Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update babel imports to use named exports #365

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/trace/cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function createCjsAnalysis(
source: string,
url: string
): Promise<Analysis> {
if (!babel) ({ default: babel } = await import("@babel/core"));
if (!babel) babel = await import("@babel/core");

const requires = new Set<string>();
const lazy = new Set<string>();
Expand Down Expand Up @@ -110,7 +110,7 @@ export async function createCjsAnalysis(
size: source.length,
format: "commonjs",
usesCjs,
integrity: getIntegrity(source)
integrity: getIntegrity(source),
};
}

Expand Down
19 changes: 4 additions & 15 deletions src/trace/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ export async function createTsAnalysis(
): Promise<Analysis> {
if (!babel)
[
{ default: babel },
{
default: { default: babelPresetTs },
},
babel,
{ default: babelPresetTs },
{ default: babelPluginImportAttributes },
] = await Promise.all([
import("@babel/core"),
Expand All @@ -54,7 +52,6 @@ export async function createTsAnalysis(

const imports = new Set<string>();
const dynamicImports = new Set<string>();
let importMeta = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

the importMeta flag is not being used.


// @ts-ignore
globalThis.console = dummyConsole;
Expand Down Expand Up @@ -84,7 +81,7 @@ export async function createTsAnalysis(
],
plugins: [
babelPluginImportAttributes,
({ types: t }) => {
() => {
return {
visitor: {
ExportAllDeclaration(path) {
Expand All @@ -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;
}
},
},
};
},
Expand All @@ -128,7 +117,7 @@ export async function createTsAnalysis(
cjsLazyDeps: null,
size: source.length,
format: "typescript",
integrity: getIntegrity(source)
integrity: getIntegrity(source),
};
}

Expand Down
10 changes: 5 additions & 5 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading