web-infra-dev / swc-plugins

SWC plugins and binding
MIT License
55 stars 4 forks source link

fix: adapte syntax based on filename, do not transform core-js-pure #190

Closed JSerFeng closed 1 year ago

JSerFeng commented 1 year ago

fix: lockCorejsVersion

lockCorejsVersion can transform 'core-js/path/to' to 'foo/bar/core-js/path/to'

Before lockCorejsVersion detect if import path is starts with 'core-js', now it detect if it starts with 'core-js/', to avoid detect 'core-js-pure'.

fix: use js syntax to transform js module

As modern-js binding only passed config once, so during loader transform, js files are transformed using the same config, and the syntax is TS syntax, at most cases this is fine, but if using TS syntax, SWC cannot transform new decorator proposal correctly, so I did a hack here, to check if file name ends with JS like, Rust side will change the syntax accordingly

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 79c9ceff3686925674cc08d9995dfbdd13ca641b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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