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.

`UNRESOLVED_IMPORT` warning when importing libs from the same Nx workspace

See original GitHub issue

I have a Nx workspace with 1 app and 6 libs (4 of which were generated using @nxext/stencil):

  • MyApp
  • MainLib (stencil)
  • LibA (stencil)
  • LibB (stencil)
  • LibC (stencil)
  • Utils
  • Types

MainLib is dependent on LibA and LibB.

When building MainLib I get this error for both LibA and LibB:

Bundling Warning UNRESOLVED_IMPORT
'@bv0012/lib-a' is imported by
../../../libs/main-lib/src/theme/component-map.ts, but could
not be resolved – treating it as an external dependency

There are no inline errors in component-map.ts and my tsconfig.json paths property looks like this:

"paths": {
      "@bv0012/main-lib": ["libs/main-lib/src/components.d.ts"],
      "@bv0012/main-lib/*": ["libs/main-lib/src/*"],
      "@bv0012/main-lib/loader": ["dist/libs/main-lib/loader"],
      "@bv0012/main-lib/react": [
        "dist/libs/generated/main-lib/react/src/components.ts"
      ],
      "@bv0012/types": ["libs/types/src/index.d.ts"],
      "@bv0012/utils": ["libs/utils/src/index.ts"],
      "@bv0012/lib-a": ["dist/libs/lib-a"],
      "@bv0012/lib-b": ["dist/libs/lib-b"],
      "@bv0012/lib-c": ["dist/libs/lib-c"]
    }

I’m pointing the lib paths to dist/ because they’re publishable.

I feel like this is a node-resolve issue but I haven’t had any success debugging it so far.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
DominikPiepercommented, Aug 6, 2020

@luchsamapparat thanks for your help.

Sorry for the late response, I’m at holidays right now. I’ll take a look at soon as I can

1reaction
DominikPiepercommented, Aug 12, 2020

Okay, now I’m back and looked into this. I’ll do some experiments as well. The ugly/fastes solution could be using rollup again to bundle the libs. The @nrwl/web plugin does this, cause you can request the dependency tree und bundle up then. I’ll try some more with the stencil compiler but maybe that’s an workaround

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Pylint "unresolved import" error in Visual Studio Code
The accepted answer won't fix the error when importing own modules. Use the following setting in your workspace settings ...
Read more >
Applications and Libraries | Nx
A typical Nx workspace is structured into "apps" and "libs". This distinction allows us to have a more modular architecture by following a...
Read more >
nrwl-nx/community - Gitter
I generated a node lib, I setup a entry in my workspace.json which copies json files to dist/assets/locale, in the node lib I...
Read more >
no-restricted-imports - ESLint - Pluggable JavaScript Linter
Imports are an ES6/ES2015 standard for making the functionality of other modules available in your current module. In CommonJS this is implemented through ......
Read more >
Create Your First Custom Angular CLI Schematic with Nx - Auth0
Learn how to create applications, libraries, and custom workspace CLI Angular schematics with enterprise Angular tool Nx.
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