-
Notifications
You must be signed in to change notification settings - Fork 43
12 LTS backporting of ERR_REQUIRE_ESM #468
Comments
I believe the eslint one has been fixed? Either way they are errors, and the user who set type module, while using a tool that can’t handle it, is fully in control of being able to revert that change pending the tool adjusting its behavior. It seems like the errors are desirable. |
Can confirm. The PR I submitted to add I also agree 100%. Better to error sooner so we know what needs to be patched. |
Just so I’m clear, aren’t these errors already unflagged on 12? Or they were briefly unflagged on 12 before we put them behind |
Please don't turn the error off, or turn it into a warning. Mocha relies on that error in its support of ESM: it first |
Gil would it work to disable the .mjs error only? You could still detect
the file extension manually. My concern there is I think the mjs
ERR_REQUIRE_ESM still breaks require(‘esm’). We should probably double
check this for certain though.
…On Tue, Jan 14, 2020 at 11:25 Gil Tayar ***@***.***> wrote:
Please don't turn the error off, or turn it into a warning.
Mocha relies on that error in its support of ESM: it first require-s the
module, and if it get ERR_REQUIRE_ESM, it switches to import.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#468?email_source=notifications&email_token=AAESFSTTPV2QPKPGMCDX5HLQ5WAJ7A5CNFSM4KGM5CL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI342AQ#issuecomment-574082306>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAESFSS3VQXOX55SHDACW3TQ5WAJ7ANCNFSM4KGM5CLQ>
.
|
Could we do the following:
It wouldn't break mocha's approach while not breaking improperly set up (but currently "working") projects on existing versions of node 12..? EDIT: Mostly asking so we have considered the option. Not sure myself if that complexity is good, especially given how many different cases our decision tree already has. |
No, because that would allow an ambiguous file that could be either parse goal to succeed in the wrong goal. |
I've just tested The issue only shows up when you explicitly set |
Removing agenda label. Was there anything actionable as a follow up to today's discussion? |
Nothing actionable, just for us to be aware of. |
@guybedford - even though closed (just saw this), note that I check if the extension is |
@giltayar thanks for the update here. I did test this again against We agreed in the meeting we were ok with these errors being backported for correctness. They may well bite some early adopters, but that is the risk of early adoption unfortunately. |
I am working on the Nuxt Js project and trying to import vuelayers module. Getting the below error screen. I know it is because of ES6 syntaxing and tried keeping "type:module" in package json. Still that does not and say's that require() of ES modules is not supported. Can you please help me in solving this |
@aditya369thalluri |
Adding |
For future reference: It looks like nuxtjs only supports ESM for modules from this PR description. It's not clear to me that general application code can use ESM. Not sure if there's a story on their side, looks like vue components don't really make a difference between require and import. |
What could be the solution to this? I am just trying to import a package and errors "cannot use import statement outside a module". It is not happening for all packages. It is only for this OpenLayers package. I am still able to import other packages. |
https://github.com/ghettovoice/vuelayers/ |
@aditya369thalluri It looks like vuelayers is taking putting pseudo modules into // Code generated from rollup --es but using .js so likely not intended to run as modules
"main": "./lib/index.js",
"module": "./lib/index.js",
// Code generated from rollup --umd, likely intended to run as a script or CommonJS
"unpkg": "./lib/index.umd.js", Looks like your nuxt setup is trying to load the P.S.: A way to phrase the vuelayers issue is "please support SSR using this code". Their approach of assuming that import sugar gets compiled away before running the code is perfectly valid if they only target bundlers. :) |
@MylesBorins did some amazing work this weekend and got the full modules implementation (minus the unflagging of
--experimental-modules
) fully backported to 12 staging (https://github.com/nodejs/node/tree/v12.x-staging). Opening this issue to discuss one of the backport details on the module agenda this week.Specifically - should we flag the
ERR_REQUIRE_ESM
errors that are thrown for.mjs
and scopes? These result in library bugs like the following respectively - standard-things/esm#855, eslint/eslint#12319. Alternatively should we turn these errors into warnings?The text was updated successfully, but these errors were encountered: