You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No, and Node itself doesn't directly control any specific package manager, so it's not technically within their control.
Plus, yarn 1 and older versions of npm are still popular.
How does this affect the interpretation of .d.ts files?
These files use export and import, so it's ambiguous (still!)
To set ourselves up for success in the future, we will need to start encoding a marker in the .d.ts file (or start performing resolution to a .js file in addition to a .d.ts file)
Hold up, there is some ambiguity about whether or not code within node_modules is affected.
Yes, current intent is that within node_modules is still CJS unless otherwise declared.
Foot-guns around vendoring a package.
If you split things between JS/TS and loose files/configured"
TS/no config - does this scenario practically exist?
Maybe for people using ts-node and Bun and Deno - but our default language service will give you errors.
Per-file detection was something we were open to; however, this is different because it's dictated by the entry-point.
This is a fundamental problem for static analyzers trying to detect things on a non-configured best-effort manner. You need some configuration to make this work well in TypeScript.
Plus, what if two people do this? Showing errors that exist from one entry-point versus another is confusing.
There is a pressure to make ESM easier to work with in Node. It is annoying that CJS is the default. But adding new rules is going to add more confusion.
Feels like npm init and family should be changed, not add a new "forever" rule.
Going back to the declaration file disambiguator - what if we had a CJS-specific declaration syntax for export? We already have one for require.
We wish we'd done this years ago.
Isn't this incorrect? You detect the format from the surrounding context (package.json).
Well it tells you how the interop strategy will work - tells you if you need to write .default on something you imported.
The text was updated successfully, but these errors were encountered:
An alternative is that you could do import/export detection on every file
This is in nodejs/node#50064. Currently it seems the more promising of the two proposals; I think we’ll probably go with nodejs/node#50064 unless it proves to be nonviable for some reason.
Node Proposal
nodejs/node#50043
.js
file is CommonJS unless there's apackage.json
at the top level saying otherwise.import
orexport
in a CommonJS file, it's a hard crash.node_modules
andpackage.json
found at all, or no"type"
field andimport
s orexport
s andpackage.json
? Or also no"type": ...
field at all?import
a file withoutexport
s.import
/export
detection on every fileverbatimModuleSyntax
tsconfig.json
with something to opt out or something.await
makes the feature awkward, right?npm init
not a reasonable change for adding"type": "module"
.d.ts
files?export
andimport
, so it's ambiguous (still!).d.ts
file (or start performing resolution to a.js
file in addition to a.d.ts
file)node_modules
is affected.node_modules
is still CJS unless otherwise declared.ts-node
and Bun and Deno - but our default language service will give you errors.npm init
and family should be changed, not add a new "forever" rule.export
? We already have one forrequire
.package.json
)..default
on something you imported.The text was updated successfully, but these errors were encountered: