From d0a619f7058e1a70ef2fb145b459f9878a0d1104 Mon Sep 17 00:00:00 2001 From: Jono Brandel Date: Thu, 9 Jun 2022 09:05:36 -0700 Subject: [PATCH] Added module.exports to UMD Files --- utils/build.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/build.js b/utils/build.js index a2cdb852f..41f972f51 100644 --- a/utils/build.js +++ b/utils/build.js @@ -20,6 +20,7 @@ async function buildModules() { entryPoints: [paths.entry], outfile: paths.umd, bundle: true, + minify: false, format: 'iife', globalName: 'Two' }); @@ -48,10 +49,12 @@ async function buildModules() { const esmOutput = await fs.promises.readFile(paths.esm); const minOutput = await fs.promises.readFile(paths.min); + const moduleExports = `(function(){if(typeof exports==='object'&&typeof module!=='undefined'){module.exports=Two}})()`; + return Promise.all([ - fs.promises.writeFile(paths.umd, [licenseComment, template(umdOutput, true)].join('\n')), + fs.promises.writeFile(paths.umd, [licenseComment, template(umdOutput, true), moduleExports].join('\n')), fs.promises.writeFile(paths.esm, [licenseComment, template(esmOutput, false)].join('\n')), - fs.promises.writeFile(paths.min, [licenseComment, template(minOutput, true)].join('\n')) + fs.promises.writeFile(paths.min, [licenseComment, template(minOutput, true), moduleExports].join('\n')) ]); }