From 85db67edf43fb441ba9cf37a8c9e30ae1a2339a1 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 5 Jan 2015 16:10:41 +0800 Subject: [PATCH 1/3] Add .es to register extensions .es is a known ecmascript file extension and should be handled by the loader See RFC 4329, 8.2. --- lib/6to5/register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/6to5/register.js b/lib/6to5/register.js index d4538c0ae5..d73532e1e9 100644 --- a/lib/6to5/register.js +++ b/lib/6to5/register.js @@ -123,7 +123,7 @@ var hookExtensions = function (_exts) { }); }; -hookExtensions([".es6", ".js"]); +hookExtensions([".es6", ".es", ".js"]); module.exports = function (opts) { // normalise options From d62914e41c887a8cd68d7d8531c439cccc4208de Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 5 Jan 2015 16:35:01 +0800 Subject: [PATCH 2/3] Amend require documentation to include '.es' extension --- doc/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/usage.md b/doc/usage.md index 84917bc0b0..5ada37f79b 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -208,7 +208,7 @@ result.ast; ### Require hook -All subsequent files required by node with the extensions `.es6` and `.js` will +All subsequent files required by node with the extensions `.es6`, `.es` and `.js` will be transformed by 6to5. The polyfill specified in [Polyfill](polyfill.md) is also required; but this is automatically loaded when using: From 8c58e0f14c9f83600e557f7e8a4b9110c1711837 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 5 Jan 2015 16:43:00 +0800 Subject: [PATCH 3/3] Add .es extension to util.canCompile --- lib/6to5/util.js | 2 +- test/util.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/6to5/util.js b/lib/6to5/util.js index 033fa3c3bb..c291d12abd 100644 --- a/lib/6to5/util.js +++ b/lib/6to5/util.js @@ -12,7 +12,7 @@ var _ = require("lodash"); exports.inherits = util.inherits; exports.canCompile = function (filename, altExts) { - var exts = altExts || [".js", ".jsx", ".es6"]; + var exts = altExts || [".js", ".jsx", ".es6", ".es"]; var ext = path.extname(filename); return _.contains(exts, ext); }; diff --git a/test/util.js b/test/util.js index 4d4913547d..4f2fead371 100644 --- a/test/util.js +++ b/test/util.js @@ -18,6 +18,10 @@ suite("util", function () { assert.ok(util.canCompile("/test.es6")); assert.ok(util.canCompile("/scripts/test.es6")); + assert.ok(util.canCompile("test.es")); + assert.ok(util.canCompile("/test.es")); + assert.ok(util.canCompile("/scripts/test.es")); + assert.ok(!util.canCompile("test")); assert.ok(!util.canCompile("test.css")); assert.ok(!util.canCompile("/test.css"));