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

node presets: consider adding allowSyntheticDefaultImports: false? #251

Open
domdomegg opened this issue Feb 5, 2024 · 2 comments
Open

Comments

@domdomegg
Copy link

My understanding of allowSyntheticDefaultImports is that it assumes you have an extra build step that converts imports of the form import React from "react"; to import * as React from "react"; (so you can write the former in place of the latter).

However, by default Node does not do this natively. This can cause runtime errors when importing packages that haven't reexported everything as a default.

Also see:

I'm not fully confident about this - would be keen for others to weigh in whether this assessment is accurate.

@zanminkian
Copy link
Contributor

microsoft/TypeScript#54500 (comment)

TS core team will deprecate this flag later. This flag should set to true. So this issue can be closed I think 🤔️

@alexanderchr
Copy link

Node does add default exports when consuming commonjs modules from es modules, see

https://nodejs.org/api/esm.html#commonjs-namespaces

To support this, when importing CommonJS from an ECMAScript module, a namespace wrapper for the CommonJS module is constructed, which always provides a default export key pointing to the CommonJS module.exports value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants