I have the following webpack 5 configuration for transpiling server code which I want to transpile to esm syntax and not commonjs:
const config: Configuration = merge(common, overrides, {
name: 'server',
target: 'node',
experiments: {
outputModule: true,
topLevelAwait: true,
},
output: {
path: paths.appBuild,
filename: options.filename,
publicPath,
library: {
type: 'module',
},
chunkFormat: 'module',
environment: {
const: true,
destructuring: true,
forOf: true,
module: true,
templateLiteral: true,
},
},
I have set "type": "module" in the package.json file.
My tsconfig.json has these compilerOptions:
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",
"module": "ESNext",
But when I look at the output, it still has require statements:
const svg_namespaceObject = require("@cutting/svg");