webpack-contrib / expose-loader

Expose Loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

opt out of development thrown error

thomas-yancey opened this issue · comments

Feature Proposal

add ability to turn off thrown error in development without turning on override

Feature Use Case

In development I can not match what occurs in production when I have two bundles I believe. if I turn on override then the second loaded bundle exposes what was requested and the first is replaced, in production with no overrides the first is exposed and the second does not override it. I understand why the error is thrown but would be nice to be able to opt out of it or maybe switch it to a warning

if (!override) {
  if (this.mode === "development") {
    code += `else throw new Error('[exposes-loader] The "${globalName.join(".")}" value exists in the global scope, it may not be safe to overwrite it, use the "override" option')\n`;
  }
}

Please paste the results of npx webpack-cli info here, and mention other relevant information

This message special for this case, you can break your application, disabling this will be unsafe

but as it stands it allows to get this functionality in production but not in development. It should allow you to have the same functionality in both environments. If I understand how it works I think it just grabs first bundles exposed package without override, but the recommendation in the docs to get past that is put overrides: true which allows the second bundle to override the first. this causes a mismatch between prod and dev

I am again on this change, it protects against problems, can you describe case why you have this situation?

Anyway, if you need this feel free to send a PR with tests

sorry for not getting back on this, on second thought I think you're right it should remain as is. Thanks