esm - inline minimist (#230155)

* esm - inline `minimist`

* .

* .

* .
This commit is contained in:
Benjamin Pasero
2024-09-30 22:13:42 +02:00
committed by GitHub
parent 11cc1c8181
commit 36b52aa938
4 changed files with 25 additions and 8 deletions
+11 -1
View File
@@ -64,6 +64,16 @@ function optimizeESMTask(opts) {
});
}
};
const overrideExternalPlugin = {
name: 'override-external',
setup(build) {
// We inline selected modules that are we depend on on startup without
// a conditional `await import(...)` by hooking into the resolution.
build.onResolve({ filter: /^minimist$/ }, () => {
return { path: path.join(REPO_ROOT_PATH, 'node_modules', 'minimist', 'index.js'), external: false };
});
},
};
const task = esbuild.build({
bundle: true,
external: entryPoint.exclude,
@@ -71,7 +81,7 @@ function optimizeESMTask(opts) {
platform: 'neutral', // makes esm
format: 'esm',
sourcemap: 'external',
plugins: [boilerplateTrimmer],
plugins: [boilerplateTrimmer, overrideExternalPlugin],
target: ['es2022'],
loader: {
'.ttf': 'file',