Skip to content

Support for importing ES modules #118

@aomarks

Description

@aomarks

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".

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions