nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.75k stars 2.37k forks source link

It looks like all of --lib-name dependencies have not been built yet: #29038

Open soulxy opened 8 hours ago

soulxy commented 8 hours ago

Current Behavior

I have a monorepo that supports angular and react components.The relationship is as follows: We have released two packages, 'uisdk-ng' and 'uisdk-rc'. 'uisdk-ng' depends on 'data-loader' and 'view-loader-ng', while 'uisdk-rc' depends on 'data-loader' and 'view-loader-rc'.view-loader-ng and view-loader-rc are both ui components, and data-loader is a tool library. The key codes are as follows:

// uisdk-ng
export * from 'data-loader';
export * from 'view-loader-ng';
// uisdk-rc
export * from 'data-loader';
export * from 'view-loader-rc';
// tsconfig.json
"paths": {
     // build uisdk-ng success, uisdk-rc fail
      "@hw-dme/data-loader": ["dist/packages/data-loader"],
     // build uisdk-ng fail, uisdk-rc success
      "data-loader": ["packages/data-loader/src/index.ts"],
      "uisdk-ng": ["packages/uisdk-ng/src/index.ts"],
      "uisdk-rc": ["packages/uisdk-rc/src/index.ts"],
      "view-loader-ng": ["packages/view-loader-ng/src/index.ts"],
      "view-loader-rc": ["packages/view-loader-rc/src/index.ts"]
    }
// nx.json
"targetDefaults": {
    "e2e-ci--**/*": {
      "dependsOn": ["^build"]
    },
    "@nx/angular:ng-packagr-lite": {
      "cache": true,
      "dependsOn": ["^build"],
      "inputs": ["production", "^production"]
    },
    "@angular-devkit/build-angular:browser": {
      "cache": true,
      "dependsOn": ["^build"],
      "inputs": ["production", "^production"]
    },
    "@nx/vite:build": {
      "cache": true,
      "dependsOn": ["^build"],
      "inputs": ["production", "^production"]
    }
  },

Although the development mode can run, the sdk that only supports one framework can be compiled under the same configuration.

// package.json
"dependencies": {
    "@angular/animations": "18.2.0",
    "@angular/common": "18.2.0",
    "@angular/compiler": "18.2.0",
    "@angular/core": "18.2.0",
    "@angular/forms": "18.2.0",
    "@angular/platform-browser": "18.2.0",
    "@angular/platform-browser-dynamic": "18.2.0",
    "@angular/router": "18.2.0",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "rxjs": "~7.8.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~18.2.0",
    "@angular-devkit/core": "~18.2.0",
    "@angular-devkit/schematics": "~18.2.0",
    "@angular-eslint/eslint-plugin": "^18.3.0",
    "@angular-eslint/eslint-plugin-template": "^18.3.0",
    "@angular-eslint/template-parser": "^18.3.0",
    "@angular/cli": "~18.2.0",
    "@angular/compiler-cli": "~18.2.0",
    "@angular/language-service": "~18.2.0",
    "@babel/core": "^7.14.5",
    "@babel/preset-react": "^7.14.5",
    "@nx/angular": "^20.1.2",
    "@nx/devkit": "20.1.2",
    "@nx/eslint": "20.1.2",
    "@nx/eslint-plugin": "20.1.2",
    "@nx/jest": "20.1.2",
    "@nx/js": "20.1.2",
    "@nx/playwright": "20.1.2",
    "@nx/react": "20.1.2",
    "@nx/vite": "20.1.2",
    "@nx/web": "20.1.2",
    "@nx/workspace": "20.1.2",
    "@playwright/test": "^1.36.0",
    "@schematics/angular": "~18.2.0",
    "@swc-node/register": "~1.9.1",
    "@swc/cli": "~0.3.12",
    "@swc/core": "~1.5.7",
    "@swc/helpers": "~0.5.11",
    "@testing-library/react": "15.0.6",
    "@types/jest": "^29.5.12",
    "@types/node": "18.16.9",
    "@types/react": "18.3.1",
    "@types/react-dom": "18.3.0",
    "@typescript-eslint/eslint-plugin": "^7.16.0",
    "@typescript-eslint/parser": "^7.16.0",
    "@typescript-eslint/utils": "^7.16.0",
    "@vitejs/plugin-react": "^4.2.0",
    "@vitest/ui": "^1.3.1",
    "autoprefixer": "^10.4.0",
    "babel-jest": "^29.7.0",
    "eslint": "~8.57.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-import": "2.31.0",
    "eslint-plugin-jsx-a11y": "6.10.1",
    "eslint-plugin-playwright": "^1.6.2",
    "eslint-plugin-react": "7.35.0",
    "eslint-plugin-react-hooks": "5.0.0",
    "jest": "^29.7.0",
    "jest-environment-jsdom": "^29.7.0",
    "jest-environment-node": "^29.7.0",
    "jest-preset-angular": "~14.1.0",
    "jsdom": "~22.1.0",
    "jsonc-eslint-parser": "^2.1.0",
    "ng-packagr": "~18.2.0",
    "nx": "20.1.2",
    "postcss": "^8.4.5",
    "postcss-url": "~10.1.3",
    "prettier": "^2.6.2",
    "sass": "^1.55.0",
    "ts-jest": "^29.1.0",
    "ts-node": "10.9.1",
    "tslib": "^2.3.0",
    "typescript": "^5.5.2",
    "vite": "^5.0.0",
    "vite-plugin-dts": "~3.8.1",
    "vitest": "^1.3.1"
  }

Expected Behavior

Using the same paths configuration, different frameworks can be compiled.

GitHub Repo

No response

Steps to Reproduce

  1. uisdk-ng success, uisdk-rc fail

    "paths": {
      "data-loader": ["packages/data-loader/src/index.ts"],
      "uisdk-ng": ["packages/uisdk-ng/src/index.ts"],
      "uisdk-rc": ["packages/uisdk-rc/src/index.ts"],
      "view-loader-ng": ["packages/view-loader-ng/src/index.ts"],
      "view-loader-rc": ["packages/view-loader-rc/src/index.ts"]
    }

    error info: It looks like all of uisdk-ng's dependencies have not been built yet:

    • data-loader
  2. uisdk-ng fail, uisdk-rc success

    "paths": {
      "data-loader": ["dist/packages/data-loader"],
      "uisdk-ng": ["packages/uisdk-ng/src/index.ts"],
      "uisdk-rc": ["packages/uisdk-rc/src/index.ts"],
      "view-loader-ng": ["packages/view-loader-ng/src/index.ts"],
      "view-loader-rc": ["packages/view-loader-rc/src/index.ts"]
    }

    error info: x Build failed in 476ms error during build: src/app/app.tsx (4:9): "dataLoader" is not exported by "../../packages/uisdk-rc/src/index.ts", imported by "src/app/app.tsx".

Nx Report

Node           : 18.18.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 9.8.1

nx (global)        : 19.6.4
nx                 : 20.1.2
@nx/js             : 20.1.2
@nx/jest           : 20.1.2
@nx/eslint         : 20.1.2
@nx/workspace      : 20.1.2
@nx/angular        : 20.1.2
@nx/devkit         : 20.1.2
@nx/eslint-plugin  : 20.1.2
@nx/playwright     : 20.1.2
@nx/react          : 20.1.2
@nx/vite           : 20.1.2
@nx/web            : 20.1.2
@nx/webpack        : 20.1.2
typescript         : 5.5.2
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/playwright/plugin
@nx/jest/plugin

Failure Logs

Package Manager Version

No response

Operating System

Additional Information

No response

soulxy commented 7 hours ago

I know the key reason. data-loader is compiled by vite, which is not compatible with angular's compilation. If data-loader is compiled by tsc, it will succeed.