Skip to content

Commit 0c23344

Browse files
authored
Update esbuild to v0.16.5 and use new --packages=external option (#51877)
1 parent 6d41964 commit 0c23344

File tree

3 files changed

+187
-218
lines changed

3 files changed

+187
-218
lines changed

Herebyfile.mjs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ async function runDtsBundler(entrypoint, output) {
160160
* @param {BundlerTaskOptions} [taskOptions]
161161
*
162162
* @typedef BundlerTaskOptions
163-
* @property {string[]} [external]
164163
* @property {boolean} [exportIsTsObject]
165164
* @property {boolean} [treeShaking]
166165
* @property {esbuild.WatchMode} [watchMode]
@@ -179,32 +178,10 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
179178
sourcemap: "linked",
180179
sourcesContent: false,
181180
treeShaking: taskOptions.treeShaking,
182-
external: [
183-
...(taskOptions.external ?? []),
184-
"source-map-support",
185-
],
181+
packages: "external",
186182
logLevel: "warning",
187183
// legalComments: "none", // If we add copyright headers to the source files, uncomment.
188184
plugins: [
189-
{
190-
name: "no-node-modules",
191-
setup: (build) => {
192-
build.onLoad({ filter: /[\\/]node_modules[\\/]/ }, () => {
193-
// Ideally, we'd use "--external:./node_modules/*" here, but that doesn't work; we
194-
// will instead end up with paths to node_modules rather than the package names.
195-
// Instead, we'll return a load error when we see that we're trying to bundle from
196-
// node_modules, then explicitly declare which external dependencies we rely on, which
197-
// ensures that the correct module specifier is kept in the output (the non-wildcard
198-
// form works properly). It also helps us keep tabs on what external dependencies we
199-
// may be importing, which is handy.
200-
//
201-
// See: https://github.com/evanw/esbuild/issues/1958
202-
return {
203-
errors: [{ text: 'Attempted to bundle from node_modules; ensure "external" is set correctly.' }]
204-
};
205-
});
206-
}
207-
},
208185
{
209186
name: "fix-require",
210187
setup: (build) => {
@@ -448,14 +425,6 @@ const { main: tests, watch: watchTests } = entrypointBuildTask({
448425
bundlerOptions: {
449426
// Ensure we never drop any dead code, which might be helpful while debugging.
450427
treeShaking: false,
451-
// These are directly imported via import statements and should not be bundled.
452-
external: [
453-
"chai",
454-
"del",
455-
"diff",
456-
"mocha",
457-
"ms",
458-
],
459428
watchMode: {
460429
onRebuild() {
461430
watchTestsEmitter.emit("rebuild");

0 commit comments

Comments
 (0)