Skip to content

Commit

Permalink
fix: use babel plugin import attributes (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Jul 7, 2024
1 parent 3720c0e commit 9cbc8e2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/generator-deno.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions src/trace/ts.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<string>();
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function createTsAnalysis(
],
],
plugins: [
babelPluginImportAssertions,
babelPluginImportAttributes,
({ types: t }) => {
return {
visitor: {
Expand Down
2 changes: 1 addition & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9cbc8e2

Please sign in to comment.