GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — esm: add `--import` flag by MoLow · Pull Request #43942 · nodejs/node

Conversation

@MoLow

@MoLow MoLow commented Jul 22, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fixes: #40110

todo:

  • add tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mirismaili, jimmywarting, styfle, and Kifzy reacted with thumbs up emoji jimmywarting reacted with hooray emoji bricss, lin72h, jtoar, and benjamingr reacted with eyes emoji
All reactions
  • 👍 4 reactions
  • 🎉 1 reaction
  • 👀 4 reactions
@MoLow
MoLow force-pushed the add-experimental-import branch from 06de59d to 198f88f Compare July 22, 2022 07:16
@nodejs-github-bot

ghost commented Jul 22, 2022

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/modules
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Jul 22, 2022
@MoLow MoLow added the esm Issues and PRs related to the ECMAScript Modules implementation. label Jul 22, 2022
aduh95
aduh95 reviewed Jul 22, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/process/esm_loader.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JakobJingleheimer

This comment was marked as outdated.

Sign in to view
@aduh95

ghost commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

I thought this functionality is already possible with the globalPreload hook.

node/doc/api/esm.md

Lines 940 to 941 in d2fe72a

scope that the application runs in. This hook allows the return of a string
that is run as a sloppy-mode script on startup.

--import is about loading ESM, so it's definitely not the same thing as sloppy-mode script. See #40110 if you need context on this feature.

JakobJingleheimer reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins

ghost commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

Is this still spec compliant?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

ghost commented Jul 22, 2022

Copy link
Copy Markdown
Member

@MylesBorins What part of the spec is relevant?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

GeoffreyBooth
GeoffreyBooth reviewed Jul 22, 2022
View reviewed changes

ghost left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This needs tests, including around variations of async behaviors:

  • An --import module that contains top-level await.
  • An --import module that does something async. Do we automatically await it before the next --import module runs? Before user code runs?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MoLow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread src/node_options.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/node_options.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

@guybedford

ghost commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

Overall I'm very much in favour of this, thanks for the PR!

I didn't follow the full thread, but what is the reasoning for starting with --experimental-import instead of just --import here? We can still label the feature as experimental without needing the experimental prefix IMO.

GeoffreyBooth, aduh95, MoLow, ljharb, JakobJingleheimer, dnalborczyk, and benjamingr reacted with thumbs up emoji
All reactions
  • 👍 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the add-experimental-import branch from 198f88f to 5a15e7a Compare July 23, 2022 21:50
JakobJingleheimer
JakobJingleheimer reviewed Jul 24, 2022
View reviewed changes
Comment thread lib/internal/process/esm_loader.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/process/esm_loader.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/process/esm_loader.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/process/esm_loader.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the add-experimental-import branch from dfad8f5 to a7d6bae Compare July 25, 2022 14:22
aduh95
aduh95 reviewed Jul 25, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow

ghost commented Jul 25, 2022 •
edited by MoLow
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

added some tests, I am not sure if these are enough tests. please direct me to additional cases that need testing if I missed some.
in addition, I am ok with removing the --import from the flag name, just added it since it was what was written in the original issue
CC @GeoffreyBooth

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Jul 25, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow MoLow changed the title esm: add --experimental-import flag esm: add --import flag Jul 25, 2022
@MoLow MoLow added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Jul 25, 2022
GeoffreyBooth
GeoffreyBooth reviewed Jul 25, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/es-module/test-esm-import-flag.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/es-module/test-esm-import-flag.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/print_imported.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/process/esm_loader.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Jul 25, 2022
View reviewed changes
Comment thread test/es-module/test-esm-import-flag.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/es-module/test-esm-import-flag.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/es-module/test-esm-import-flag.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/esm-top-level-await.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/esm-top-level-await.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/print_imported.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/esm-top-level-await.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins

ghost commented Jul 25, 2022

Copy link
Copy Markdown
Contributor

@MylesBorins What part of the spec is relevant?

I was curious about how this work in populating the internal cache and global state. Will this work similarly to subsequent script tags for example.

There might not be a spec issue, just wanted to confirm

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth

ghost commented Jul 25, 2022

Copy link
Copy Markdown
Member

Once this lands, I think we should mark it as blocked from release until we also land the “move loaders off thread” work, since that effort might effect --import. It would be similar to how we added the “backport-blocked-v18.x” tag to the chaining loaders PR until we had a few loaders-related PRs ready to release together. Thoughts? I know this will be experimental but I’m hopeful that the other PR isn’t too far behind and therefore we could release these together and minimize churn.

ljharb reacted with thumbs up emoji MoLow reacted with eyes emoji
All reactions
  • 👍 1 reaction
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Jul 25, 2022
View reviewed changes
Comment thread test/es-module/test-esm-import-flag.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/es-module/test-esm-loader-http-imports.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/es-module/test-esm-loader-http-imports.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/print_3.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/esm-top-level-await.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/esm-top-level-await.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

GeoffreyBooth
GeoffreyBooth reviewed Jul 26, 2022
View reviewed changes
Comment thread test/es-module/test-esm-import-flag.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/fixtures/es-modules/print_3.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/es-module/test-esm-loader-http-imports.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/process/execution.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth GeoffreyBooth added module Issues and PRs related to the module subsystem. loaders Issues and PRs related to ES module loaders. labels Jul 26, 2022
@MoLow
MoLow requested a review from benjamingr July 26, 2022 16:04
This was referenced Nov 29, 2022
Proposal: modify cli to nudge People to do the right thing in nodejs 19.1+ microsoft/TypeScript#51681
Closed
Verify NJS 19,1 import require flags lemanschik/modules#2
Closed
PR: cli api just-js/just#56
Closed
@frank-dspeed frank-dspeed mentioned this pull request Dec 4, 2022
Add Support for Top Level Await inside CJS oracle/graaljs#350
Closed
@aduh95 aduh95 removed the backport-blocked-v18.x label Sep 6, 2023
@ruyadorno ruyadorno added the backport-requested-v18.x label Sep 7, 2023
@ruyadorno

ghost commented Sep 7, 2023

Copy link
Copy Markdown
Member

This will need manual backport in case we want to land it in v18.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth

ghost commented Sep 7, 2023

Copy link
Copy Markdown
Member

Yes, we need this on 18 to support the module customization hooks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95 aduh95 mentioned this pull request Sep 7, 2023
[v18.x backport] esm: add --import flag #49539
Closed
@aduh95 aduh95 added backport-open-v18.x and removed backport-requested-v18.x labels Sep 8, 2023
@ruyadorno ruyadorno mentioned this pull request Sep 8, 2023
v18.18.0 proposal #49220
Merged
@ruyadorno ruyadorno added backported-to-v18.x and removed backport-open-v18.x labels Sep 9, 2023
styfle
styfle reviewed Sep 19, 2023
View reviewed changes
Comment thread doc/api/cli.md
[#42511]: https://github.com/nodejs/node/issues/42511
[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/
[CommonJS]: modules.md
[CommonJS module]: modules.md

ghost Sep 19, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks like you have two links to the same page here

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daquinoaldo daquinoaldo mentioned this pull request Feb 28, 2025
Support type stripping in node_modules #57215
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 13, 2026
docs: add deployer OTel SDK setup note to README wiggitywhitney/commit-story-v2#64
Merged
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ljharb ljharb ljharb left review comments
@GeoffreyBooth GeoffreyBooth GeoffreyBooth approved these changes
@benjamingr benjamingr benjamingr approved these changes
@JakobJingleheimer JakobJingleheimer JakobJingleheimer approved these changes
@aduh95 aduh95 aduh95 approved these changes
+2 more reviewers
@styfle styfle styfle left review comments
@targos targos targos left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash PRs the Commit Queue should land as one squashed commit. esm Issues and PRs related to the ECMAScript Modules implementation. 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. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add --import <module> flag for pre-loading ESM modules

Uh oh!

There was an error while loading. Please reload this page.

12 participants

@MoLow @nodejs-github-bot @JakobJingleheimer @aduh95 @MylesBorins @targos @guybedford @GeoffreyBooth @ljharb @benjamingr @ruyadorno @styfle
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.