Skip to content

Commit

Permalink
Merge pull request #29 from PolymathNetwork/feat/MSDK-13-sandbox
Browse files Browse the repository at this point in the history
Feat/msdk 13 sandbox
  • Loading branch information
VictorVicente authored Mar 3, 2020
2 parents 03adbc9 + 65c87cd commit b42f2d1
Show file tree
Hide file tree
Showing 7 changed files with 2,278 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ npm-package/
.idea/
coverage/
test.ts
sandbox.ts
docs/
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"author": "Polymath Studios Inc.",
"license": "ISC",
"scripts": {
"start": "cross-env webpack-dev-server --config=webpack.config.dev.js",
"test": "jest --coverage",
"build:ts": "ttsc -b",
"build:docs": "typedoc src",
Expand All @@ -27,6 +28,8 @@
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
"@zerollup/ts-transform-paths": "^1.7.11",
"awesome-typescript-loader": "^5.2.1",
"case-sensitive-paths-webpack-plugin": "^2.3.0",
"cross-env": "^7.0.0",
"cz-conventional-changelog": "^3.0.2",
"eslint": "^6.8.0",
Expand All @@ -38,6 +41,7 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-simple-import-sort": "^5.0.1",
"eslint-plugin-standard": "^4.0.1",
"html-webpack-plugin": "^3.2.0",
"husky": "^4.1.0",
"jest": "25.1.0",
"lint-staged": "^8.1.5",
Expand All @@ -49,9 +53,14 @@
"ts-jest": "^25.2.1",
"ts-mock-imports": "^1.2.6",
"tsconfig-paths": "^3.9.0",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"ttypescript": "^1.5.10",
"typedoc": "^0.16.8",
"typescript": "3.7.5"
"typescript": "3.7.5",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"webpack-merge": "^4.2.2"
},
"config": {
"commitizen": {
Expand Down
26 changes: 26 additions & 0 deletions tsconfig-dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths",
"exclude": ["*"]
}
],
"target": "es6",
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"lib": ["es2017", "dom"],
"typeRoots": ["./node_modules/@types", "./src/typings"]
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"lib": ["es2017", "dom"],
"typeRoots": ["./node_modules/@types", "./src/typings"]
},
"exclude": ["dist", "node_modules", "test.ts"]
"exclude": ["dist", "node_modules", "sandbox.ts"]
}
21 changes: 21 additions & 0 deletions webpack.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');

module.exports = {
devtool: 'cheap-module-source-map',
mode: 'development',
module: {
rules: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
},
],
},
resolve: {
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin()],
},
plugins: [new CaseSensitivePathsPlugin()],
};
60 changes: 60 additions & 0 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const fs = require('fs');
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const baseConfig = require('./webpack.base');

const SANDBOX_FILE_NAME = 'sandbox.ts';

const sandboxFilePath = path.resolve(`./${SANDBOX_FILE_NAME}`);

if (!fs.existsSync(sandboxFilePath)) {
fs.writeFileSync(
sandboxFilePath,
"import { Polymesh } from './src/Polymesh';\r\n\r\n/**\r\n * Polymesh SDK connection\r\n */\r\nasync function run(): Promise<void> {\r\n await Polymesh.connect({\r\n nodeUrl: 'ws://78.47.38.110:9944',\r\n });\r\n}\r\n\r\nrun();"
);
}

const devConfig = merge.smart(baseConfig, {
entry: path.resolve(__dirname, SANDBOX_FILE_NAME),
module: {
rules: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig-dev.json',
},
},
],
},

devServer: {
// This is not written to the disk, but has to be named anyways
contentBase: path.join(__dirname, 'dist'),
watchContentBase: true,
// Opens the browser when the watcher starts
open: true,
// No need for compression on development
compress: false,
port: process.env.PORT || 9000,
},
plugins: [
new HtmlWebpackPlugin({
title: 'Polymesh SDK - Sandbox',
}),
],
output: {
pathinfo: true,
filename: 'devServer.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
node: {
fs: 'empty',
},
});

module.exports = devConfig;
Loading

0 comments on commit b42f2d1

Please sign in to comment.