Use imports to replace hack in build script (#17953)
This commit is contained in:
1 parent
07007103d4
commit
67329f4108
25 files changed
+96
-83
No files matched your search
@@ -21,7 +21,6 @@ import transform from "./transform/index.js";
|
||||
import { getPackageFile } from "./utils.js";
|
||||
|
||||
const {
|
||||
dirname,
|
||||
readJsonSync,
|
||||
require,
|
||||
resolve: importMetaResolve,
|
||||
@@ -170,39 +169,6 @@ function getEsbuildOptions({ packageConfig, file, cliOptions }) {
|
||||
};
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
replaceModule.push(
|
||||
// When running build script with `--no-minify`, `esbuildPluginNodeModulePolyfills` shim `module` module incorrectly
|
||||
{
|
||||
module: "*",
|
||||
find: 'import { createRequire } from "node:module";',
|
||||
replacement: "",
|
||||
},
|
||||
// Prevent `esbuildPluginNodeModulePolyfills` shim `assert`, which will include a big `buffer` shim
|
||||
// TODO[@fisker]: Find a better way
|
||||
{
|
||||
module: "*",
|
||||
find: ' from "node:assert";',
|
||||
replacement: ` from ${JSON.stringify(
|
||||
path.join(dirname, "./shims/assert.js"),
|
||||
)};`,
|
||||
},
|
||||
// Prevent `esbuildPluginNodeModulePolyfills` include shim for this module
|
||||
{
|
||||
module: "assert",
|
||||
path: path.join(dirname, "./shims/assert.js"),
|
||||
},
|
||||
// `esbuildPluginNodeModulePolyfills` didn't shim this module
|
||||
{
|
||||
module: "module",
|
||||
text: "export const createRequire = () => {};",
|
||||
},
|
||||
// This module requires file access, should not include in universal bundle
|
||||
{
|
||||
module: path.join(PROJECT_ROOT, "src/utils/get-interpreter.js"),
|
||||
text: "export default undefined;",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Current version of `yaml` is not tree-shakable,
|
||||
|
||||
@@ -953,7 +953,7 @@ export default [
|
||||
format,
|
||||
file: `${outputBaseName}${extensions[format]}`,
|
||||
},
|
||||
platform: "node",
|
||||
platform: "universal",
|
||||
buildOptions,
|
||||
build: buildJavascriptModule,
|
||||
kind: "javascript",
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
const assert = new Proxy(() => {}, { get: () => assert });
|
||||
|
||||
export default assert;
|
||||
Reference in new issue
Block a user