Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(esbuild): fix static properties transpile when useDefineForClassFields false #13992

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 31, 2023

Description

Fix #13863

In esbuild 0.18, when target: 'esnext' is passed, and useDefineForClassFields is false, it transpiles

class Foo {
  static bar = 'hello'
}

into

class Foo {
  static {
    bar = 'hello'
  }
}

Which the latter support isn't great, but it's because we specify esnext that it transpile it that way. In this PR, I disabled this static block transpilation so it transpiles to a syntax that's better supported:

class Foo {}
Foo.bar = 'hello'

Additional context

I don't think this is a great fix. I've noted something we can improve on in the TODO to not rely on esnext by default.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Jul 31, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev patak-dev merged commit 4ca7c13 into main Jul 31, 2023
12 checks passed
@patak-dev patak-dev deleted the fix-define-class-field-esbuild-18 branch July 31, 2023 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error Unexpected token '{' after upgrade [email protected] to [email protected]
2 participants