Skip to content

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

@Bielik20

Description

@Bielik20

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 swc-project/swc#3459 this should be fixed on the side of swc already.

Steps to Reproduce

PR example: nrwl/nx-examples#240

Run

  • yarn nx run di:build:tsc - ✅ DepClass is included.
  • yarn nx run di:build:swc - ❌ DepClass is NOT included.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions