The node16
module resolution for TypeScript adds native support for Node's ESM. In codebases with ESM libraries shared between Node and the frontend, this is the recommended module resolution for native ESM.
Unfortunately, setting the node16
module resolution currently breaks create-react-app
. The reason is that imports need an explicit extension, and TypeScript requires to use the output module for resolution; even for bundlers. So foo.ts
must be imported as foo.js
.
To support this use case, Webpack 5.74.0 introduced the extensionAlias
option. This commit updates the Webpack config used by react-scripts
to use this new option and fix support for node16
module resolution in TypeScript.
Closes #12625