Skip to content

Commit

Permalink
Merge pull request #1114 from stealjs/keep-es2015
Browse files Browse the repository at this point in the history
Add option to keep ES2015 code in built code
  • Loading branch information
m-mujica committed Mar 5, 2019
2 parents 22cadf6 + 089fa13 commit 8cbc6aa
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/graph/transpile.js
Expand Up @@ -47,7 +47,9 @@ var transpileNode = function(node, outputFormat, options, graph, loader){
}

transformActiveSource(node, key(options, outputFormat), function(node, source){
var opts = Object.assign({}, options);
var opts = Object.assign({}, options, {
forceES5: loader.forceES5 !== false
});
var depMap = nodeDependencyMap(node);

// this options is used by steal-tools transform
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -31,14 +31,14 @@
"prettier": "1.12.0",
"pump": "^3.0.0",
"rollup-plugin-commonjs": "^9.1.3",
"steal": "^2.1.10",
"steal": "^2.2.0",
"steal-bundler": "^0.3.6",
"steal-parse-amd": "^1.0.0",
"steal-rollup": "^0.58.4",
"through2": "^3.0.0",
"tmp": "0.0.33",
"traceur": "0.0.111",
"transpile": "^2.6.1",
"transpile": "^2.7.0",
"uglify-es": "3.1.3",
"urix": "^0.1.0",
"winston": "^2.2.0",
Expand Down
4 changes: 4 additions & 0 deletions test/keep_es2015/config.js
@@ -0,0 +1,4 @@
steal.config({
forceES5: false,
treeShaking: false
});
3 changes: 3 additions & 0 deletions test/keep_es2015/main.js
@@ -0,0 +1,3 @@
async function callMe() {}

export default callMe;
26 changes: 26 additions & 0 deletions test/multibuild_test.js
Expand Up @@ -2304,4 +2304,30 @@ describe("multi build", function(){
done();
}, done).catch(done);
});

it("skips ES2015 transpilation if data.loader.forceES5 is false", function() {
var config = {
config: path.join(__dirname, "keep_es2015", "config.js"),
main: "main"
};

var options = {
minify: false,
quiet: true
};

return asap(rmdir)(path.join(__dirname, "keep_es2015", "dist"))
.then(function() {
return multiBuild(config, options);
})
.then(function() {
var main = path.join(__dirname, "keep_es2015", "dist", "bundles", "main.js");
var actualJS = fs.readFileSync(main, "utf8");

assert(
actualJS.includes("async function callMe()"),
"source should include async function untranspiled"
);
});
});
});

0 comments on commit 8cbc6aa

Please sign in to comment.