chore(deps): update dependency esbuild to v0.25.2 (#17316)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
1 parent
6bb0541b59
commit
df7194b385
7 files changed
+149
-139
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import path from "node:path";
|
||||
|
||||
const namespace = "with-default-export";
|
||||
const PLUGIN_NAMESPACE = "with-default-export";
|
||||
export default function esbuildPluginAddDefaultExport() {
|
||||
return {
|
||||
name: "addDefaultExport",
|
||||
@@ -12,18 +12,18 @@ export default function esbuildPluginAddDefaultExport() {
|
||||
|
||||
let entry;
|
||||
|
||||
build.onResolve({ filter: /./u }, (module) => {
|
||||
build.onResolve({ filter: /./, namespace: "file" }, (module) => {
|
||||
if (module.kind === "entry-point") {
|
||||
const relativePath = module.path
|
||||
.slice(module.resolveDir.length + 1)
|
||||
.replaceAll("\\", "/");
|
||||
|
||||
entry = module.path;
|
||||
return { path: relativePath, namespace };
|
||||
return { path: relativePath, namespace: PLUGIN_NAMESPACE };
|
||||
}
|
||||
});
|
||||
|
||||
build.onLoad({ filter: /./u, namespace }, () => {
|
||||
build.onLoad({ filter: /./, namespace: PLUGIN_NAMESPACE }, () => {
|
||||
const directory = path.dirname(entry);
|
||||
const source = `./${path.basename(entry)}`;
|
||||
|
||||
|
||||
@@ -8,33 +8,36 @@ export default function esbuildPluginEvaluate() {
|
||||
setup(build) {
|
||||
const { format } = build.initialOptions;
|
||||
|
||||
build.onLoad({ filter: /\.evaluate\.c?js$/u }, async ({ path }) => {
|
||||
const module = await import(url.pathToFileURL(path));
|
||||
const text = Object.entries(module)
|
||||
.filter(([specifier]) => specifier !== "module.exports")
|
||||
.map(([specifier, value]) => {
|
||||
const code =
|
||||
value instanceof RegExp
|
||||
? `/${value.source}/${value.flags}`
|
||||
: serialize(value, { space: 2 });
|
||||
build.onLoad(
|
||||
{ filter: /\.evaluate\.c?js$/, namespace: "file" },
|
||||
async ({ path }) => {
|
||||
const module = await import(url.pathToFileURL(path));
|
||||
const text = Object.entries(module)
|
||||
.filter(([specifier]) => specifier !== "module.exports")
|
||||
.map(([specifier, value]) => {
|
||||
const code =
|
||||
value instanceof RegExp
|
||||
? `/${value.source}/${value.flags}`
|
||||
: serialize(value, { space: 2 });
|
||||
|
||||
if (specifier === "default") {
|
||||
return format === "cjs"
|
||||
? `module.exports = ${code};`
|
||||
: `export default ${code};`;
|
||||
}
|
||||
|
||||
if (!isValidIdentifier(specifier)) {
|
||||
throw new Error(`${specifier} is not a valid specifier`);
|
||||
}
|
||||
|
||||
if (specifier === "default") {
|
||||
return format === "cjs"
|
||||
? `module.exports = ${code};`
|
||||
: `export default ${code};`;
|
||||
}
|
||||
|
||||
if (!isValidIdentifier(specifier)) {
|
||||
throw new Error(`${specifier} is not a valid specifier`);
|
||||
}
|
||||
|
||||
return format === "cjs"
|
||||
? `exports.${specifier} = ${code};`
|
||||
: `export const ${specifier} = ${code};`;
|
||||
})
|
||||
.join("\n");
|
||||
return { contents: text };
|
||||
});
|
||||
? `exports.${specifier} = ${code};`
|
||||
: `export const ${specifier} = ${code};`;
|
||||
})
|
||||
.join("\n");
|
||||
return { contents: text };
|
||||
},
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import fs from "node:fs/promises";
|
||||
|
||||
const DEFAULT_ON_RESOLVE_CONCEPTS = { filter: /./u, namespace: "file" };
|
||||
const DEFAULT_ON_RESOLVE_CONCEPTS = { filter: /./, namespace: "file" };
|
||||
const DEFAULT_ON_LOAD_CONCEPTS = {
|
||||
filter: /\.(?:js|json|mjs|cjs)$/u,
|
||||
filter: /\.(?:js|json|mjs|cjs)$/,
|
||||
namespace: "file",
|
||||
};
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ export default function esbuildPluginStripNodeProtocol() {
|
||||
return {
|
||||
name: "strip-node-protocol",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^node:/u }, ({ path, kind }) =>
|
||||
build.resolve(path.slice(5), { kind }),
|
||||
build.onResolve(
|
||||
{ filter: /^node:/, namespace: "file" },
|
||||
({ path, kind }) => build.resolve(path.slice(5), { kind }),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user