[go: nahoru, domu]

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

Support for importing ES modules #118

Open
aomarks opened this issue May 20, 2021 · 3 comments
Open

Support for importing ES modules #118

aomarks opened this issue May 20, 2021 · 3 comments

Comments

@aomarks
Copy link
aomarks commented May 20, 2021

Node now supports ES modules, but there doesn't seem to be a way to import them from a ttypescript config.

https://nodejs.org/api/esm.html

A CommonJS module can import an ES module like this:

const esModule = await import('some-es-module');

ttypescript could know to use import with a new plugin configuration option (e.g. "module": true).

Or to be more automatic, it could follow the Node rules which are to 1) check it ends with .mjs and if so import as a module, 2) check if it ends with .cjs and if so import as CommonJS, 3) otherwise check the package's package.json for "type": "module".

@robojeff
Copy link

I have a project that depends on TTypescript 1.5.13. I can build the project with ttsc when my project uses Typescript 4.3.5. However if I upgrade to Typescript 4.5.2, this error is thrown:

TypeError: Cannot read property 'impliedNodeFormat' of undefined

Does this enhancement address that issue, or I have encountered an unreported bug?

@cevek
Copy link
Owner
cevek commented Nov 30, 2021

Hello @robojeff. Do you have some repro?

@moshen
Copy link
moshen commented Jan 2, 2022

@robojeff You using ts-transform-paths? I found this bug report after trying to upgrade my own project: zerkalica/zerollup#37

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

No branches or pull requests

4 participants