embroider icon indicating copy to clipboard operation
embroider copied to clipboard

error instead of warn for missing exports

Open amk221 opened this issue 1 year ago • 7 comments

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.

amk221 avatar Oct 23 '24 22:10 amk221

Anyone?

amk221 avatar Jan 16 '25 22:01 amk221

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!

NullVoxPopuli avatar Jan 17 '25 14:01 NullVoxPopuli

ok.

warning

strictExportPresence is deprecated in favor of exportsPresence option.

Since some time has passed, re-looking into exportsPresence

amk221 avatar Jan 17 '25 14:01 amk221

Yeh that works, switched from strictExportPresence to exportsPresence

amk221 avatar Jan 17 '25 15:01 amk221

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

NullVoxPopuli avatar Jan 17 '25 15:01 NullVoxPopuli

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?

amk221 avatar Jan 17 '25 15:01 amk221

Also, what does Vite do?

Vite doesn't let you import things that don't exist 🎉

NullVoxPopuli avatar Jan 17 '25 16:01 NullVoxPopuli