facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.73k stars 26.85k forks source link

Dynamic imports not working when acorn has resolutions #10521

Open ochmanski opened 3 years ago

ochmanski commented 3 years ago

Describe the bug

Dynamic imports are not working with any version of acorn specified in resolutions field in package.json.

Did you try recovering your dependencies?

Yes, my yarn version is 1.22.5.

Which terms did you search for in User Guide?

I think every possible one.

Environment

Environment Info:

  current version of create-react-app: 4.0.2
  running from /Users/ochdev/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: macOS 11.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 15.8.0 - ~/.nvm/versions/node/v15.8.0/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 7.5.1 - ~/.nvm/versions/node/v15.8.0/bin/npm
  Browsers:
    Chrome: 88.0.4324.146
    Edge: Not Found
    Firefox: 84.0
    Safari: 14.0.2
  npmPackages:
    react: ^17.0.1 => 17.0.1
    react-dom: ^17.0.1 => 17.0.1
    react-scripts: 4.0.2 => 4.0.2
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. Create new project with create-react-app
  2. Add any version of acorn to resolutions field in package.json
  3. Install deps yarn or npm i
  4. Add any dynamic import to the project
  5. Start project yarn start or npm run start
  6. Go to localhost:3000 and see crashed app

Expected behavior

Dynamic imports should work as expected.

Actual behavior

Screenshot 2021-02-08 at 09 16 31

Reproducible demo

https://github.com/ochmanski/cra-dynamic-import-acorn-res

Instructions are the same as cloning every new CRA project.

$ git clone git@github.com:ochmanski/cra-dynamic-import-acorn-res.git
$ yarn
$ yarn start
$ git clone git@github.com:ochmanski/cra-dynamic-import-acorn-res.git
$ npm i
$ npm run start
gramalinbechtel commented 2 years ago

Any progress on this issue and i can replicate the same.