From 7d74a0f1c12ddae8a132bafd85d0fddfa0eed70a Mon Sep 17 00:00:00 2001 From: Jaya Krishna Date: Wed, 10 Jul 2024 16:24:57 +0530 Subject: [PATCH] chore: update babel imports to use named exports --- src/trace/cjs.ts | 4 ++-- src/trace/ts.ts | 19 ++++--------------- test/test.html | 10 +++++----- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/trace/cjs.ts b/src/trace/cjs.ts index 8516c85..10c1d39 100644 --- a/src/trace/cjs.ts +++ b/src/trace/cjs.ts @@ -21,7 +21,7 @@ export async function createCjsAnalysis( source: string, url: string ): Promise { - if (!babel) ({ default: babel } = await import("@babel/core")); + if (!babel) babel = await import("@babel/core"); const requires = new Set(); const lazy = new Set(); @@ -110,7 +110,7 @@ export async function createCjsAnalysis( size: source.length, format: "commonjs", usesCjs, - integrity: getIntegrity(source) + integrity: getIntegrity(source), }; } diff --git a/src/trace/ts.ts b/src/trace/ts.ts index 7049218..6ce2303 100644 --- a/src/trace/ts.ts +++ b/src/trace/ts.ts @@ -41,10 +41,8 @@ export async function createTsAnalysis( ): Promise { if (!babel) [ - { default: babel }, - { - default: { default: babelPresetTs }, - }, + babel, + { default: babelPresetTs }, { default: babelPluginImportAttributes }, ] = await Promise.all([ import("@babel/core"), @@ -54,7 +52,6 @@ export async function createTsAnalysis( const imports = new Set(); const dynamicImports = new Set(); - let importMeta = false; // @ts-ignore globalThis.console = dummyConsole; @@ -84,7 +81,7 @@ export async function createTsAnalysis( ], plugins: [ babelPluginImportAttributes, - ({ types: t }) => { + () => { return { visitor: { ExportAllDeclaration(path) { @@ -105,14 +102,6 @@ export async function createTsAnalysis( ) ); }, - MetaProperty(path) { - if ( - t.isIdentifier(path.node.meta, { name: "import" }) && - t.isIdentifier(path.node.property, { name: "meta" }) - ) { - importMeta = true; - } - }, }, }; }, @@ -128,7 +117,7 @@ export async function createTsAnalysis( cjsLazyDeps: null, size: source.length, format: "typescript", - integrity: getIntegrity(source) + integrity: getIntegrity(source), }; } diff --git a/test/test.html b/test/test.html index 6af29a2..2c44341 100644 --- a/test/test.html +++ b/test/test.html @@ -27,7 +27,7 @@ "#lib/config/files/index.js": "https://ga.jspm.io/npm:@babel/core@7.24.7/lib/config/files/index-browser.js", "#lib/config/resolve-targets.js": "https://ga.jspm.io/npm:@babel/core@7.24.7/lib/config/resolve-targets-browser.js", "#lib/transform-file.js": "https://ga.jspm.io/npm:@babel/core@7.24.7/lib/transform-file-browser.js", - "#node.js": "https://ga.jspm.io/npm:browserslist@4.23.1/browser.js", + "#node.js": "https://ga.jspm.io/npm:browserslist@4.23.2/browser.js", "@ampproject/remapping": "https://ga.jspm.io/npm:@ampproject/remapping@2.3.0/dist/remapping.umd.js", "@babel/code-frame": "https://ga.jspm.io/npm:@babel/code-frame@7.24.7/lib/index.js", "@babel/compat-data/native-modules": "https://ga.jspm.io/npm:@babel/compat-data@7.24.7/native-modules.js", @@ -65,18 +65,18 @@ "@jridgewell/gen-mapping": "https://ga.jspm.io/npm:@jridgewell/gen-mapping@0.3.5/dist/gen-mapping.umd.js", "@jridgewell/resolve-uri": "https://ga.jspm.io/npm:@jridgewell/resolve-uri@3.1.2/dist/resolve-uri.umd.js", "@jridgewell/set-array": "https://ga.jspm.io/npm:@jridgewell/set-array@1.2.1/dist/set-array.umd.js", - "@jridgewell/sourcemap-codec": "https://ga.jspm.io/npm:@jridgewell/sourcemap-codec@1.4.15/dist/sourcemap-codec.umd.js", + "@jridgewell/sourcemap-codec": "https://ga.jspm.io/npm:@jridgewell/sourcemap-codec@1.5.0/dist/sourcemap-codec.umd.js", "@jridgewell/trace-mapping": "https://ga.jspm.io/npm:@jridgewell/trace-mapping@0.3.25/dist/trace-mapping.umd.js", "ansi-styles": "https://ga.jspm.io/npm:ansi-styles@3.2.1/index.js", - "browserslist": "https://ga.jspm.io/npm:browserslist@4.23.1/index.js", + "browserslist": "https://ga.jspm.io/npm:browserslist@4.23.2/index.js", "buffer": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/buffer.js", - "caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:caniuse-lite@1.0.30001640/dist/unpacker/agents.js", + "caniuse-lite/dist/unpacker/agents": "https://ga.jspm.io/npm:caniuse-lite@1.0.30001641/dist/unpacker/agents.js", "chalk": "https://ga.jspm.io/npm:chalk@2.4.2/index.js", "color-convert": "https://ga.jspm.io/npm:color-convert@1.9.3/index.js", "color-name": "https://ga.jspm.io/npm:color-name@1.1.3/index.js", "convert-source-map": "https://ga.jspm.io/npm:convert-source-map@2.0.0/index.js", "debug": "https://ga.jspm.io/npm:debug@4.3.5/src/browser.js", - "electron-to-chromium/versions": "https://ga.jspm.io/npm:electron-to-chromium@1.4.818/versions.js", + "electron-to-chromium/versions": "https://ga.jspm.io/npm:electron-to-chromium@1.4.823/versions.js", "escape-string-regexp": "https://ga.jspm.io/npm:escape-string-regexp@1.0.5/index.js", "fs": "https://ga.jspm.io/npm:@jspm/core@2.0.1/nodelibs/browser/fs.js", "gensync": "https://ga.jspm.io/npm:gensync@1.0.0-beta.2/index.js",