Closed libla closed 2 years ago
Sorry for delay, yep, it is wrong setup, don't use:
rules: [{
test: require.resolve('./src/test.ts'),
loader: 'expose-loader',
options: {
exposes: {
globalName: "test",
override: true,
}
}
}, {
test: /\.ts$/,
loader: 'ts-loader'
}]
Because you apply two loader for the same file at the same time, so webpack tried to appy both, so you have different output, set exclude
with ./src/test.ts
for ts-loader
and setup two loader for test.ts
- expose-loader
and ts-loader
.
Feel free to feedback
Bug report
I use expose-loader in webpack5, and I found when webpack --watch is running and the file changed, will output different with webpack, the combined filename without "-exposed" suffix. I create a demo for this: https://github.com/libla/expose-loader-demo.git
Actual Behavior
One of the outputs is
and another is
Expected Behavior
webpack and webpack --watch will get same output
How Do We Reproduce?
I create a demo for this: https://github.com/libla/expose-loader-demo.git checkout this repository, run command
npm run build
get the first output. Next, run commandnpm run watch
, then modify a file (such as adding an empty line), wait watch poll, get the other output.Please paste the results of
npx webpack-cli info
here, and mention other relevant information