Closed
Description
I basically detailed the issue in this comment: #155 (comment)
It's a chicken-and-egg-like problem:
- If we use
module: 'commonjs'
, then if any TS files import ES Modules (indirectly in their dependency graph), then Node throws an error because CommonJS modules can not import ES Modules. - If we change to
module: 'esnext'
, then the errors from the previous point go away, but now the.js
file that is loadingts-node
and calling something likerequire('typescript-entry-point.ts')
will have a similar issue, because the call torequire('typescript-entry-point.ts')
will try to load an ES Module. - Finally, if we convert the
.js
file into an ES Module, we can not convertrequire('typescript-entry-point.ts')
intoimport 'typescript-entry-point.ts'
because now ES Modules don't handle.ts
extensions (at least not out of the box, and it seems the old require hooks don't operate on these new identifiers)
At the moment, I'm sort of stuck, because I have dependencies in my dependency tree that are ES Modules.
The only workaround I can think of is to compile everything to .js
files (ES Modules) and avoid to use ts-node.
I wonder if a combination of allowJs
and ignore
so that it compiles JS files would help. I haven't tried that yet.
Metadata
Metadata
Assignees
Labels
No labels