unjs / unbuild

📦 A unified JavaScript build system
MIT License
2.23k stars 86 forks source link

Decorators support #309

Open huseeiin opened 10 months ago

huseeiin commented 10 months ago

Describe the feature

ERROR: Transforming JavaScript decorators to the configured target environment ("es2020") is not supported yet

tsconfig.json:

{
    "compilerOptions": {
        "lib": ["ESNext", "DOM"],
        "target": "ESNext",
        "module": "ESNext",
        "strict": true,
        "exactOptionalPropertyTypes": true,
        "noUncheckedIndexedAccess": true,
        "esModuleInterop": true,
        "moduleResolution": "node",
        "noEmit": true,
        "skipLibCheck": true,
        "experimentalDecorators": true,
        "strictPropertyInitialization": false,
        "emitDecoratorMetadata": true
    }
}

Additional information

colmugx commented 10 months ago

same..

sadeghbarati commented 10 months ago

Hi, I don't know it's related but have you guys add tslib to dependencies? what is your typescript version?

colmugx commented 10 months ago

but it works in 1.2.1

OSpoon commented 10 months ago

I also tried to build the module that used decoration and got the same error as above

hengshanMWC commented 9 months ago

The same mistake, do you want to use babel to transfer the insurance first

zhangjiluo-com commented 7 months ago

same mistake

zsilbi commented 5 months ago

Workaround:

Create a build.config.ts with the following:

import { defineBuildConfig } from 'unbuild';

export default defineBuildConfig({
  rollup: {
    esbuild: {
      tsconfigRaw: {
        compilerOptions: {
          experimentalDecorators: true,
        },
      },
    },
  },
});

or add the following section to the package.json:

"unbuild": {
  "rollup": {
    "esbuild": {
      "tsconfigRaw": {
        "compilerOptions": {
          "experimentalDecorators": true
        }
      }
    }
  }
}