Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update esbuild to v0.16.5 and use new --packages=external option #51877

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ async function runDtsBundler(entrypoint, output) {
* @param {BundlerTaskOptions} [taskOptions]
*
* @typedef BundlerTaskOptions
* @property {string[]} [external]
* @property {boolean} [exportIsTsObject]
* @property {boolean} [treeShaking]
* @property {esbuild.WatchMode} [watchMode]
Expand All @@ -179,32 +178,10 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
sourcemap: "linked",
sourcesContent: false,
treeShaking: taskOptions.treeShaking,
external: [
...(taskOptions.external ?? []),
"source-map-support",
],
packages: "external",
logLevel: "warning",
// legalComments: "none", // If we add copyright headers to the source files, uncomment.
plugins: [
{
name: "no-node-modules",
setup: (build) => {
build.onLoad({ filter: /[\\/]node_modules[\\/]/ }, () => {
// Ideally, we'd use "--external:./node_modules/*" here, but that doesn't work; we
// will instead end up with paths to node_modules rather than the package names.
// Instead, we'll return a load error when we see that we're trying to bundle from
// node_modules, then explicitly declare which external dependencies we rely on, which
// ensures that the correct module specifier is kept in the output (the non-wildcard
// form works properly). It also helps us keep tabs on what external dependencies we
// may be importing, which is handy.
//
// See: https://github.com/evanw/esbuild/issues/1958
return {
errors: [{ text: 'Attempted to bundle from node_modules; ensure "external" is set correctly.' }]
};
});
}
},
{
name: "fix-require",
setup: (build) => {
Expand Down Expand Up @@ -448,14 +425,6 @@ const { main: tests, watch: watchTests } = entrypointBuildTask({
bundlerOptions: {
// Ensure we never drop any dead code, which might be helpful while debugging.
treeShaking: false,
// These are directly imported via import statements and should not be bundled.
external: [
"chai",
"del",
"diff",
"mocha",
"ms",
],
watchMode: {
onRebuild() {
watchTestsEmitter.emit("rebuild");
Expand Down
Loading