Has anyone gotten Webpack to work with Typescript for building the runtime index.js
bundle?
I can only get it to output browser code, which the server can’t parse, or code which doesn’t seem complete. Setting Webpack’s "target": "node"
option has no effect (still outputs browser code), and using "target": "es5"
causes InitModule function not found.
fatal error when the server tries to start.
Webpack is necessary since Typescript can’t natively bundle its code with node modules (like lodash). So you need to use Webpack to bundle it instead.
const path = require("path");
module.exports = {
entry: "./src/main.ts",
target: "es5",
module: {
rules: [
{
test: /\.ts$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
path: path.resolve(__dirname, "build"),
filename: "index.js",
},
};