Skip to content

Commit 185e0d8

Browse files
garycourtmathiasbynens
authored andcommitted
Add support for named exports
Closes #63.
1 parent cc9ecb5 commit 185e0d8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scripts/prepublish.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ const fs = require('fs');
44
const path = require('path');
55

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

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

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

14-
const outputContents = sourceContents.replace(regex, 'export default punycode;');
15+
const outputContents = sourceContents.replace(regex, output);
1516

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

0 commit comments

Comments
 (0)