Skip to content

Commit

Permalink
Added module.exports to UMD Files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonobr1 committed Jun 9, 2022
1 parent ac786b0 commit d0a619f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async function buildModules() {
entryPoints: [paths.entry],
outfile: paths.umd,
bundle: true,
minify: false,
format: 'iife',
globalName: 'Two'
});
Expand Down Expand Up @@ -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'))
]);

}
Expand Down

0 comments on commit d0a619f

Please sign in to comment.