webpack-plugin-serve icon indicating copy to clipboard operation
webpack-plugin-serve copied to clipboard

WARNING in DefinePlugin Conflicting values for 'ʎɐɹɔosǝʌɹǝs'

Open constgen opened this issue 3 years ago • 6 comments

  • 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?

  1. Build a project in dev and watch mode > webpack --mode development
  2. Open served page in the browser and refresh it (F5) al least one time
  3. 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}))); 

constgen avatar Jan 13 '22 17:01 constgen

Sounds like that fix might work. We'll need a specific test written for that change.

shellscape avatar Jan 13 '22 17:01 shellscape

Let me see how to do tests

constgen avatar Jan 13 '22 17:01 constgen

I am getting this too! webpack-plugin-serve v1.6.0

alielmajdaoui avatar Feb 27 '22 21:02 alielmajdaoui

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: []
},

constgen avatar Feb 28 '22 14:02 constgen

It did the trick! Could you explain what those 2 options do?

alielmajdaoui avatar Mar 08 '22 21:03 alielmajdaoui

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

constgen avatar Mar 17 '22 17:03 constgen