-
Notifications
You must be signed in to change notification settings - Fork 136
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
Include named exports in CJS shims when using importSync
#1531
Merged
Commits on Jul 13, 2023
-
Include named exports in CJS shims when using
importSync
`importSync()` is intended to work like `import()` (buy sync), which, in turns, is expected to work like a namespace import – `import * as NS from "foo";`. In general, we would expect that to be interchangable with `const NS = importSync("foo");`. Prior to this commit, this is not true for commonjs packages: ```js import * as QUnit1 from "qunit"; // => { QUnit, assert, begin, config, ... } QUnit1.assert // => function const QUnit2 = importSync("qunit"); // => { default: { QUnit, assert, begin, config, ... } } QUnit2.assert // => undefined ``` Of course, using ES imports on commonjs packages is, in itself, an ill-defined concept, but nevertheless, it is a very common interop requirement. The previous behavior is introduced in embroider-build#1076. The intent appears to be fixing a different interop issue, where we would expect these to work the same way: ```js import QUnit1 from "qunit"; // => { Qunit, assert, begin, config, ... } QUnit1.assert // => function const QUnit2 = importSync("qunit").default; // => { QUnit, assert, begin, config, ... } QUnit2.assert // => function ``` The fix in embroider-build#1076, however, broke the exepctation that `import()` should behave like a namespace improt statement for CJS modules. This commit attempts to satisfy both of these requirements, with one caveat: `importSync("foo").default` is present on the shimed CJS modules, but in `import * as FOO from "foo";`, `FOO.default` is undefined. Arguably, this is a bug in webpack's implementation – if you are able to write an import statement that references the default export, you should be able to do the same in the namespace import as per the spec. So, the implementation here is different but more correct. Fixes embroider-build#1530
Configuration menu - View commit details
-
Copy full SHA for ff85425 - Browse repository at this point
Copy the full SHA ff85425View commit details
Commits on Jul 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for ee5cf20 - Browse repository at this point
Copy the full SHA ee5cf20View commit details -
Configuration menu - View commit details
-
Copy full SHA for c909f46 - Browse repository at this point
Copy the full SHA c909f46View commit details
Commits on Jul 15, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 416d189 - Browse repository at this point
Copy the full SHA 416d189View commit details -
bump filename to make this work in classic
In classic builds, multiple different versions of `@embroider/macros` may get smashed together, overwriting each other's files in ways that we cannot control. If we want packages that upgrade to get this bugfix to reliably have it, they need to use a new name to refer to the module.
Configuration menu - View commit details
-
Copy full SHA for 7acddac - Browse repository at this point
Copy the full SHA 7acddacView commit details -
Configuration menu - View commit details
-
Copy full SHA for fd28bc4 - Browse repository at this point
Copy the full SHA fd28bc4View commit details
Commits on Jul 16, 2023
-
Configuration menu - View commit details
-
Copy full SHA for e46c67f - Browse repository at this point
Copy the full SHA e46c67fView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.