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

Updated SWC crate for JS Transformer #9104

Merged
merged 2 commits into from
Jun 25, 2023
Merged

Updated SWC crate for JS Transformer #9104

merged 2 commits into from
Jun 25, 2023

Conversation

alshdavid
Copy link
Contributor

@alshdavid alshdavid commented Jun 23, 2023

↪️ Pull Request

Updated version of swc_ecmascript in the JS transformer to correct generics inside jsx elements

const Foo = () => <Component<any>></Component>

SWC playground

🚨 Test instructions

Build Parcel and try to compile something

#!/bin/bash
export NODE_ENV=production 
export PARCEL_BUILD_ENV=production
export PARCEL_SELF_BUILD=true
export PARCEL_WORKER_BACKEND=process

node scripts/build-native.js | tee

rm -rf packages/*/*/lib

npx parcel build \
  packages/core/{fs,codeframe,package-manager,utils} \
  packages/reporters/{cli,dev-server} \
  packages/utils/{parcel-lsp,parcel-lsp-protocol} \
  | tee

npx gulp | tee

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@mischnic
Copy link
Member

The unit tests are failing because apparently now less whitespaces are emitted:

failures:

---- hoist::tests::fold_dynamic_import stdout ----
error: test failed, to rerun pass `-p parcel-js-swc-core --lib`
thread 'hoist::tests::fold_dynamic_import' panicked at 'assertion failed: `(left == right)`
  left: `"import \"abc:other\";\nasync function $abc$var$test() {\n    const { foo: foo } = await $abc$importAsync$70a00e0a8474f72a;\n    console.log(foo);\n}\n"`,
 right: `"import \"abc:other\";\nasync function $abc$var$test() {\n    const { foo: foo  } = await $abc$importAsync$70a00e0a8474f72a;\n    console.log(foo);\n}\n"`', packages/transformers/js/core/src/hoist.rs:2[950](https://github.com/parcel-bundler/parcel/actions/runs/5353680449/jobs/9709816316?pr=9104#step:9:951):5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- hoist::tests::fold_export stdout ----
thread 'hoist::tests::fold_export' panicked at 'assertion failed: `(left == right)`
  left: `"var { x: $abc$export$d141bba7fdc215a3, ...$abc$export$4a5767248b18ef41 } = something;\nvar [$abc$export$ffb5f4729a158638, ...$abc$export$9e5f44173e64f162] = something;\nvar { x: $abc$export$d141bba7fdc215a3 = 3 } = something;\n"`,
 right: `"var { x: $abc$export$d141bba7fdc215a3 , ...$abc$export$4a5767248b18ef41 } = something;\nvar [$abc$export$ffb5f4729a158638, ...$abc$export$9e5f44173e64f162] = something;\nvar { x: $abc$export$d141bba7fdc215a3 = 3  } = something;\n"`', packages/transformers/js/core/src/hoist.rs:2462:5

---- hoist::tests::fold_require_member stdout ----
thread 'hoist::tests::fold_require_member' panicked at 'assertion failed: `(left == right)`
  left: `"import \"abc:other\";\nconst { foo: $abc$var$foo } = $abc$import$70a00e0a8474f72a$6a5cdcad01c973fa;\nconsole.log($abc$var$foo);\n"`,
 right: `"import \"abc:other\";\nconst { foo: $abc$var$foo  } = $abc$import$70a00e0a8474f72a$6a5cdcad01c973fa;\nconsole.log($abc$var$foo);\n"`', packages/transformers/js/core/src/hoist.rs:2072:5

---- hoist::tests::fold_non_static_require stdout ----
thread 'hoist::tests::fold_non_static_require' panicked at 'assertion failed: `(left == right)`
  left: `"import \"abc:other\";\nconst { foo: $abc$var$foo, ...$abc$var$bar } = $abc$import$70a00e0a8474f72a;\nconsole.log($abc$var$foo, $abc$var$bar);\n"`,
 right: `"import \"abc:other\";\nconst { foo: $abc$var$foo , ...$abc$var$bar } = $abc$import$70a00e0a8474f72a;\nconsole.log($abc$var$foo, $abc$var$bar);\n"`', packages/transformers/js/core/src/hoist.rs:1[967](https://github.com/parcel-bundler/parcel/actions/runs/5353680449/jobs/9709816316?pr=9104#step:9:968):5

---- hoist::tests::fold_require_wrapped stdout ----
thread 'hoist::tests::fold_require_wrapped' panicked at 'assertion failed: `(left == right)`
  left: `"import \"abc:other\";\nfunction $abc$var$x() {\n    const { foo: foo } = $abc$import$70a00e0a8474f72a;\n    console.log(foo);\n}\n"`,
 right: `"import \"abc:other\";\nfunction $abc$var$x() {\n    const { foo: foo  } = $abc$import$70a00e0a8474f72a;\n    console.log(foo);\n}\n"`', packages/transformers/js/core/src/hoist.rs:2203:5


failures:
    hoist::tests::fold_dynamic_import
    hoist::tests::fold_export
    hoist::tests::fold_non_static_require
    hoist::tests::fold_require_member
    hoist::tests::fold_require_wrapped

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.

3 participants