Nx: core-js version conflicts when mixing @nrwl/angular and @nrwl/react into the same workspace

Created on 21 Nov 2019  路  3Comments  路  Source: nrwl/nx

_Please make sure you have read the submission guidelines before posting an issue_

Prerequisites

Please answer the following questions for yourself before submitting an issue.
YOU MAY DELETE THE PREREQUISITES SECTION.

  • [x] I am running the latest version: "@nrwl/workspace": "8.8.0",
  • [x] I checked the documentation and found no answer
  • [x] I checked to make sure that this issue has not already been filed
  • [x] I'm reporting the issue to the correct repository (not related to Angular, AngularCLI or any dependency)

Expected Behavior

Nx can work in a monorepo with both @nrwl/angular and @nrwl/react.
Hopefully this is a valid use case for Nx.

Current Behavior

Adding a react app into an existing workspace (there's already an angular app), the react app cannot be started

What is the current behavior?

As above.

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. create workspace:
    yarn create nx-workspace --preset=empty myworkspace

  2. generate an angular app first:
    yarn add --dev @nrwl/angular && yarn ng g @nrwl/angular:app myapp1
    this app can be started when running yarn start

  3. generate another react app:
    yarn add -D @nrwl/react && yarn nx g @nrwl/react:app myapp2
    this react app cannot be started when running yarn start myapp2, there were a lot of errors about core-js thrown in polyfills.ts:

ERROR in ./polyfills.ts
Module not found: Error: Can't resolve 'core-js/modules/es.array-buffer.constructor'

checked that it's actually from:

import 'core-js/stable'; // this is actually since v3 only

and the version for core-js in package.json: "core-js": "^2.5.4",

Context

Please provide any relevant information about your setup:

  • version of Nx used (_Please run nx report at the root of your workspace and copy the results here if you are using Nx 8.6.1 or greater_) 8.8.0
  • 3rd-party libraries and their versions
  • and most importantly - a use-case that fails

Failure Logs

As above

Other

Any other relevant information that will help us help you.

bug

All 3 comments

In my case, there's a quick workaround though:
because core-js is mainly used in polyfills.ts in angular app (still an empty app), which did not import yet any modules, I can simply change the core-js version in package.json to v3+

Thank you for your report, it is something that is on our radar and will be fixed soon :)

@royling This will be patched in the upcoming release. And yes, you can force core-js to be version 3 in your package.json for now. With the patch it wouldn't matter which core-js version your workspace has, we'll always point to the one needed by web builder.

Was this page helpful?
0 / 5 - 0 ratings