Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #12625
Closed
Open
Issue created Aug 01, 2022 by Charles Samborski@demurgos

Support TypeScript module resolution `node16`

Describe the bug

Setting moduleResolution to node16 in tsconfig.json is not supported.

(Write your answer here.)

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

N/A

Environment

Environment Info:

  current version of create-react-app: 5.0.1
  running from /home/demurgos/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: Linux 5.18 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 18.7.0 - /usr/bin/node
    Yarn: 3.2.2 - /usr/bin/yarn
    npm: 8.15.1 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: 103.0
  npmPackages:
    react: Not Found
    react-dom: Not Found
    react-scripts: Not Found
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. Initialize a project
  2. Set moduleResolution to node16 in the TypeScript compiler options
  3. Run the build script

Expected behavior

The project compiles

Actual behavior

  • node16 requires explicit .js extensions.
  • when using .js extensions, webpack does not find the target file

Reproducible demo

N/A

How to fix this

Webpack 5.74.0 added support for extension aliases. It allows to write .js in the imports and resolve the .ts file.

The webpack config should update its resolve field:

{
  resolve: {
    extensionAlias: {
      ".js": [".ts", ".js"],
      ".cjs": [".cts", ".cjs"],
      ".mjs": [".mts", ".mjs"],
    }
    // ...
  }
  // ...
}
Assignee
Assign to
Time tracking