webpack-plugin-serve
webpack-plugin-serve copied to clipboard
WARNING in DefinePlugin Conflicting values for 'ʎɐɹɔosǝʌɹǝs'
- Webpack Version: 5.38.1
- Operating System (or Browser): Windows 10, Firefox 95.0.2
- Node Version: v14.15.5
- webpack-plugin-serve Version: 1.5.0
How Do We Reproduce?
- Build a project in dev and watch mode
> webpack --mode development
- Open served page in the browser and refresh it (F5) al least one time
- Change something in the source code to trigger HMR
Expected Behavior
Rebuild should be done successfully without errors and warnings
Actual Behavior
Rebuild is done. Everything works. But this this warning is shown in the terminal of Webpack process
WARNING in DefinePlugin
Conflicting values for 'ʎɐɹɔosǝʌɹǝs'
'{"compress":null,"headers":null,"historyFallback":{},"hmr":"refresh-on-failure","host":"localhost","liveReload":false,"log":{"lev"minimal","ramdisk":false,"secure":false,"status":true,"client":{"silent":true,"retry":true},"waitForBuild":true,"address":"localhost:3000","compilerName":null,"wpsId":"fb5dfed"}' !== '{"compress":null,"headers":null,"historyFallback":{"htmlAcceptHeaders":["text/html","*/*"],"rewrites":[]},"hmr":"refresh-on-failure","host":"localhost","liveReload":false,"log":{"level":"info","timestamp":false,"prefix":{"template":"{{level}}"},"name":"webpack-plugin-serve"},"open":false,"port":3000,"progress":"minimal","ramdisk":false,"secure":false,"status":true,"client":{"silent":true,"retry":true},"waitForBuild":true,"address":"localhost:3000","compilerName":null,"wpsId":"fb5dfed"}'
And it is multiplied every time rebuild is triggered. So the terminal becomes higly polluted at some moment.
This happens because ʎɐɹɔosǝʌɹǝs
is changed between rebuilds. The only difference is this part "historyFallback":{"htmlAcceptHeaders":["text/html","*/*"],"rewrites":[]}
. I found that this object is mutated when it is passed to the 3rd party middleware on this line https://github.com/shellscape/webpack-plugin-serve/blob/ba83bf5b041604cd7e20f22470ca52be10491060/lib/middleware.js#L123 . We could fix it by making a clone of this parameter to preserve immutability. Is it true?
app.use(convert(historyApiFallback({ ...options.historyFallback})));
Sounds like that fix might work. We'll need a specific test written for that change.
Let me see how to do tests
I am getting this too! webpack-plugin-serve v1.6.0
Untill the moment I finish the PR I can recommend you to use this workaround. Configure settings of this plugin using this
historyFallback: {
htmlAcceptHeaders: ["text/html", "*/*"],
rewrites: []
},
It did the trick! Could you explain what those 2 options do?
For some reason during building historyFallback
option is mutated. And our value in options is what it is changed to. So we define the same value that will not be detected as different by Webpack