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

feat(es/module): Preserve custom use directives #7528

Merged
merged 7 commits into from
Jun 16, 2023
Merged

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Jun 14, 2023

Description:

Related issue:

@kdy1 kdy1 added this to the Planned milestone Jun 14, 2023
@kdy1 kdy1 self-assigned this Jun 14, 2023
Copy link
Member Author

@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:

  • swc_ecma_utils

@kdy1 kdy1 marked this pull request as ready for review June 15, 2023 11:58
@kdy1 kdy1 changed the title feat(es/module): Preserve directives for common js modules feat(es/module): Preserve custom use directives Jun 15, 2023
@kdy1 kdy1 enabled auto-merge (squash) June 15, 2023 11:59
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 disabled auto-merge June 15, 2023 12:47
@kdy1 kdy1 merged commit e5152d3 into swc-project:main Jun 16, 2023
129 checks passed
@kdy1 kdy1 deleted the issue-7315 branch June 16, 2023 02:49
kdy1 added a commit that referenced this pull request Jun 16, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.65 Jun 19, 2023
Comment on lines 147 to 149
if self.config.strict_mode {
stmts.push(clone_first_use_strict(n).unwrap_or_else(use_strict));
stmts.push(clone_first_use_directive(n).unwrap_or_else(use_strict));
}
Copy link

Choose a reason for hiding this comment

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

Maybe I'm not understanding what this is doing, but at first glance, does this mean that if an input file has a directive, it would only get hoisted to the top of the file if strictMode is enabled? I'm using strict mode, so it doesn't really affect me, but I imagine this would be a bug that may present itself in the future.

Copy link

Choose a reason for hiding this comment

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

I guess I must be mis-understanding. I just finished upgrading and tried it out setting strictMode to false and the directive still makes its way to the top. So you can ignore me...it is working as it should.

@swc-project swc-project locked as resolved and limited conversation to collaborators Jul 28, 2023
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.

Directive not preserved for commonjs
4 participants