nrwl / nx

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

@nrwl/webpack with swc doesn't work with reflect-metadata/emitDecoratorMetadata #12845

Closed Bielik20 closed 2 months ago

Bielik20 commented 1 year ago

main.ts

import { Injectable } from '@wikia/dependency-injection';
import { DepClass } from './dep';

@Injectable()
export class MainClass {
  constructor(public dep: DepClass) {}
}

dep.ts

import { Injectable } from '@wikia/dependency-injection';

@Injectable()
export class DepClass {
  foo() {
    return 'foo';
  }
}

Current Behavior

✅ Running @nrwl/webpack:webpack with "compiler": "tsc" includes DepClass in bundle.

❌ Running @nrwl/webpack:webpack with "compiler": "swc" excludes DepClass from bundle.

Expected Behavior

DepClass should be included in bundle.

According to https://github.com/swc-project/swc/pull/3459 this should be fixed on the side of swc already.

Steps to Reproduce

PR example: https://github.com/nrwl/nx-examples/pull/240

Run

Environment

   Node : 16.17.0
   OS   : darwin arm64
   yarn : 1.22.19

   nx : 15.0.0
   @nrwl/angular : 15.0.0
   @nrwl/cypress : 15.0.0
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.0.0
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.0.0
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.0.0
   @nrwl/js : 15.0.0
   @nrwl/linter : 15.0.0
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 15.0.0
   @nrwl/nx-cloud : 14.7.0
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.0.0
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.0.0
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.0.0
   @nrwl/web : 15.0.0
   @nrwl/webpack : 15.0.0
   @nrwl/workspace : 15.0.0
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
     @ngrx/component-store: 14.0.2
     @ngrx/effects: 14.0.2
     @ngrx/entity: 14.0.2
     @ngrx/router-store: 14.0.2
     @ngrx/store: 14.0.2
     @ngrx/store-devtools: 14.0.2

Related issues

MarcieMarc425 commented 1 year ago

I wonder if this is related to #12782?

Bielik20 commented 1 year ago

@MarcieMarc425 Hmm, I don't think so. With optimization: false it still does NOT include DepClass

github-actions[bot] commented 1 year ago

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! 🙏

Bielik20 commented 1 year ago

Still an issue, I have checked with recent version. Interestingly enough @nrwl/rspack works fine with SWC.

kodeine commented 1 year ago

i am facing the same issue, can someone guide?

github-actions[bot] commented 7 months ago

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! 🙏

Bielik20 commented 7 months ago

Haven't checked for the long time but I don't think it is resolved.

jaysoo commented 2 months ago

Checked it on latest and it is resolved. See the demo here: https://github.com/jaysoo/issue12845

github-actions[bot] commented 1 month ago

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.