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
  • #6289
Closed
Open
Issue created Jan 27, 2019 by Administrator@rootContributor

Webpack 4.x bug compiling libraries with both .js and .mjs

Created by: trxcllnt

Webpack 4.x has a bug that causes it to throw ReferenceError: require is not defined at runtime when compiling projects with .js and .mjs side-by-side:

screenshot from 2019-01-27 14-46-46

This bug has been fixed in Webpack 5, and Webpack 4 has this workaround:

{
	test: /\.mjs$/,
	type: "javascript/auto",
}

From what I can tell, this was briefly how CRA handled .mjs, but was reverted a few days later via #5258.

Assuming no objections from @Timer, can CRA revert back to back to the javascript/auto configuration for Webpack 4? We can revert again once CRA is updated to Webpack 5.

Steps to Reproduce

Repro repo: https://github.com/trxcllnt/arrow-viewer/tree/cra-mjs-bug

  1. git clone -b cra-mjs-bug https://github.com/trxcllnt/arrow-viewer.git
  2. yarn && yarn start

Environment

  System:
    OS: Linux 4.18 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  Binaries:
    Node: 11.6.0 - ~/.nvm/versions/node/v11.6.0/bin/node
    Yarn: 1.13.0 - /usr/bin/yarn
    npm: 6.5.0 - ~/.nvm/versions/node/v11.6.0/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Firefox: 64.0
  npmPackages:
    react: next => 16.8.0-alpha.1 
    react-dom: next => 16.8.0-alpha.1 
    react-scripts: next => 2.1.3-next.6a95aae9 
  npmGlobalPackages:
    create-react-app: Not Found
Assignee
Assign to
Time tracking