Add worker bundling configuration

This commit is contained in:
Nilay Majorwar
2021-12-18 15:52:25 +05:30
parent 2ef2ab5ea6
commit 2322ebe55d
7 changed files with 666 additions and 16 deletions

19
worker-pack/tsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist/",
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"sourceMap": true,
"incremental": true,
"noImplicitAny": true
},
}

View File

@ -0,0 +1,35 @@
const path = require("path");
const fs = require("fs");
const langNames = fs.readdirSync("engines").filter((name) => {
const stats = fs.statSync(`./engines/${name}`);
return stats.isDirectory();
});
const entryPoints = {};
for (const lang of langNames) {
entryPoints[lang] = `./engines/${lang}/engine.ts`;
}
console.log(path.resolve(__dirname, "worker-pack/tsconfig.json"));
module.exports = {
entry: entryPoints,
output: {
path: path.resolve(__dirname, "../public/workers"),
filename: "[name].js",
},
resolve: { extensions: [".ts"] },
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
configFile: path.resolve(__dirname, "tsconfig.json"),
},
},
],
},
};

View File

@ -0,0 +1,7 @@
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
});

View File

@ -0,0 +1,6 @@
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
module.exports = merge(common, {
mode: "production",
});