error instead of warn for missing exports
Currently, this:
import { foo } from 'bar';
will cause Webpack to warn if foo does not exist, but this is easily missed. Meaning its possible to ship broken code.
This PR configures strictExportPresence to error instead of warn.
But this is actually deprecated in favour of exportsPresence, which I did try but it wasn't available on the current version.
Also note it will be true by default in v6 of webpack anyway.
Reading:
- https://stackoverflow.com/questions/40539768/webpack-throw-error-on-missing-member-import
- https://github.com/webpack/webpack/discussions/14659
Regarding tests, since I'm not familiar with the embroider repo I found it hard to know where they should go. I saw some that seemed like an appropriate place, but I'll need help tbh.
Anyone?
sorrry for the delay -- our focus hasn't been on webpack lately.
Looks like CI needs to be re-ran, but the logs are old enough where I can't just click "re-run".
Would you be willing to rebase this PR? sorry!
ok.
warning
strictExportPresence is deprecated in favor of exportsPresence option.
Since some time has passed, re-looking into exportsPresence
Yeh that works, switched from strictExportPresence to exportsPresence
How should this be framed in the changelog?
- generally throwing errors where we weren't previously is a breaking change
- it could be argued that the errors were always there, but now moved from runtime to build time
I don't really know. There's some info here, like that it's already true in mjs.
I can see why it would be a breaking change, but, then again if it breaks for somebody then something was already broken they just didn't know it. If they were in runtime, and you weren't actively monitoring in (Sentry for example) you'd never know.
Yeh anyway, I don't necessarily need this to go in, just as a developer it feels like no brainer. Can I leave it to you all to decide whether you want it or not?
Also, what does Vite do?
Also, what does Vite do?
Vite doesn't let you import things that don't exist 🎉