Skip to content

Commit

Permalink
Add support for named exports
Browse files Browse the repository at this point in the history
Closes #63.
  • Loading branch information
garycourt authored and mathiasbynens committed May 22, 2018
1 parent cc9ecb5 commit 185e0d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/prepublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ const fs = require('fs');
const path = require('path');

This comment has been minimized.

Copy link
@MigarantAtom9

MigarantAtom9 May 10, 2019

or loop path to the variable making a cleaner script


const regex = /module\.exports = punycode;/;
const output = 'export { ucs2decode, ucs2encode, decode, encode, toASCII, toUnicode };\nexport default punycode;';

const sourceContents = fs.readFileSync(path.resolve(__dirname, '../punycode.js'), 'utf-8');

if (!regex.test(sourceContents)) {
throw new Error('The underlying library has changed. Please update the prepublish script.');
}

const outputContents = sourceContents.replace(regex, 'export default punycode;');
const outputContents = sourceContents.replace(regex, output);

fs.writeFileSync(path.resolve(__dirname, '../punycode.es6.js'), outputContents);

0 comments on commit 185e0d8

Please sign in to comment.