Skip to content

bug: esbuild config cannot be overridden for many scenarios #1481

Description

@SgtPooki

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch aegir@42.2.2 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/aegir/src/build/index.js b/node_modules/aegir/src/build/index.js
index 54537df..6df4c61 100644
--- a/node_modules/aegir/src/build/index.js
+++ b/node_modules/aegir/src/build/index.js
@@ -36,26 +36,31 @@ const build = async (argv) => {
     entryPoint = fromRoot('dist', 'src', 'index.js')
   }
 
-  const result = await esbuild.build(defaults(
+  const config = defaults(
     {
       entryPoints: [entryPoint],
       bundle: true,
-      format: 'iife',
+      format: argv.fileConfig.build.config.format ?? 'iife',
       conditions: ['production'],
       sourcemap: argv.bundlesize,
       minify: true,
       globalName,
-      banner: { js: umdPre },
-      footer: { js: umdPost },
+      banner: argv.fileConfig.build.config.banner ?? { js: umdPre },
+      footer: argv.fileConfig.build.config.footer ?? { js: umdPost },
       metafile: argv.bundlesize,
-      outfile,
+      outfile: argv.fileConfig.build.config.outfile == null ? undefined : outfile,
       define: {
         global: 'globalThis',
         'process.env.NODE_ENV': '"production"'
       }
     },
     argv.fileConfig.build.config
-  ))
+  )
+  if (config.outdir) {
+    delete config.outfile
+  }
+
+  const result = await esbuild.build(config)
 
   if (result.metafile) {
     fs.writeJSONSync(path.join(paths.dist, 'stats.json'), result.metafile)

This issue body was partially generated by patch-package.


the above was generated by patch-package. Some things I was trying to do that caused me to create this:

  1. set outputdir instead of outfile
  2. change format
  3. remove banner and footer that were not needed for the format I wanted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions