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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 8 deletions

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',

View File

@ -96,6 +96,17 @@ function optimizeESMTask(opts: IOptimizeESMTaskOpts): NodeJS.ReadWriteStream {
}
};
const overrideExternalPlugin: esbuild.Plugin = {
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,
@ -103,7 +114,7 @@ function optimizeESMTask(opts: IOptimizeESMTaskOpts): NodeJS.ReadWriteStream {
platform: 'neutral', // makes esm
format: 'esm',
sourcemap: 'external',
plugins: [boilerplateTrimmer],
plugins: [boilerplateTrimmer, overrideExternalPlugin],
target: ['es2022'],
loader: {
'.ttf': 'file',

View File

@ -18,11 +18,6 @@ flakySuite('Native Modules (all platforms)', () => {
assert.ok(typeof kerberos.initializeClient === 'function', testErrorMessage('kerberos'));
});
test('minimist', async () => {
const { default: minimist } = await import('minimist');
assert.ok(typeof minimist === 'function', testErrorMessage('minimist'));
});
test('yauzl', async () => {
const { default: yauzl } = await import('yauzl');
assert.ok(typeof yauzl.ZipFile === 'function', testErrorMessage('yauzl'));

View File

@ -11,6 +11,7 @@ import { FileChangeType, IFileChange } from '../../common/files.js';
import { URI } from '../../../../base/common/uri.js';
import { DeferredPromise, ThrottledDelayer } from '../../../../base/common/async.js';
import { hash } from '../../../../base/common/hash.js';
import { onUnexpectedError } from '../../../../base/common/errors.js';
interface ISuspendedWatchRequest {
readonly id: number;
@ -107,7 +108,7 @@ export abstract class BaseWatcher extends Disposable implements IWatcher {
}
}
return this.updateWatchersDelayer.trigger(() => this.doWatch(nonSuspendedRequests), delayed ? this.getUpdateWatchersDelay() : 0);
return this.updateWatchersDelayer.trigger(() => this.doWatch(nonSuspendedRequests), delayed ? this.getUpdateWatchersDelay() : 0).catch(error => onUnexpectedError(error));
}
protected getUpdateWatchersDelay(): number {