Nx: React: Buildable library that imports another buildable library fails to build (rootDir)

Created on 29 Oct 2020  路  4Comments  路  Source: nrwl/nx

Current Behavior

Buildable library foo fails to build when it imports buildable library bar.

Expected Behavior

Per the incremental builds page, importing a buildable library into another buildable library should result in a successful build.

Steps to Reproduce

Repro repo: https://github.com/mikechabot/lib-foo-depends-on-lib-bar

  1. npx create-nx-workspace my-test-org
  2. npm install --save-dev @nrwl/react
  3. nx generate @nrwl/react:library --name=foo --buildable --pascalCaseFiles
  4. nx generate @nrwl/react:library --name=bar --buildable --pascalCaseFiles
  5. Open libs/foo/src/lib/Foo.tsx
  6. Import <Bar /> from "@my-test-org/bar".
  7. nx build foo --withDeps --skip-nx-cache
  8. nx run build:bar -> Success
  9. nx run build:foo -> Fail

Can you reproduce this on https://github.com/nrwl/nx-examples?

Although there are no buildable libs in the nx-examples example repo, I created some buildable libs, and submitted the PR here: https://github.com/nrwl/nx-examples/pull/120

Failure Logs

It's the rootDir issue, which appears to be a common/recurring problem. It appears this issue has not been addressed for React.

> nx run foo:build
Bundling...
Error during bundle: Error: C:/_workspaces/my-test-org/libs/foo/src/lib/Foo.tsx(4,19): semantic error TS6059: File 'C:/_workspaces/my-test-org/libs/bar/src/index.ts' is not under 'rootDir' 'C:/_workspaces/my-test-org/libs/foo/src'. 'rootDir' is expected to contain all source files.
Bundle failed.

Environment

 NX  Report complete - copy this into the issue template

  nx : Not Found
  @nrwl/angular : Not Found
  @nrwl/cli : 10.3.1
  @nrwl/cypress : 10.3.1
  @nrwl/eslint-plugin-nx : 10.3.1
  @nrwl/express : Not Found
  @nrwl/jest : 10.3.1
  @nrwl/linter : 10.3.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : 10.3.1
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.3.1
  @nrwl/web : 10.3.1
  @nrwl/workspace : 10.3.1
  typescript : 4.0.5
react bug

All 4 comments

@FrozenPandaz Hey there, just checking in for any possible updates; I'd pushing for my org to adopt this tech stack, but unfortunately this is a blocker. Let me know if there's anyway I can help diagnose the issue.

Just linking this here, to have these connected #3518

Hi there @mikechabot ! Thanks for filing this bug. We are looking into it! :)

@mikechabot I'm working on a fix for this. So to unblock you in the meantime. Change the name prop of the package.json of the buildable libs to their actual TS path, like

  • bar => @my-test-org/bar
  • foo => @my-test-org/foo

that should make it work. Sorry for the inconvenience. I'll try to release a fix for this asap

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IonFoXx picture IonFoXx  路  3Comments

joelmuskwe picture joelmuskwe  路  3Comments

danieldanielecki picture danieldanielecki  路  3Comments

SWGeekPD picture SWGeekPD  路  3Comments

zpydee picture zpydee  路  3Comments