question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can no longer build publishable libraries that import other publishable libraries after migrate to v14

See original GitHub issue

Current Behavior

All Libraries are Angular. Running the build target on a publishable library that imports another publishable library fails with the following error message after I migrated our repo to NX 14.

packages/design-system/bottom-sheet/src/lib/bottom-sheet.component.ts:10:44 - error TS6059: File '/Users/zach.morgan/Development/Web.CO2/packages/design-system/cdk/overlay/src/index.ts' is not under 'rootDir' '/Users/zach.morgan/Development/Web.CO2/packages/design-system/bottom-sheet/src'. 'rootDir' is expected to contain all source files.
  The file is in the program because:
    Imported via '@snagajob/cdk/overlay' from file '/Users/zach.morgan/Development/Web.CO2/packages/design-system/bottom-sheet/src/lib/bottom-sheet.component.ts'
    Imported via '@snagajob/cdk/overlay' from file '/Users/zach.morgan/Development/Web.CO2/packages/design-system/bottom-sheet/src/lib/bottom-sheet.service.ts'
    Imported via "@snagajob/cdk/overlay" from file '/Users/zach.morgan/Development/Web.CO2/packages/design-system/bottom-sheet/src/lib/types/bottom-sheet-options.ts'
    Imported via "@snagajob/cdk/overlay" from file '/Users/zach.morgan/Development/Web.CO2/packages/design-system/bottom-sheet/src/lib/types/bottom-sheet-ref.ts'

10 import { SAJOverlayContentContainer } from '@snagajob/cdk/overlay';
                                              ~~~~~~~~~~~~~~~~~~~~~~~

  packages/design-system/bottom-sheet/src/lib/bottom-sheet.service.ts:3:35
    3 import { SAJOverlayService } from '@snagajob/cdk/overlay';
                                        ~~~~~~~~~~~~~~~~~~~~~~~
    File is included via import here.
  packages/design-system/bottom-sheet/src/lib/types/bottom-sheet-options.ts:1:35
    1 import { SAJOverlayOptions } from "@snagajob/cdk/overlay";
                                        ~~~~~~~~~~~~~~~~~~~~~~~
    File is included via import here.
  packages/design-system/bottom-sheet/src/lib/types/bottom-sheet-ref.ts:2:44
    2 import { SAJOverlayContentContainer } from "@snagajob/cdk/overlay";
                                                 ~~~~~~~~~~~~~~~~~~~~~~~
    File is included via import here.

We were having no issues building prior to the migration.

Expected Behavior

Previously it would make sure that any libraries it relied on were built and would build them if they weren’t. It would then successfully build.

Steps to Reproduce

  • Migrate from v13 to 14 (It put me at 14.3.5)
  • Create a publishable library (lib A) with a basic angular component
  • Create another publishable library (lib B) with another basic angular component
  • import component from lib B into lib A
  • attempt to build lib A

Failure Logs

You can see error message up above

Environment

 Node : 16.12.0
   OS   : darwin x64
   npm  : 8.1.0
   
   nx : 14.3.5
   @nrwl/angular : 14.3.5
   @nrwl/cypress : 14.3.5
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.3.5
   @nrwl/eslint-plugin-nx : 14.3.5
   @nrwl/express : Not Found
   @nrwl/jest : 14.3.5
   @nrwl/js : 14.3.5
   @nrwl/linter : 14.3.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.3.5
   @nrwl/web : Not Found
   @nrwl/workspace : 14.3.5
   typescript : 4.7.3
   ---------------------------------------
   Community plugins:
   	 @compodoc/compodoc: 1.1.18
   	 @storybook/angular: 6.5.9

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

19reactions
leosvelperezcommented, Jun 17, 2022

@sir-captainmorgan21 thanks for sharing!

There seems to have been an issue with a migration that was scheduled for a version but the migration itself was released in another version, so that might have caused the migration to not run in some scenarios. That migration should have added the following in nx.json for anyone having their nx.json extending from nx/presets/core.json or nx/presets/npm.json:

{
  ...
  "pluginsConfig": {
    "@nrwl/js": {
      "analyzeSourceFiles": true
    }
  }
}

Could you please add the above snippet to your nx.json and try again? If after applying the change it doesn’t pick it up immediately, run nx reset and then try again.

1reaction
sir-captainmorgan21commented, Jun 17, 2022

@leosvelperez that did! Thanks for looking at this so quickly. This will likely help a lot of folks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing a publishable library into another library Fails Angular
My First Library is build and there in dist folder and in my new library when i try and import i get various...
Read more >
Buildable and Publishable Libraries - Nx
One particularity when generating a library with --publishable is that it requires you to also provide an --importPath . Your import path is...
Read more >
nrwl-nx/community - Gitter
for some reason, I can't import from another library ... according to the help: Build applications and publishable libraries affected by changes so...
Read more >
Building an Angular Library with multiple entry points | Articles
No main entry point: You can move all modules, components and services into multiple subentry points and don't use the main entry point....
Read more >
Creating and Publishing Angular libraries with Nx - YouTube
Nx devTools allows us to create and publish angular libraries with ease, we will learn how you can create different types of libraries...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found