Skip to content

decorators not support in js for prebuild #2349

@soulcm

Description

@soulcm

⚠️ IMPORTANT ⚠️ Please do not ignore this template. If you do, your issue will be closed immediately.

Describe the bug

运行 dev时,因为有预购建,导致esbuild无法识别js中的decorators,报如下错误
image

Reproduction

code 如下

// test.js
function sealed() {
  console.log('sealed');
}

@sealed
class Greeter {
  greeting;
  constructor(message) {
    this.greeting = message;
  }
  greet() {
    return "Hello, " + this.greeting;
  }
}

export default Greeter;

// main.tsx
import App from './App'
import Gretter from './test';

console.log(new Gretter())
  1. yarn dev

image

PS. yarn build时,加入了babel插件且无预购建步骤,因此不会报错

System Info

  • vite version: 2.0.3
  • Operating System: mac os
  • Node version: v12.14.1
  • Package manager (npm/yarn/pnpm) and version: yarn

Logs (Optional if provided reproduction)

  1. yarn dev

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions