From 9cbc8e2f719c176f23f0b5b054068c8bc7fa1e2a Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 8 Jul 2024 00:56:28 +0200 Subject: [PATCH] fix: use babel plugin import attributes (#364) --- package-lock.json | 26 +++++++++++++------------- package.json | 2 +- src/generator-deno.ts | 4 ++-- src/trace/ts.ts | 12 ++++++------ test/test.html | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 361c4681..cc29d0d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.24.7", - "@babel/plugin-syntax-import-assertions": "^7.24.7", + "@babel/plugin-syntax-import-attributes": "^7.24.7", "@babel/preset-typescript": "^7.24.7", "@jspm/import-map": "^1.1.0", "es-module-lexer": "^1.5.4", @@ -428,10 +428,10 @@ "node": ">=6.0.0" } }, - "node_modules/@babel/plugin-syntax-import-assertions": { + "node_modules/@babel/plugin-syntax-import-attributes": { "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.24.7.tgz", - "integrity": "sha512-Ec3NRUMoi8gskrkBe3fNmEQfxDvY8bgfQpz6jlk/41kX9eUjvpyqWU7PBP/pLAvMaSQjbMNKJmvX57jP+M6bPg==", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.24.7.tgz", + "integrity": "sha512-hbX+lKKeUMGihnK8nvKqmXBInriT3GVjzXKFriV3YC6APGxMbP8RZNFwy91+hocLXq90Mta+HshoB31802bb8A==", "dependencies": { "@babel/helper-plugin-utils": "^7.24.7" }, @@ -2055,15 +2055,6 @@ "node": ">=4" } }, - "node_modules/executable/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/ext-list": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/ext-list/-/ext-list-2.2.2.tgz", @@ -3512,6 +3503,15 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/prettier": { "version": "2.8.8", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", diff --git a/package.json b/package.json index f00dc2d9..ea385124 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@babel/core": "^7.24.7", - "@babel/plugin-syntax-import-assertions": "^7.24.7", + "@babel/plugin-syntax-import-attributes": "^7.24.7", "@babel/preset-typescript": "^7.24.7", "@jspm/import-map": "^1.1.0", "es-module-lexer": "^1.5.4", diff --git a/src/generator-deno.ts b/src/generator-deno.ts index 473c0c1a..3988a43a 100644 --- a/src/generator-deno.ts +++ b/src/generator-deno.ts @@ -1,6 +1,6 @@ import babel from "@babel/core"; import babelPresetTs from "@babel/preset-typescript"; -import babelPluginSyntaxImportAssertions from "@babel/plugin-syntax-import-assertions"; +import babelPluginSyntaxImportAttributes from "@babel/plugin-syntax-import-attributes"; import { createHash } from "crypto"; import { realpath } from "fs"; import { pathToFileURL } from "url"; @@ -11,7 +11,7 @@ import { setPathFns } from "./trace/resolver.js"; import { setCreateHash } from "./common/integrity.js"; setBabelCjs(babel); -setBabelTs(babel, babelPresetTs, babelPluginSyntaxImportAssertions); +setBabelTs(babel, babelPresetTs, babelPluginSyntaxImportAttributes); setCreateHash(createHash); setPathFns(realpath, pathToFileURL); diff --git a/src/trace/ts.ts b/src/trace/ts.ts index 2d2b5031..70492187 100644 --- a/src/trace/ts.ts +++ b/src/trace/ts.ts @@ -1,12 +1,12 @@ import { getIntegrity } from "../common/integrity.js"; import { Analysis } from "./analysis"; -let babel, babelPresetTs, babelPluginImportAssertions; +let babel, babelPresetTs, babelPluginImportAttributes; -export function setBabel(_babel, _babelPresetTs, _babelPluginImportAssertions) { +export function setBabel(_babel, _babelPresetTs, _babelPluginImportAttributes) { (babel = _babel), (babelPresetTs = _babelPresetTs), - (babelPluginImportAssertions = _babelPluginImportAssertions); + (babelPluginImportAttributes = _babelPluginImportAttributes); } const globalConsole = globalThis.console; @@ -45,11 +45,11 @@ export async function createTsAnalysis( { default: { default: babelPresetTs }, }, - { default: babelPluginImportAssertions }, + { default: babelPluginImportAttributes }, ] = await Promise.all([ import("@babel/core"), import("@babel/preset-typescript"), - import("@babel/plugin-syntax-import-assertions"), + import("@babel/plugin-syntax-import-attributes"), ]); const imports = new Set(); @@ -83,7 +83,7 @@ export async function createTsAnalysis( ], ], plugins: [ - babelPluginImportAssertions, + babelPluginImportAttributes, ({ types: t }) => { return { visitor: { diff --git a/test/test.html b/test/test.html index 36b163b2..6af29a24 100644 --- a/test/test.html +++ b/test/test.html @@ -11,7 +11,7 @@ "../": { "#fetch": "../dist/fetch-native.js", "@babel/core": "https://ga.jspm.io/npm:@babel/core@7.24.7/lib/index.js", - "@babel/plugin-syntax-import-assertions": "https://ga.jspm.io/npm:@babel/plugin-syntax-import-assertions@7.24.7/lib/index.js", + "@babel/plugin-syntax-import-attributes": "https://ga.jspm.io/npm:@babel/plugin-syntax-import-attributes@7.24.7/lib/index.js", "@babel/preset-typescript": "https://ga.jspm.io/npm:@babel/preset-typescript@7.24.7/lib/index.js", "@jspm/import-map": "https://ga.jspm.io/npm:@jspm/import-map@1.1.0/dist/map.js", "crypto": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/crypto.js",