diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..efbacd7 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["es2015"], + "plugins": ["add-module-exports"], +} diff --git a/.gitignore b/.gitignore index 3c3629e..491fc35 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +lib diff --git a/es/index.js b/es/index.js new file mode 100644 index 0000000..dacce17 --- /dev/null +++ b/es/index.js @@ -0,0 +1,11 @@ +/* global window */ +import ponyfill from './ponyfill'; + +let root = this; +if (typeof global !== 'undefined') { + root = global; +} else if (typeof window !== 'undefined') { + root = window; +} + +export default ponyfill(root); diff --git a/ponyfill.js b/es/ponyfill.js similarity index 78% rename from ponyfill.js rename to es/ponyfill.js index b81f36c..95dedc2 100644 --- a/ponyfill.js +++ b/es/ponyfill.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function symbolObservablePonyfill(root) { +export default function symbolObservablePonyfill(root) { var result; var Symbol = root.Symbol; diff --git a/index.js b/index.js index 25cff4b..2291cd8 100644 --- a/index.js +++ b/index.js @@ -1,10 +1 @@ -/* global window */ -'use strict'; - -var root = this; -if (typeof global !== 'undefined') { - root = global; -} else if (typeof window !== 'undefined') { - root = window; -} -module.exports = require('./ponyfill')(root); \ No newline at end of file +module.exports = require('./lib/'); diff --git a/package.json b/package.json index 49ff105..fd6ff64 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,18 @@ "node": ">=0.10.0" }, "scripts": { - "test": "mocha" + "build": "babel es --out-dir lib", + "test": "npm run build && mocha", + "prepublish": "npm test" }, "files": [ "index.js", "ponyfill.js", - "index.d.ts" + "index.d.ts", + "es/index.js", + "es/ponyfill/js", + "lib/index.js", + "lib/ponyfill.js" ], "keywords": [ "symbol", @@ -28,6 +34,9 @@ "shim" ], "devDependencies": { + "babel-cli": "^6.9.0", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-preset-es2015": "^6.9.0", "chai": "^3.5.0", "mocha": "^2.4.5" } diff --git a/test/ponyfill.js b/test/ponyfill.js index aecb08f..617e37c 100644 --- a/test/ponyfill.js +++ b/test/ponyfill.js @@ -1,6 +1,6 @@ /* global describe, it */ var expect = require('chai').expect; -var ponyfill = require('../ponyfill'); +var ponyfill = require('../lib/ponyfill'); describe('ponyfill unit tests', function () { describe('when Symbol does NOT exist as a function', function () {