Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not build buildable libs with rollup correctly #18946

Closed
2 of 4 tasks
rluvaton opened this issue Aug 31, 2023 · 11 comments
Closed
2 of 4 tasks

Does not build buildable libs with rollup correctly #18946

rluvaton opened this issue Aug 31, 2023 · 11 comments
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: bundlers Issues related to webpack, rollup stale type: bug

Comments

@rluvaton
Copy link
Contributor

rluvaton commented Aug 31, 2023

Current Behavior

When I run nx run lib2:build I get the following error:

> nx run lib2:build

Bundling lib2...
Error during bundle: Error: libs/lib2/src/lib/lib2.tsx:1:22 - error TS2307: Cannot find module '@test/lib1' or its corresponding type declarations.

1 import { Lib1 } from '@test/lib1';

Expected Behavior

to not have errors at all

GitHub Repo

Repro

Steps to Reproduce

nx run nx run lib2:build

Nx Report

nx report
>  NX  Falling back to ts-node for local typescript execution. This may be a little slower.
  - To fix this, ensure @swc-node/register and @swc/core have been installed

 >  NX   Report complete - copy this into the issue template

   Node   : 16.18.1
   OS     : darwin-arm64
   npm    : 8.19.2

   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nx/react          : 16.7.4
   @nx/rollup         : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/vite           : 16.7.4
   @nx/web            : 16.7.4
   typescript         : 5.1.6

Failure Logs

❯ nx run lib2:build --verbose --skip-nx-cache

 >  NX   Running target build for project lib2 and 1 task it depends on:

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

> nx run lib1:build

Bundling lib1...
  index.esm.js 234 Bytes
⚡ Done in 1.04s

> nx run lib2:build

Bundling lib2...
Error during bundle: Error: libs/lib2/src/lib/lib2.tsx:1:22 - error TS2307: Cannot find module '@test/lib1' or its corresponding type declarations.

1 import { Lib1 } from '@test/lib1';
                       ~~~~~~~~~~~~

Bundle failed: lib2

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Running target build for project lib2 and 1 task it depends on failed

   Failed tasks:

   - lib2:build

   Hint: run the command with --verbose for more details.

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

if you look at the dist folder, the lib1 package json shows this:

{
  "name": "@test/lib1",
  "version": "0.0.1",
  "main": "./index.js",
  "types": "./index.d.ts",
  "exports": {
    ".": {
      "import": "./index.mjs",
      "require": "./index.js"
    }
  },
  "module": "./index.esm.js",
  "type": "module"
}

while the folder content is this (main and types does not point to the right file):

❯ ls dist/libs/lib1
README.md        index.esm.css    index.esm.d.ts   index.esm.js     package.json     src              vite.config.d.ts
@FrozenPandaz FrozenPandaz added the scope: bundlers Issues related to webpack, rollup label Aug 31, 2023
@KamalAman
Copy link

It seems like all of these issues reported are probably released to this:

#16821
#17019
#18349

@KamalAman
Copy link

Switching await from @nx/rollup to vite seems to be a workaround, and probably for the better.

@steve-lorenz
Copy link

@KamalAman I was experiencing similar issues, using vite for @nx/react seemed to work, but I was also trying to do the same for @nx/react-native that seems to use @nx/rollup would this be a web only workaround?

@KamalAman
Copy link

I guess so, hopefully nx starts prioritizing this issue.

I have no idea why they switched the updateBuildableProjectDepsInPackageJson flag for that eslint rule. I think these issues are all related to that switch.

@mandarini
Copy link
Member

mandarini commented Oct 25, 2023

@rluvaton and anyone else, is it possible that your build target names (of two interdependent libs) are different? This bug can appear if you are importing one buildable lib into the other, and the build target names are different. I am not saying that's the issue you are facing, I'm just saying that this issue can appear under this circumstance.

related: #11289

For anyone having that error, solution: #17798 (comment)

@rluvaton
Copy link
Contributor Author

rluvaton commented Nov 14, 2023

Checked and it's not the case, you can see in the reproduction

@rluvaton
Copy link
Contributor Author

rluvaton commented Nov 14, 2023

So I checked it and I found that this problem happened when moving @nx/rollup from 16.5.5 to 16.6.0

Found the bad commit: 661efa9

@steve-lorenz
Copy link

Just wanted to update this thread, I migrated and upgraded to v17.1.3 and this works for me now. @rluvaton not sure if that's an option for you or not, but just wanted to ping the thread as this might be fixed now

@mandarini mandarini added the blocked: retry with latest Retry with latest release or head. label Dec 5, 2023
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@rluvaton
Copy link
Contributor Author

The issue still happening on the latest version

Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: bundlers Issues related to webpack, rollup stale type: bug
Projects
None yet
Development

No branches or pull requests

5 participants