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

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

Open
SgtPooki opened this issue Mar 15, 2024 · 1 comment
Open

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

SgtPooki opened this issue Mar 15, 2024 · 1 comment

Comments

@SgtPooki
Copy link
Member

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] 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.
@marcus-pousette
Copy link
Contributor

marcus-pousette commented Apr 3, 2024

Need this!

or well

this seem to work also

build: {
        config: {
            banner: { js: '' },
            footer: { js: '' }
        }
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants