-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account for ESM/CJS compat mode __esModule #927
Comments
A table from esbuild folks for reference evanw/esbuild#532 (comment) |
Looking at the results for case 11 in the table here unless we want to be more like tsc and some transpilers, no work needs to be done other than merging @kriskowal @kumavis please correct me if I'm wrong. I don't see any other use for |
I think we’re close enough. If we can get parity with Parcel, Rollup &c, it would be nice, but not at the expense of Node.js parity or our sanity. |
The overlap between parcel and sanity is not something I'm comfortable with https://github.com/endojs/endo-e2e-tests/blob/naugtur-matrix-iteration/matrix/table.md Anyway - we've got node compatibility and a bit more. This is also useful for understanding the scope. So I don't think we need to do anything else here unless we want a --esModuleInterop flag. |
Ok, so there's a PR now. #1149
It does create a behavior difference between endo and node getting endo closer to what bundlers do. I could add in some failing tests to ilustrate those. The only sane way to introduce support for this would be in the |
My preference is not to modify third-party-module support in such a way that WASM or any other language would interact with Failing tests would be illuminating! You mentioned out-of-band that there might be a path forward but it would require a new compartment hook. Can you propose such a hook? Ideally, the hook is not coupled specifically to the My intuition is that we shouldn’t spend too much effort on |
We'd have to have means for a parser implementation to provide a hook that'd then be called in module-instance to inform the process of wiring up the updaters to exports. I was considering putting metadata in the __esModule value itself but I doubt it'd get past review :D As for failing tests - I'd need to find real examples and I'm struggling to find ones that actually need the __esModules logic to work correctly for their dependents. And for each such theoretical example I've already seen a counter example of a module that wouldn't work if that was implemented. Like generated code which sets __esModule but doesn't set default but people are happy to import it like the cjs module it is 😠 I'm happy leaving it unfixed until there's an issue. Where would I document that? |
For now, the compartment mapper README has a lot of notes about features, caveats, and aspirations. That’s a good place to put a note. A link to this issue would not hurt. Closing this issue until such a time is also okay. |
@naugtur Please reöpen or open a follow-up issue if the current solution needs more work. |
The SES and the Endo Compartment Mapper have a frail and under-tested implementation of CommonJS as a third-party static module record. These need to be more extensively tested and the difference between a CommonJS module that sets
exports.__esModule
distinguished from one that does now. The setter can be detected after initialization and the behavior of thedefault
getter on the proxied exports behavior varied accordingly.Background on compatibility mode esnext/es6-module-transpiler#85
The text was updated successfully, but these errors were encountered: