Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

fix: babel compiling with empty target for node #2795

Merged
merged 2 commits into from
Jun 17, 2024
Merged

Conversation

iAmNathanJ
Copy link
Contributor

@iAmNathanJ iAmNathanJ commented Jun 14, 2024

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)
@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)
@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
@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 iAmNathanJ requested a review from a team as a code owner June 14, 2024 21:41
@iAmNathanJ iAmNathanJ requested a review from mateus June 14, 2024 21:41
@iAmNathanJ iAmNathanJ force-pushed the fix-babel-node-target branch from f6ccbe7 to 7728dd1 Compare June 16, 2024 16:31
@iAmNathanJ
Copy link
Contributor Author

/snapit

Copy link
Contributor

🫰✨ 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"

Copy link

@EdwardGallant EdwardGallant left a comment

Choose a reason for hiding this comment

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

I am shocked babel is still a thing

Copy link
Contributor

@patrickracicot patrickracicot left a comment

Choose a reason for hiding this comment

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

Confirmed that the snapshot fixes the CD of the Search & Discovery app. I've also confirmed that the application runs as expected.

@iAmNathanJ iAmNathanJ merged commit 8fa47ff into main Jun 17, 2024
5 checks passed
@iAmNathanJ iAmNathanJ deleted the fix-babel-node-target branch June 17, 2024 13:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants