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

@nx/esbuild:esbuild declarationRootDir not working properly when output path matches workspace #28814

Open
1 of 4 tasks
Dabmuel opened this issue Nov 6, 2024 · 0 comments
Open
1 of 4 tasks

Comments

@Dabmuel
Copy link

Dabmuel commented Nov 6, 2024

Current Behavior

There was a issue with type declaration files when building a package with @nx/esbuild:esbuild. Declaration were placed at the wrong folder ( @nx/esbuild:esbuild with "declaration": true always executes from $PWD ). This could be fixed by adding option declarationRootRir.
Recently this got fixed with this PR : [fix(esbuild): declaration:true should find the correct package root regardless of cwd](#27560) but the fix breaks the declarationRootRir option if the output path contains the absolute path of the workspace. I kinda need this option :/

Expected Behavior

Writing the type declaration files at the correct folder even if declarationRootRir is set and the output path of the declaration contains the absolute path of the workspace.

GitHub Repo

No response

Steps to Reproduce

{
"name": "angular-administration-api",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/client-sdk/angular/administration-api/src",
"projectType": "library",
"tags": ["tech:angular"],
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"main": "libs/client-sdk/angular/package-api/src/index.ts",
"outputPath": "dist/libs/client-sdk/angular/package-api",
"outputFileName": "main.js",
"declarationRootDir": "libs/client-sdk/angular/package-api/src",
"tsConfig": "libs/client-sdk/angular/package-api/tsconfig.lib.json",
"assets": [
{
"input": "libs/client-sdk/angular/package-api",
"glob": "README.md",
"output": "/"
}
],
"platform": "node"
},
"configurations": {
"development": {
"minify": false
},
"production": {
"minify": true
}
}
}
}
}
The code of the package is located in folder libs/client-sdk/angular/package-api/src
and I need them in folder dist/libs/client-sdk/angular/package-api after build.

With this nx project, the build creates declaration files to folder dist/
and without specifing the declarationRootDir to folder dist/libs/client-sdk/angular/package-api/src

If i change the output path (dist/libs/client-sdk/angular/package-api) to not match the workspace (libs/client-sdk/angular/package-api) by changing the name of a folder (dist/libs/client-sdk-test/angular/package-api), it works fine.

Nx Report

Node : 20.16.0
OS : win32-x64
Native Target : x86_64-windows
npm : 10.8.1

nx : 19.7.2
@nx/js : 19.7.2
@nx/jest : 19.7.2
@nx/linter : 19.7.2
@nx/eslint : 19.7.2
@nx/workspace : 19.7.2
@nx/angular : 19.7.2
@nx/cypress : 19.7.2
@nx/devkit : 19.7.2
@nx/esbuild : 19.7.2
@nx/eslint-plugin : 19.7.2
@nx/nest : 19.7.2
@nx/node : 19.7.2
@nrwl/tao : 19.7.2
@nx/web : 19.7.2
@nx/webpack : 19.7.2
typescript : 5.5.4

Community plugins:
devextreme-angular : 24.1.5
ngx-bootstrap : 18.0.2
ngx-toastr : 19.0.0

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@Dabmuel Dabmuel changed the title @nx/esbuild:esbuild declarationRootDir not working properly when it contains @nx/esbuild:esbuild declarationRootDir not working properly Nov 6, 2024
@Dabmuel Dabmuel changed the title @nx/esbuild:esbuild declarationRootDir not working properly @nx/esbuild:esbuild declarationRootDir not working properly when output path matches workspace Nov 6, 2024
@FrozenPandaz FrozenPandaz assigned AgentEnder and Coly010 and unassigned AgentEnder Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants