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

Refactor experimental-modules check into runMain #21350

Closed
wants to merge 4 commits into from

Conversation

guybedford
Copy link
Contributor

This provides a slightly cleaner separation, moving the top-level ESM load to higher up in the bootstrap as it should be.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@devsnek
Copy link
Member

devsnek commented Jun 15, 2018

its worth noting this isn't just a refactor, it actually fixes a bug where the loader can't run cjs. i can't quite figure out the repro though.

edit:
the bug is that the translator for cjs calls to Module._load which checks isMain and if its true calls loader.import, but the module was already imported so it just dies there.

moving this code ensures that the loop never happens.

/cc @guybedford could you add a test for this?

@guybedford
Copy link
Contributor Author

@devsnek well spotted on the failure case. Note that the failure case also exposes another bug that duplicate import executions of module jobs don't seem to be properly deduped through job.run execution. It may be better to create a test for that and solve the general issue separately.

Copy link
Member

@bmeck bmeck left a comment

Choose a reason for hiding this comment

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

would like to see a test per @devsnek if possible

@guybedford
Copy link
Contributor Author

(CI failure unrelated)

assert.strictEqual(require.main.exports.asdf, 'asdf');
const path = require('path');

const entry = path.resolve(__dirname, '../fixtures/es-modules/cjs.js');
Copy link
Member

Choose a reason for hiding this comment

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

isn't there like common.fixture or smth for this

@guybedford
Copy link
Contributor Author

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM but it would be nice if the nit from @devsnek could be addressed before landing.

@devsnek
Copy link
Member

devsnek commented Jun 20, 2018

@guybedford is this ready to land?

Copy link
Contributor

@Fishrock123 Fishrock123 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 aside from gus's comment

@addaleax
Copy link
Member

This is being reported as a regression in 10.5.0 already, see e.g. nodejs/help#1349

I’ve pushed a commit addressing @devsnek’s nit + adding a common.mustCall() where I think we need it

CI: https://ci.nodejs.org/job/node-test-pull-request/15542/

@devsnek
Copy link
Member

devsnek commented Jun 20, 2018

es-module/test-esm-error-cache.js is failing but i can't really figure out why...

@guybedford
Copy link
Contributor Author

@devsnek it turns out because of this bug that test wasn't actually running to completion, and the file path was incorrect. I've resolved this here now.

CI: https://ci.nodejs.org/job/node-test-pull-request/15548/

@guybedford
Copy link
Contributor Author

Merged in 883e1cd.

@guybedford guybedford closed this Jun 21, 2018
guybedford added a commit that referenced this pull request Jun 21, 2018
PR-URL: #21350
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
targos pushed a commit that referenced this pull request Jun 22, 2018
PR-URL: #21350
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
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.