You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating a publishable library using the @nx/js generator with the Rollup bundler, the nx build command produces a type declaration file (index.cjs.d.ts) that is not consistent with the types field in the generated package.json.
Specifically:
The Rollup config generates index.cjs.d.ts in the dist directory.
The types field in package.json is set to ./dist/index.d.ts.
Similarly, the exports section refers to ./dist/index.d.ts for the types key
The generated file names and package.json configuration should align. The following adjustment(s) could resolve the issue:
The Rollup bundler should produce a type declaration file named index.d.ts (instead of index.cjs.d.ts).
GitHub Repo
No response
Steps to Reproduce
Create a publishable library with Rollup bundler: npx nx g @nx/js:library packages/example-types --bundler=rollup --publishable --importPath=@myorg/example
Build the library: npx nx build example-types
Inspect the output directory and package.json:
Output includes index.cjs.d.ts in the dist folder.
package.json has a types field pointing to ./dist/index.d.ts and an exports entry for types pointing to the same file.
Attempt to use the package in an external project:
Install the package and observe that TypeScript cannot resolve the type declarations.
…le extensions for type definitions.
Updated the Rollup plugin's logic for generating type definition files to ensure compatibility with
additional file extensions, including .cjs.js and .mjs.js.
This change improves the handling of entry points and ensures that corresponding .d.ts files are
correctly named and emitted in all supported scenarios.
Added a comprehensive test case to validate the new behavior.
closednrwl#29308
…le extensions for type definitions.
Updated the Rollup plugin's logic for generating type definition files to ensure compatibility with
additional file extensions, including .cjs.js and .mjs.js.
This change improves the handling of entry points and ensures that corresponding .d.ts files are
correctly named and emitted in all supported scenarios.
Added a comprehensive test case to validate the new behavior.
closednrwl#29308
Current Behavior
When generating a publishable library using the @nx/js generator with the Rollup bundler, the nx build command produces a type declaration file (index.cjs.d.ts) that is not consistent with the types field in the generated package.json.
Specifically:
As a result, when the package is consumed outside the workspace, TypeScript fails to locate the type declarations.
Error example:
Expected Behavior
The generated file names and package.json configuration should align. The following adjustment(s) could resolve the issue:
GitHub Repo
No response
Steps to Reproduce
npx nx g @nx/js:library packages/example-types --bundler=rollup --publishable --importPath=@myorg/example
npx nx build example-types
resulting
dist
directory:generated package.json:
Nx Report
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: