Skip to content

Commit

Permalink
Merge pull request #644 from jonobr1/issue-643-commonjs
Browse files Browse the repository at this point in the history
Added module.exports to UMD Files
  • Loading branch information
jonobr1 authored Jun 9, 2022
2 parents ac786b0 + d0a619f commit a263cf7
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 a263cf7

Please sign in to comment.