Skip to content
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

Do not export null as module.exports in amd.js. Resolves #2332. #2334

Merged
merged 5 commits into from Jun 7, 2021

Conversation

joeldenning
Copy link
Collaborator

See #2332 - both system-core and named-exports do not work if _export(null) occurs, as it appears to be invalid. However, amd.js would do this as explained in #2332. My fix here is specific only to null, rather than an object check + null check, since it's valid to loop over the keys of functions for re-exporting.

@github-actions
Copy link

github-actions bot commented Jun 1, 2021

File size impact

Merging issue-2332 into master will impact 4 files in 3 groups.

browser (2/2)
File raw gzip brotli Event
dist/s.min.js +3 (7,558) +1 (2,979) +1 (2,707) modified
dist/system.min.js +3 (11,846) +2 (4,565) +2 (4,115) modified
Total size impact +6 (19,404) +3 (7,544) +3 (6,822)
node (1/1)
File raw gzip brotli Event
dist/system-node.cjs +8 (201,506) +5 (52,169) -1 (43,856) modified
Total size impact +8 (201,506) +5 (52,169) -1 (43,856)
extras (1/8)
File raw gzip brotli Event
dist/extras/named-exports.min.js +3 (665) +2 (403) -2 (336) modified
Total size impact +3 (665) +2 (403) -2 (336)
Generated by file size impact during size-impact#915574030

Copy link
Member

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work tracking this down. Let's perhaps just make the core code resiliant to null here?

Since this is the problematic line (https://github.com/systemjs/systemjs/blob/master/src/system-core.js#L115):

    if (name.__esModule)

we could just change that line to:

    if (name && name.__esModule)

@joeldenning
Copy link
Collaborator Author

joeldenning commented Jun 2, 2021

Done! Also added similar for named-exports.js

Copy link

@saak23 saak23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good

Comment on lines 59 to 61
// https://github.com/systemjs/systemjs/issues/2332
if (module.exports !== null)
_export(module.exports);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the core change we shouldn't need this null check anymore:

Suggested change
// https://github.com/systemjs/systemjs/issues/2332
if (module.exports !== null)
_export(module.exports);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏿 updated

@joeldenning joeldenning merged commit a9a0f34 into master Jun 7, 2021
@joeldenning joeldenning deleted the issue-2332 branch June 7, 2021 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants