diff --git a/Cakefile b/Cakefile index 5e9c6adf..00ddfc45 100644 --- a/Cakefile +++ b/Cakefile @@ -66,15 +66,18 @@ build = (callback) -> buildParser() buildExceptParser callback -transpile = (code) -> +transpile = (code, options = {}) -> + options.minify = process.env.MINIFY isnt 'false' + options.transform = process.env.TRANSFORM isnt 'false' babel = require '@babel/core' presets = [] # Exclude the `modules` plugin in order to not break the `}(this));` # at the end of the `build:browser` code block. - presets.push ['@babel/env', {modules: no}] unless process.env.TRANSFORM is 'false' - presets.push ['minify', {mangle: no, evaluate: no, removeUndefined: no}] unless process.env.MINIFY is 'false' + presets.push ['@babel/env', {modules: no}] if options.transform + presets.push ['minify', {mangle: no, evaluate: no, removeUndefined: no}] if options.minify babelOptions = - compact: process.env.MINIFY isnt 'false' + compact: not options.minify + comments: not options.minify presets: presets sourceType: 'script' { code } = babel.transform code, babelOptions unless presets.length is 0 @@ -140,13 +143,18 @@ task 'build:browser', 'merge the built scripts into a single file for use in a b return module.exports; })(); """ + # From here, we generate two outputs: a legacy script output for all browsers + # and a module output for browsers that support ` + - - + + + diff --git a/docs/v2/test.html b/docs/v2/test.html index e9ff2bf1..587fffe6 100644 --- a/docs/v2/test.html +++ b/docs/v2/test.html @@ -3,7 +3,12 @@ CoffeeScript Test Suite - + +