@@ -21,7 +21,7 @@ header = """
21
21
* CoffeeScript Compiler v#{ CoffeeScript .VERSION }
22
22
* https://coffeescript.org
23
23
*
24
- * Copyright 2011, Jeremy Ashkenas
24
+ * Copyright 2011- #{ new Date (). getFullYear () } , Jeremy Ashkenas
25
25
* Released under the MIT License
26
26
*/
27
27
"""
@@ -67,19 +67,20 @@ build = (callback) ->
67
67
buildExceptParser callback
68
68
69
69
transpile = (code , options = {}) ->
70
- options .minify = process .env .MINIFY isnt ' false'
71
- options .transform = process .env .TRANSFORM isnt ' false'
70
+ options .minify = process .env .MINIFY isnt ' false'
71
+ options .transform = process .env .TRANSFORM isnt ' false'
72
+ options .sourceType ?= ' script'
72
73
babel = require ' @babel/core'
73
74
presets = []
74
75
# Exclude the `modules` plugin in order to not break the `}(this));`
75
76
# at the end of the `build:browser` code block.
76
77
presets .push [' @babel/env' , {modules : no }] if options .transform
77
78
presets .push [' minify' , {mangle : no , evaluate : no , removeUndefined : no }] if options .minify
78
79
babelOptions =
80
+ presets : presets
79
81
compact : not options .minify
80
82
comments : not options .minify
81
- presets : presets
82
- sourceType : ' script'
83
+ sourceType : options .sourceType
83
84
{ code } = babel .transform code, babelOptions unless presets .length is 0
84
85
code
85
86
@@ -163,19 +164,24 @@ task 'build:browser', 'merge the built scripts into a single file for use in a b
163
164
}
164
165
}(this));
165
166
"""
166
- moduleCode = """
167
+ moduleCode = transpile """
167
168
#{ code}
168
169
169
170
export default CoffeeScript;
170
171
const { VERSION, compile, eval: evaluate, load, run, runScripts } = CoffeeScript;
171
172
export { VERSION, compile, evaluate as eval, load, run, runScripts };
172
- """
173
- for folder in [' browser-compiler' , ' browser-compiler-modern' ]
174
- outputFolder = " docs/v#{ majorVersion} /#{ folder} "
173
+ """ , {sourceType : ' module' }
174
+ outputFolders = [
175
+ " docs/v#{ majorVersion} /browser-compiler-legacy"
176
+ " docs/v#{ majorVersion} /browser-compiler-modern"
177
+ " lib/coffeescript-browser-compiler-legacy"
178
+ " lib/coffeescript-browser-compiler-modern"
179
+ ]
180
+ for outputFolder in outputFolders
175
181
fs .mkdirSync outputFolder unless fs .existsSync outputFolder
176
182
fs .writeFileSync " #{ outputFolder} /coffeescript.js" , """
177
183
#{ header}
178
- #{ if folder is ' browser-compiler ' then scriptCode else moduleCode}
184
+ #{ if outputFolder . includes ( ' legacy ' ) then scriptCode else moduleCode}
179
185
"""
180
186
181
187
task ' build:browser:full' , ' merge the built scripts into a single file for use in a browser, and test it' , ->
@@ -487,7 +493,7 @@ task 'test', 'run the CoffeeScript language test suite', ->
487
493
488
494
489
495
task ' test:browser' , ' run the test suite against the merged browser script' , ->
490
- source = fs .readFileSync " docs/v #{ majorVersion } / browser-compiler/coffeescript.js" , ' utf-8'
496
+ source = fs .readFileSync " lib/coffeescript- browser-compiler-legacy /coffeescript.js" , ' utf-8'
491
497
result = {}
492
498
global .testingBrowser = yes
493
499
(-> eval source).call result
0 commit comments