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

lib,test: improves ERR_REQUIRE_ESM message #30694

Closed
wants to merge 7 commits into from

Conversation

juanarbol
Copy link
Member

@juanarbol juanarbol commented Nov 28, 2019

Fixes: #30599

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@juanarbol
Copy link
Member Author

If this get landed, please re-write that commit message before landing, mine is horrible, haha ):

@juanarbol
Copy link
Member Author

FIxing tests issues

@MylesBorins MylesBorins added the esm Issues and PRs related to the ECMAScript Modules implementation. label Nov 28, 2019
Copy link
Contributor

@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.

Looking good, thanks again for working on this.

lib/internal/modules/cjs/loader.js Outdated Show resolved Hide resolved
lib/internal/modules/cjs/loader.js Outdated Show resolved Hide resolved
lib/internal/errors.js Outdated Show resolved Hide resolved
lib/internal/errors.js Outdated Show resolved Hide resolved
@juanarbol
Copy link
Member Author

This changes are breaking test/parallel/test-require-mjs.js, I've attached debugger and no idea what's going on.

Output:

assert.js:561
      throw err;
      ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

  Comparison {
+   code: 'ERR_INVALID_ARG_TYPE',
+   message: 'The "path" argument must be of type string. Received type object'
-   code: 'ERR_REQUIRE_ESM',
-   message: /Must use import to load ES Module/
  }
    at Object.<anonymous> (/Users/juanjose/Documents/GitHub/Node/node/test/parallel/test-require-mjs.js:5:8)
    at Module._compile (internal/modules/cjs/loader.js:1185:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:944:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
    at internal/main/run_main_module.js:17:47 {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: [NodeError],
  expected: [Object],
  operator: 'throws'
}

lib/internal/errors.js Outdated Show resolved Hide resolved
lib/internal/errors.js Outdated Show resolved Hide resolved
Copy link
Contributor

@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.

Seems like we're there? Thanks for your persistence on this one!

@nodejs-github-bot
Copy link
Collaborator

@guybedford guybedford added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 4, 2019
@nodejs-github-bot
Copy link
Collaborator

guybedford pushed a commit that referenced this pull request Dec 5, 2019
@guybedford
Copy link
Contributor

Landed in 81ac302.

@guybedford guybedford closed this Dec 5, 2019
targos pushed a commit that referenced this pull request Dec 9, 2019
@MylesBorins MylesBorins mentioned this pull request Dec 13, 2019
MylesBorins pushed a commit that referenced this pull request Jan 12, 2020
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
@MylesBorins MylesBorins mentioned this pull request Feb 8, 2020
@pinguinjkeke
Copy link
Contributor

It introduces a breaking change.
It was emitted as a warning before update to the latest version.
Now it throws the error and prevents execution.

@MylesBorins
Copy link
Contributor

@pinguinjkeke experimental features in Node.js are not covered by the semver contract. More details about this can be found in our docs

We do try and be cautious though. That is part of the reason that we landed this change in a SemverMinor on 12.x and have kept the ESM implementation behind a flag.

I apologise for the inconvenience but I hope you understand that being pragmatic about this will allow us to have a more consistent experience across versions of node when we stabilize the api

@juanarbol juanarbol deleted the combine-esmodules-warning branch January 19, 2021 16:24
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. esm Issues and PRs related to the ECMAScript Modules implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combine ERR_REQUIRE_ESM with warning
5 participants