Shopify / quilt

[⚠️ Deprecated] A loosely related set of packages for JavaScript/TypeScript projects at Shopify
MIT License
1.7k stars 222 forks source link

fix: babel compiling with empty target for node #2795

Closed iAmNathanJ closed 5 months ago

iAmNathanJ commented 5 months ago

Description

It looks like a recent change to .browserslistrc is causing babel to compile the node target as undefined and therefore including all transforms plus generator helpers. This breaks library usage unless consumers (or quilt) were to include a global regenerator runtime.

Upgrading @babel/core and @babel/preset-env fixes the problem.

Using the debug option with @babel/preset-env shows the parsed build targets and applicable transforms:

before browserslist change (original state) ```sh @babel/preset-env: `DEBUG` option Using targets: { "node": "14.17" } Using modules transform: auto Using plugins: proposal-class-static-block { node < 16.11 } proposal-private-property-in-object { node < 16.9 } proposal-class-properties { } proposal-private-methods { } proposal-numeric-separator { } proposal-logical-assignment-operators { node < 15 } proposal-nullish-coalescing-operator { } proposal-optional-chaining { } syntax-json-strings syntax-optional-catch-binding syntax-async-generators syntax-object-rest-spread syntax-dynamic-import syntax-export-namespace-from syntax-top-level-await ```
after browserslist change (current state) ```sh @babel/preset-env: `DEBUG` option Using targets: {} <-- ! targets empty Using modules transform: auto Using plugins: proposal-class-static-block { } proposal-private-property-in-object { } proposal-class-properties { } proposal-private-methods { } proposal-numeric-separator { } proposal-logical-assignment-operators { } proposal-nullish-coalescing-operator { } proposal-optional-chaining { } proposal-json-strings { } proposal-optional-catch-binding { } transform-parameters { } proposal-async-generator-functions { } proposal-object-rest-spread { } transform-dotall-regex { } proposal-unicode-property-regex { } transform-named-capturing-groups-regex { } transform-async-to-generator { } transform-exponentiation-operator { } transform-template-literals { } transform-literals { } transform-function-name { } transform-arrow-functions { } transform-block-scoped-functions { } transform-classes { } transform-object-super { } transform-shorthand-properties { } transform-duplicate-keys { } transform-computed-properties { } transform-for-of { } transform-sticky-regex { } transform-unicode-escapes { } transform-unicode-regex { } transform-spread { } transform-destructuring { } transform-block-scoping { } transform-typeof-symbol { } transform-new-target { } transform-regenerator { } transform-member-expression-literals { } transform-property-literals { } transform-reserved-words { } proposal-export-namespace-from { } syntax-dynamic-import syntax-export-namespace-from syntax-top-level-await ```
this branch ```sh @babel/preset-env: `DEBUG` option Using targets: { "node": "18.19" } Using modules transform: auto Using plugins: transform-unicode-sets-regex { node < 20 } syntax-class-static-block syntax-private-property-in-object proposal-class-properties { } proposal-private-methods { } proposal-numeric-separator { } proposal-nullish-coalescing-operator { } proposal-optional-chaining { } syntax-json-strings syntax-optional-catch-binding syntax-async-generators syntax-object-rest-spread syntax-export-namespace-from syntax-dynamic-import syntax-top-level-await syntax-import-meta ```

I think this should affect all packages using the isIsomorphic: false flag in their rollup config so I've added a changeset for each.

iAmNathanJ commented 5 months ago

/snapit

github-actions[bot] commented 5 months ago

🫰✨ Thanks @iAmNathanJ! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/graphql-persisted": "0.0.0-snapshot-20240616173624",
"@shopify/koa-liveness-ping": "0.0.0-snapshot-20240616173624",
"@shopify/koa-metrics": "0.0.0-snapshot-20240616173624",
"@shopify/koa-performance": "0.0.0-snapshot-20240616173624",
"@shopify/koa-shopify-graphql-proxy": "0.0.0-snapshot-20240616173624",
"@shopify/koa-shopify-webhooks": "0.0.0-snapshot-20240616173624",
"@shopify/react-server": "0.0.0-snapshot-20240616173624",
"@shopify/sewing-kit-koa": "0.0.0-snapshot-20240616173624",
"@shopify/storybook-a11y-test": "0.0.0-snapshot-20240616173624"