-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[5.5 beta] package.json "type"
lookup in non-Node.js module
is unexpected
#58663
Comments
moduleDetection
option is ignoredmoduleDetection
option is ignored for verbatimModuleSyntax
error
That option doesn't control anything to do with ESM versus CJS, it's controlling "module" (uses some form of exports, declarations are local) versus "script" (all globals, like a script tag). |
This sounds similar (but not the same) as the 5.5 issue we hit of The root cause seems to be the intentional decision to respect In our case we have a build system that up to now intentionally ignored |
I am using TypeScript only for type checking, and I'm using Babel to do all transpilation. My build system will transpile those files either to ESM or to CJS and put them in appropriate folders with their own These restriction seem to be only necessary when TypeScript is emitting JS files, and even in that case they should be based on the In the new TS5.5 behavior, how would I have to update my tsconfig to keep being able to have the following, when not emitting JS files through tsc?
What I find surprising about this new behavior is that my EDIT: It seems I can just disable EDIT2: That doesn't work because then TS errors on |
I guess what I would like to have is an option to tell TS "I know what I'm doing about modules syntax, please don't error when you think you won't be able to emit it correctly", or an option to restore the previous behavior. |
IIRC this was actually tried. I donβt remember the exact reasoning but it turned out to not really be viable. See discussion at #54593 and other issues linked therein. |
Some more context here: #58587 (comment). |
Why are folks using an explicit |
Just because Does TS handle those two cases differently? |
It does now outside of
See #54546 |
moduleDetection
option is ignored for verbatimModuleSyntax
error"type"
lookup in non-Node.js module
is unexpected
@nicolo-ribaudo @acutmore could you try the build at #58825 and see if that addresses your issues? I think it should, but getting some definite feedback on real projects would be great since weβre so close to the final 5.5 release here. |
π Search Terms
moduleDetection force legacy
π Version & Regression Information
β― Playground Link
No response
π» Code
package.json:
tsconfig.json:
src/index.ts:
π Actual behavior
π Expected behavior
Given that I'm using
"moduleDetection": "force"
, that file is an ES module (regardless of whatpackage.json#type
says) and thus I shouldn't see that error. This was the behavior in 5.4.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: