Skip to content

ts-node docs tweaks #6154

Open
Open
@cspotcode

Description

@cspotcode

Feature to document

I noticed that the recommendations for using ts-node to load webpack.config.ts can be simplified:
https://webpack.js.org/configuration/configuration-languages/

First, TS_NODE_PROJECT environment variable is supported natively by ts-node; no need to install tsconfig-paths

Second, the recommended configuration should be updated to recommend using moduleTypes instead of compilerOptions

https://typestrong.org/ts-node/docs/module-type-overrides

moduleTypes is better because it not only modifies the emitted code to be CommonJS, it also tells node to execute the files as CommonJS. This avoids node errors about attempting to require() ESM modules.

Note that I've also merged support for CJS and CTS file extensions, to be published in our next release in a week or two. So if webpack supports webpack.config.cts, then that is an even simpler option. With a webpack.config.cts, moduleTypes is not necessary unless the config tries to import other files that are ESM TS.

Author(s)

Additional information

[x] I am willing to work on this issue and submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions