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
  • Merge requests
  • !12982

fix: Support Typescript module resolution `node16` (#12625)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Charles Samborski requested to merge github/fork/demurgos/fix/12625-ts-node16 into main Jan 21, 2023
  • Overview 2
  • Commits 1
  • Pipelines 1
  • Changes 3

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

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/demurgos/fix/12625-ts-node16