Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Commit

Permalink
Don't bundle node and web targets, only for third "bundle" target
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnski committed Feb 26, 2021
1 parent d68eca8 commit ee4cac3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 37 deletions.
3 changes: 2 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
]
]
}
}
},
"ignore": ["src/**/*.test.ts"]
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Sia Skynet Javascript Client",
"browser": "dist/web/index.web.js",
"main": "dist/node/index.node.js",
"module": "src/index.web.js",
"module": "dist/web/index.web.js",
"files": [
"dist/*"
],
Expand All @@ -14,7 +14,10 @@
"not OperaMini all"
],
"scripts": {
"build": "rimraf dist && yarn run webpack",
"build": "rimraf dist && yarn build-bundle && yarn build-node && yarn build-web",
"build-bundle": "yarn run webpack",
"build-node": "babel src --out-dir dist/node --extensions .ts && tsc --project tsconfig.build.json --outDir dist/node && rimraf dist/node/**/web* && rimraf dist/node/**/*web*",
"build-web": "babel src --out-dir dist/web --extensions .ts && tsc --project tsconfig.build.json --outDir dist/web && rimraf dist/web/**/node* && rimraf dist/web/**/*node*",
"lint:eslint": "eslint --ext .ts src utils --max-warnings 0",
"lint:tsc": "tsc",
"prepublishOnly": "yarn build",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"types": ["node", "jest"],
"typeRoots": ["./types", "./node_modules/@types"]
},
"include": ["types/**/*.d.ts"],
"include": ["src", "types/**/*.d.ts"],
"exclude": ["src/**/*.test.ts"]
}
39 changes: 6 additions & 33 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const path = require("path");
const { merge } = require("webpack-merge");

var baseConfig = {
module.exports = {
entry: "./src/index.web.ts",
target: "web",
mode: "production",

module: {
Expand All @@ -10,46 +12,17 @@ var baseConfig = {
test: /\.tsx?$/,
exclude: /(node_modules|bower_components)/,
loader: "babel-loader",
options: {
ignore: ["src/**/*.test.ts"],
},
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
output: {
path: path.resolve(__dirname, "./dist/bundle"),
// The filename needs to match the index.web.d.ts declarations file.
filename: "index.js",
library: "skynet",
libraryTarget: "umd",
},
};

let targets = ["web", "node"].map((target) => {
let base = merge(baseConfig, {
entry: "./src/index." + target + ".ts",
target: target,
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
configFile: "tsconfig.build.json",
compilerOptions: {
outDir: path.resolve(__dirname, "./dist/" + target),
},
},
},
],
},
output: {
path: path.resolve(__dirname, "./dist/" + target),
filename: "index." + target + ".js",
},
});
return base;
});

module.exports = targets;

0 comments on commit ee4cac3

Please sign in to comment.