From 3a1077c2d2d8a55797d83e330c5a9607e42da78b Mon Sep 17 00:00:00 2001 From: Jess Telford Date: Thu, 12 Sep 2024 18:24:41 +1000 Subject: [PATCH] Remove "@babel/traverse" dependency Used only as types which are also available from @babel/core. This ensures the types don't get out of sync since @babel/core is sometimes listed as a peer dependency (web-worker). --- .changeset/dry-hotels-give.md | 5 +++++ packages/async/package.json | 1 - packages/async/src/babel-plugin.ts | 4 +++- packages/react-i18n/package.json | 1 - packages/react-i18n/src/babel-plugin/index.ts | 3 +-- packages/web-worker/src/babel-plugin.ts | 5 ++++- yarn.lock | 21 ++++++++++++++++--- 7 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 .changeset/dry-hotels-give.md diff --git a/.changeset/dry-hotels-give.md b/.changeset/dry-hotels-give.md new file mode 100644 index 0000000000..831c91359b --- /dev/null +++ b/.changeset/dry-hotels-give.md @@ -0,0 +1,5 @@ +--- +'@shopify/web-worker': patch +--- + +Ensure the correct babel types are used internally diff --git a/packages/async/package.json b/packages/async/package.json index 65b16bdec2..4ee0e19bc1 100644 --- a/packages/async/package.json +++ b/packages/async/package.json @@ -33,7 +33,6 @@ "devDependencies": { "@babel/core": ">=7.0.0", "@babel/plugin-syntax-dynamic-import": ">=7.0.0", - "@babel/traverse": ">=7.23.2", "@babel/types": ">=7.0.0", "@types/babel__core": ">=7.0.0", "@types/babel__traverse": ">=7.0.0" diff --git a/packages/async/src/babel-plugin.ts b/packages/async/src/babel-plugin.ts index 17c882deec..7f2d82baf8 100644 --- a/packages/async/src/babel-plugin.ts +++ b/packages/async/src/babel-plugin.ts @@ -1,5 +1,7 @@ import type Types from '@babel/types'; -import type {NodePath, Binding} from '@babel/traverse'; +import type {NodePath, BabelFile} from '@babel/core'; + +type Binding = BabelFile['scope']['bindings'][string]; /* eslint-disable @typescript-eslint/naming-convention */ const DEFAULT_PACKAGES_TO_PROCESS = { diff --git a/packages/react-i18n/package.json b/packages/react-i18n/package.json index ddc3a6eeff..e84cdf37ae 100644 --- a/packages/react-i18n/package.json +++ b/packages/react-i18n/package.json @@ -68,7 +68,6 @@ }, "optionalDependencies": { "@babel/template": "^7.0.0", - "@babel/traverse": "^7.23.2", "fs-extra": "^9.1.0" }, "files": [ diff --git a/packages/react-i18n/src/babel-plugin/index.ts b/packages/react-i18n/src/babel-plugin/index.ts index 350d0fab54..af89ab1d38 100644 --- a/packages/react-i18n/src/babel-plugin/index.ts +++ b/packages/react-i18n/src/babel-plugin/index.ts @@ -3,10 +3,9 @@ import path from 'path'; import glob from 'glob'; import stringHash from 'string-hash'; import {camelCase} from 'change-case'; -import type {BabelFile} from '@babel/core'; +import type {Node, NodePath, BabelFile} from '@babel/core'; import type {TemplateBuilder} from '@babel/template'; import type Types from '@babel/types'; -import type {Node, NodePath} from '@babel/traverse'; import { fallbackTranslationsImport, diff --git a/packages/web-worker/src/babel-plugin.ts b/packages/web-worker/src/babel-plugin.ts index 45492ae507..53958128ca 100644 --- a/packages/web-worker/src/babel-plugin.ts +++ b/packages/web-worker/src/babel-plugin.ts @@ -1,15 +1,18 @@ import {resolve} from 'path'; import {runInNewContext} from 'vm'; -import type {NodePath, Binding} from '@babel/traverse'; import type { PluginObj, + BabelFile, + NodePath, types as babelTypes, template as babelTemplate, } from '@babel/core'; import type {Options as LoaderOptions} from './webpack-parts/loader'; +type Binding = BabelFile['scope']['bindings'][string]; + export const DEFAULT_PACKAGES_TO_PROCESS = { // eslint-disable-next-line @typescript-eslint/naming-convention '@shopify/web-worker': [ diff --git a/yarn.lock b/yarn.lock index 76e52df9bc..5cccf30fcc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1460,7 +1460,7 @@ "@babel/parser" "^7.24.7" "@babel/types" "^7.24.7" -"@babel/traverse@>=7.23.2", "@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.23.2", "@babel/traverse@^7.24.7", "@babel/traverse@^7.7.2": +"@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.24.7", "@babel/traverse@^7.7.2": version "7.24.7" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.24.7.tgz#de2b900163fa741721ba382163fe46a936c40cf5" integrity sha512-yb65Ed5S/QAcewNPh0nZczy9JdYXkkAbIsEo+P7BE7yO3txAY30Y/oPa3QkQ5It3xVG2kpKMg9MsdxZaO31uKA== @@ -12672,7 +12672,15 @@ react-docgen@^5.0.0: node-dir "^0.1.10" strip-indent "^3.0.0" -"react-dom18@npm:react-dom@^18.1.0", react-dom@^18.1.0: +"react-dom18@npm:react-dom@^18.1.0": + version "18.1.0" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.1.0.tgz#7f6dd84b706408adde05e1df575b3a024d7e8a2f" + integrity sha512-fU1Txz7Budmvamp7bshe4Zi32d0ll7ect+ccxNu9FlObT605GOEB8BfO4tmRJ39R5Zj831VCpvQ05QPBW5yb+w== + dependencies: + loose-envify "^1.1.0" + scheduler "^0.22.0" + +react-dom@^18.1.0: version "18.1.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.1.0.tgz#7f6dd84b706408adde05e1df575b3a024d7e8a2f" integrity sha512-fU1Txz7Budmvamp7bshe4Zi32d0ll7ect+ccxNu9FlObT605GOEB8BfO4tmRJ39R5Zj831VCpvQ05QPBW5yb+w== @@ -12731,7 +12739,14 @@ react-router@6.4.0: dependencies: "@remix-run/router" "1.0.0" -"react18@npm:react@^18.1.0", react@^18.1.0: +"react18@npm:react@^18.1.0": + version "18.1.0" + resolved "https://registry.yarnpkg.com/react/-/react-18.1.0.tgz#6f8620382decb17fdc5cc223a115e2adbf104890" + integrity sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ== + dependencies: + loose-envify "^1.1.0" + +react@^18.1.0: version "18.1.0" resolved "https://registry.yarnpkg.com/react/-/react-18.1.0.tgz#6f8620382decb17fdc5cc223a115e2adbf104890" integrity sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==