Exclude assert shim (#12147)
This commit is contained in:
1 parent
38b5b98393
commit
2c5839b4ac
2 files changed
+13
-4
No files matched your search
@@ -71,7 +71,7 @@ function getBabelConfig(bundle) {
|
||||
return config;
|
||||
}
|
||||
|
||||
function* getEsbuildOptions(bundle, options) {
|
||||
async function* getEsbuildOptions(bundle, options) {
|
||||
const replaceStrings = {
|
||||
"process.env.PRETTIER_TARGET": JSON.stringify(bundle.target),
|
||||
"process.env.NODE_ENV": JSON.stringify("production"),
|
||||
@@ -129,6 +129,11 @@ function* getEsbuildOptions(bundle, options) {
|
||||
]) {
|
||||
replaceModule[path.join(PROJECT_ROOT, file)] = { contents: "" };
|
||||
}
|
||||
|
||||
// Prevent `esbuildPluginNodeModulePolyfills` include shim for this module
|
||||
replaceModule.assert = {
|
||||
contents: await fs.readFile(path.join(__dirname, "./shims/assert.cjs")),
|
||||
};
|
||||
}
|
||||
|
||||
let shouldMinify = options.minify;
|
||||
@@ -141,10 +146,10 @@ function* getEsbuildOptions(bundle, options) {
|
||||
bundle: true,
|
||||
metafile: true,
|
||||
plugins: [
|
||||
bundle.target === "universal" && esbuildPluginNodeGlobalsPolyfills(),
|
||||
bundle.target === "universal" && esbuildPluginNodeModulePolyfills(),
|
||||
esbuildPluginEvaluate(),
|
||||
esbuildPluginReplaceModule({ ...replaceModule, ...bundle.replaceModule }),
|
||||
bundle.target === "universal" && esbuildPluginNodeGlobalsPolyfills(),
|
||||
bundle.target === "universal" && esbuildPluginNodeModulePolyfills(),
|
||||
esbuildPluginTextReplace({
|
||||
include: /\.[cm]?js$/,
|
||||
// TODO[@fisker]: Use RegExp when possible
|
||||
@@ -243,7 +248,7 @@ async function createBundle(bundle, options) {
|
||||
}
|
||||
|
||||
const esbuildOptions = getEsbuildOptions(bundle, options);
|
||||
for (const options of esbuildOptions) {
|
||||
for await (const options of esbuildOptions) {
|
||||
await runBuild(bundle, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
const assert = () => {};
|
||||
assert.ok = assert;
|
||||
assert.strictEqual = assert;
|
||||
module.exports = assert;
|
||||
Reference in new issue
Block a user