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

esm: emit experimental warnings in common place #42314

Conversation

JakobJingleheimer
Copy link
Contributor

@JakobJingleheimer JakobJingleheimer commented Mar 12, 2022

Previously, experimental warnings were scattered (sometimes by me) around the ESM code with inconsistent messaging. This PR consolidates them to ESMLoader instantiation (so subsequent code does not need to consider whether a warning has yet been emitted).

This PR also adds an experimental warning for Network Imports (which was previously not emitted).

@JakobJingleheimer JakobJingleheimer added esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders labels Mar 12, 2022
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Mar 12, 2022

Review requested:

  • @nodejs/loaders
  • @nodejs/modules

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Mar 12, 2022
@JakobJingleheimer JakobJingleheimer force-pushed the esm/consolidate-experimental-warnings-emission-in-common-place branch from 39bf611 to bfe82dc Compare March 13, 2022 16:00
@GeoffreyBooth GeoffreyBooth force-pushed the esm/consolidate-experimental-warnings-emission-in-common-place branch from cc6202a to 59eff1f Compare March 28, 2022 01:35
@GeoffreyBooth
Copy link
Member

@JakobJingleheimer I just pushed some commits. I got the test to pass by removing the isInternal flag from the ESMLoader constructor. At least in all of the tests, ESMLoader only ever gets initialized once, by Node’s internals, and never again. I’m not sure when it would get initialized a second time—worker threads?—other than in Node’s own tests that explicitly initialize it. Is there a reason you added this flag?

With that removed, and the console.log lines removed, all the tests pass for me. So I guess unless there was some reason we needed isInternal, hopefully the commits I pushed should make this PR mergeable.

@nodejs-github-bot

This comment was marked as outdated.

@GeoffreyBooth GeoffreyBooth added module Issues and PRs related to the module subsystem. experimental Issues and PRs related to experimental features. and removed needs-ci PRs that need a full CI run. labels Mar 28, 2022
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@GeoffreyBooth GeoffreyBooth added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 28, 2022
@JakobJingleheimer
Copy link
Contributor Author

JakobJingleheimer commented Mar 28, 2022

@GeoffreyBooth alas, no: the isInternal flag is necessary for the real world. There are 2 instances of ESMLoader:

The 1st Node.js uses internally to load custom loaders.

The 2nd is what the custom loaders get shoved into and runs when user-land code runs.

Without the isInternal, IRL, the specifier resolution warning prints twice (the others don't because they're using emitExperimentalWarning(), which de-dupes).

@GeoffreyBooth GeoffreyBooth added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. labels Mar 28, 2022
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Mar 28, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/42314
✔  Done loading data for nodejs/node/pull/42314
----------------------------------- PR info ------------------------------------
Title      esm: emit experimental warnings in common place (#42314)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     JakobJingleheimer:esm/consolidate-experimental-warnings-emission-in-common-place -> nodejs:master
Labels     module, process, experimental, esm, author ready, loaders, commit-queue-squash
Commits    8
 - esm: emit experimental warnings in common place
 - fixup: switch test from substring to regex
 - fixup: delint
 - WIP: switch specifier resolution warning to custom message
 - fixup: remove log
 - fixup: remove isInternal flag for ESMLoader
 - fixup: lint
 - fixup: prevent the specifier resolution warning from being printed twice
Committers 1
 - Geoffrey Booth 
PR-URL: https://github.com/nodejs/node/pull/42314
Reviewed-By: Antoine du Hamel 
Reviewed-By: Geoffrey Booth 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/42314
Reviewed-By: Antoine du Hamel 
Reviewed-By: Geoffrey Booth 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last review:
   ⚠  - fixup: prevent the specifier resolution warning from being printed twice
   ℹ  This PR was created on Sat, 12 Mar 2022 16:41:20 GMT
   ✔  Approvals: 2
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/42314#pullrequestreview-908174329
   ✔  - Geoffrey Booth (@GeoffreyBooth): https://github.com/nodejs/node/pull/42314#pullrequestreview-923226427
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-03-28T18:10:29Z: https://ci.nodejs.org/job/node-test-pull-request/43219/
- Querying data for job/node-test-pull-request/43219/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/2054946216

@GeoffreyBooth GeoffreyBooth added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Mar 28, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 28, 2022
@nodejs-github-bot nodejs-github-bot merged commit 5a927ef into nodejs:master Mar 28, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 5a927ef

@GeoffreyBooth GeoffreyBooth deleted the esm/consolidate-experimental-warnings-emission-in-common-place branch March 28, 2022 21:57
juanarbol pushed a commit that referenced this pull request Apr 4, 2022
PR-URL: #42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
juanarbol pushed a commit to juanarbol/node that referenced this pull request Apr 5, 2022
PR-URL: nodejs#42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This was referenced Apr 5, 2022
juanarbol pushed a commit that referenced this pull request Apr 6, 2022
PR-URL: #42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
@GeoffreyBooth GeoffreyBooth mentioned this pull request Apr 11, 2022
10 tasks
@kachkaev
Copy link

kachkaev commented Apr 24, 2022

👋 @JakobJingleheimer! I’m not familiar with Node.js internals, but I guess that this change could potentially break a workaround in here: #30810 Could you please share your thoughts in that issue if it’s relevant?

It’d be great to know how to suppress warnings in Node 18 like in Node 16.
Found a working patch: #30810 (comment)

xtx1130 pushed a commit to xtx1130/node that referenced this pull request Apr 25, 2022
PR-URL: nodejs#42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
juanarbol pushed a commit that referenced this pull request May 31, 2022
PR-URL: #42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
danielleadams pushed a commit that referenced this pull request Jun 27, 2022
PR-URL: #42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
targos pushed a commit that referenced this pull request Jul 11, 2022
PR-URL: #42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
targos pushed a commit that referenced this pull request Jul 11, 2022
PR-URL: #42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
PR-URL: #42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
PR-URL: nodejs/node#42314
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. esm Issues and PRs related to the ECMAScript Modules implementation. experimental Issues and PRs related to experimental features. loaders Issues and PRs related to ES module loaders module Issues and PRs related to the module subsystem. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants