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(es/helpers): Fix metadata of decorators being undefined #8768

Merged
merged 3 commits into from
Mar 28, 2024

Conversation

sschen86
Copy link
Contributor

when use "decorator stage3" with this option that context.metadata will be undefined

const option = {
    jsc: {
        parser: {
            syntax: 'typescript',
            decorators: true,
        },
        transform: {
            decoratorVersion: '2022-03',
        },
        target: 'es5',
        externalHelpers: true, // external @swc/helpers
    },
    module: {
        type: 'es6',
    }
}

if set externalHelpers to false, context.metadata is right

example code

function Get() {
  return (value, context) => {
    console.info(context.metadata); // out undefind
  };
}

class MyClass{
    @Get()
    doSome(){
        //..
    }
}

@sschen86 sschen86 requested a review from a team as a code owner March 21, 2024 07:56
Copy link

changeset-bot bot commented Mar 21, 2024

⚠️ No Changeset found

Latest commit: f17f306

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdy1 kdy1 changed the title fix decorator of metadata is undefined fix(es/helpers): Fix metadata of decorators being undefined Mar 22, 2024
@kdy1 kdy1 added this to the Planned milestone Mar 22, 2024
@sschen86 sschen86 requested a review from kdy1 March 28, 2024 06:04
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you revert changes in swc_ecma_transforms_base?

@sschen86
Copy link
Contributor Author

Why did you revert changes in swc_ecma_transforms_base?

What, pray, is the meaning of this?

I only modified this file(packages/helpers/esm/_apply_decs_2203_r.js) and added the missing variable metadata

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sschen86
Copy link
Contributor Author

I misread it. Sorry. Please modify https://github.com/swc-project/swc/blob/b798632a829eca950ede021d3e2db57f8649523c/crates/swc_ecma_transforms_base/src/helpers/_apply_decs_2203_r.js, too

This file is correct and there is no missing variable metadata. It does not need to be modified

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swc-bump:

  • dbg-swc

@kdy1 kdy1 enabled auto-merge (squash) March 28, 2024 07:21
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit 263ce6e into swc-project:main Mar 28, 2024
142 checks passed
@kdy1 kdy1 modified the milestones: Planned, v1.4.12 Apr 4, 2024
@swc-project swc-project locked as resolved and limited conversation to collaborators May 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants