nx: web:rollup executor doesn't produce declarations with compiler set to swc

Current Behavior

When running nx build for my buildable library I don’t get d.ts files in the output directory.

Expected Behavior

d.ts files should be generated.

Steps to Reproduce

  1. Generate a buildable library with --compiler swc
  2. Build it

Environment

Node : 16.10.0
   OS   : darwin arm64
   yarn : 1.22.17

   nx : 13.8.3
   @nrwl/angular : undefined
   @nrwl/cli : 13.8.3
   @nrwl/cypress : 13.8.3
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.3
   @nrwl/eslint-plugin-nx : 13.8.3
   @nrwl/express : undefined
   @nrwl/jest : 13.8.3
   @nrwl/js : 13.8.3
   @nrwl/linter : 13.8.3
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : undefined
   @nrwl/nx-cloud : undefined
   @nrwl/react : 13.8.3
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.3
   @nrwl/tao : 13.8.3
   @nrwl/web : 13.8.3
   @nrwl/workspace : 13.8.3
   typescript : 4.4.4
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 16
  • Comments: 52 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Still relevant.

I’m having the same issue too. And from what I can see in the swc thread

https://github.com/swc-project/swc/issues/657

It seems like a missing feature so I thought the missed types in NX are expected.

Not a big issue for compiling and bundling apps, but for libs that mean to be published to NPM, this is an essential feature.

Based on the comment by @Chanki-Min, I’ve created a custom version of the rollup executor that includes the missing useSwc check:

Just add these 4 files into a folder in your mono-repo, e.g. ./executors/rollup: https://gist.github.com/ShayDavidson/e89751a5bc57a17ca6846dfd68aabf45

And then in the project.json, reference it like this:

"build": {
      "executor": "./executors/rollup:rollup",
	 ...
}

It does generate the type declarations, but I’m not sure if there are other bad side-effects of this (will update this comment if I find any).

Still relevant

Still relevant

Does anyone know what and where something needs to be addressed? Is it a swc issue?