Skip to content
Permalink
Browse files
Add ES6 module output
  • Loading branch information
nathanhammond authored and mathiasbynens committed Oct 24, 2016
1 parent a541fe6 commit e69fd3df332b96476398e0ea47ad045df93e2f94
Showing with 25 additions and 3 deletions.
  1. +3 −0 .gitignore
  2. +1 −1 README.md
  3. +5 −2 package.json
  4. +16 −0 scripts/prepublish.js
@@ -1,3 +1,6 @@
# Generated files
punycode.es6.js

# Coverage report
coverage

@@ -12,7 +12,7 @@ This JavaScript library is the result of comparing, optimizing and documenting d

This project was [bundled](https://github.com/joyent/node/blob/master/lib/punycode.js) with Node.js from [v0.6.2+](https://github.com/joyent/node/compare/975f1930b1...61e796decc) until [v7](https://github.com/nodejs/node/pull/7941) (soft-deprecated).

The current version supports recent versions of Node.js only. For the old version that offers the same functionality with broader support, including Rhino, Ringo, Narwhal, and web browsers, see [v1.4.1](https://github.com/bestiejs/punycode.js/releases/tag/v1.4.1).
The current version supports recent versions of Node.js only. It provides a CommonJS module and an ES6 module. For the old version that offers the same functionality with broader support, including Rhino, Ringo, Narwhal, and web browsers, see [v1.4.1](https://github.com/bestiejs/punycode.js/releases/tag/v1.4.1).

## Installation

@@ -4,6 +4,7 @@
"description": "A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.",
"homepage": "https://mths.be/punycode",
"main": "punycode.js",
"jsnext:main": "punycode.es6.js",
"engines": {
"node": ">=6"
},
@@ -34,10 +35,12 @@
"bugs": "https://github.com/bestiejs/punycode.js/issues",
"files": [
"LICENSE-MIT.txt",
"punycode.js"
"punycode.js",
"punycode.es6.js"
],
"scripts": {
"test": "mocha tests"
"test": "mocha tests",
"prepublish": "node scripts/prepublish.js"
},
"devDependencies": {
"codecov": "^1.0.1",
@@ -0,0 +1,16 @@
'use strict';

const fs = require('fs');
const path = require('path');

const regex = /module\.exports = 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;');

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

0 comments on commit e69fd3d

Please sign in to comment.