Skip to content

Instantly share code, notes, and snippets.

@arvidfm
Last active July 7, 2025 16:19
Show Gist options
  • Save arvidfm/350eb8bdb328b0e70fec2eeea240a6df to your computer and use it in GitHub Desktop.
Save arvidfm/350eb8bdb328b0e70fec2eeea240a6df to your computer and use it in GitHub Desktop.
Webpack commonjs-static bug
export function main() {
const a = [1, 2, 3];
// remove the below line to avoid the issue
const b = [4, 5, 6, ...a];
}
{
"name": "webpack-test",
"version": "1.0.0",
"description": "",
"private": true,
"sideEffects": false,
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "9.5.2",
"typescript": "5.0.4",
"webpack": "5.99.8",
"webpack-cli": "6.0.1"
}
}
module.exports = {
entry: `./src/index.ts`,
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
},
],
},
mode: 'development',
output: {
library: {
type: 'commonjs-static',
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment