* Explicitly turn off minify mangling, because it was previously implicitly disabled by the existence of the `eval` call we’re about to remove * Update babel-core * Run browser-compiled scripts using window.eval rather than just eval, to use a clean scope (many times faster) * Update output * Fix browser-based test broken by #5028 * Update output
This commit is contained in:
parent
fe7554828a
commit
d82272b6c2
2
Cakefile
2
Cakefile
|
@ -72,7 +72,7 @@ transpile = (code) ->
|
||||||
# Exclude the `modules` plugin in order to not break the `}(this));`
|
# Exclude the `modules` plugin in order to not break the `}(this));`
|
||||||
# at the end of the `build:browser` code block.
|
# at the end of the `build:browser` code block.
|
||||||
presets.push ['env', {modules: no}] unless process.env.TRANSFORM is 'false'
|
presets.push ['env', {modules: no}] unless process.env.TRANSFORM is 'false'
|
||||||
presets.push 'minify' unless process.env.MINIFY is 'false'
|
presets.push ['minify', {mangle: no}] unless process.env.MINIFY is 'false'
|
||||||
babelOptions =
|
babelOptions =
|
||||||
compact: process.env.MINIFY isnt 'false'
|
compact: process.env.MINIFY isnt 'false'
|
||||||
presets: presets
|
presets: presets
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -148,6 +148,8 @@ diffOutput = (expectedOutput, actualOutput) ->
|
||||||
ok yes
|
ok yes
|
||||||
else if e.toString().indexOf('[stdin]') is 0 # Handle comparing error messages
|
else if e.toString().indexOf('[stdin]') is 0 # Handle comparing error messages
|
||||||
ok err e
|
ok err e
|
||||||
|
else if err instanceof RegExp
|
||||||
|
ok err.test e
|
||||||
else
|
else
|
||||||
eq e, err
|
eq e, err
|
||||||
else
|
else
|
||||||
|
|
|
@ -143,7 +143,7 @@ $(document).ready ->
|
||||||
else
|
else
|
||||||
$(textareas[index]).val()
|
$(textareas[index]).val()
|
||||||
js = "#{js}\nalert(#{unescape run});" unless run is yes
|
js = "#{js}\nalert(#{unescape run});" unless run is yes
|
||||||
eval js
|
window.eval js
|
||||||
gtag 'event', 'run_code',
|
gtag 'event', 'run_code',
|
||||||
event_category: 'engagement'
|
event_category: 'engagement'
|
||||||
event_label: $(@).closest('[data-example]').data('example')
|
event_label: $(@).closest('[data-example]').data('example')
|
||||||
|
|
|
@ -108,6 +108,8 @@ onFail = (description, fn, err) ->
|
||||||
ok yes
|
ok yes
|
||||||
else if e.toString().indexOf('[stdin]') is 0 # Handle comparing error messages
|
else if e.toString().indexOf('[stdin]') is 0 # Handle comparing error messages
|
||||||
ok err e
|
ok err e
|
||||||
|
else if err instanceof RegExp
|
||||||
|
ok err.test e
|
||||||
else
|
else
|
||||||
eq e, err
|
eq e, err
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,14 +9,19 @@
|
||||||
|
|
||||||
CoffeeScript = require('./coffeescript');
|
CoffeeScript = require('./coffeescript');
|
||||||
|
|
||||||
compile = CoffeeScript.compile;
|
({compile} = CoffeeScript);
|
||||||
|
|
||||||
// Use standard JavaScript `eval` to eval code.
|
// Use `window.eval` to evaluate code, rather than just `eval`, to run the
|
||||||
|
// script in a clean global scope rather than inheriting the scope of the
|
||||||
|
// CoffeeScript compiler. (So that `cake test:browser` also works in Node,
|
||||||
|
// use either `window.eval` or `global.eval` as appropriate).
|
||||||
CoffeeScript.eval = function(code, options = {}) {
|
CoffeeScript.eval = function(code, options = {}) {
|
||||||
|
var globalRoot;
|
||||||
if (options.bare == null) {
|
if (options.bare == null) {
|
||||||
options.bare = true;
|
options.bare = true;
|
||||||
}
|
}
|
||||||
return eval(compile(code, options));
|
globalRoot = typeof window !== "undefined" && window !== null ? window : global;
|
||||||
|
return globalRoot['eval'](compile(code, options));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Running code does not provide access to this scope.
|
// Running code does not provide access to this scope.
|
||||||
|
|
|
@ -167,9 +167,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"babel-core": {
|
"babel-core": {
|
||||||
"version": "6.26.2",
|
"version": "6.26.3",
|
||||||
"resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.2.tgz",
|
"resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz",
|
||||||
"integrity": "sha512-rFKFnHY8sbRSqja2O5eTx0z0Na5hukdtsFt7X9xdBFXMurrJ5YoY78Y/2/EuNZIaDQKEJSfxSMePfsymxt0CZg==",
|
"integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-code-frame": "6.26.0",
|
"babel-code-frame": "6.26.0",
|
||||||
|
@ -1509,7 +1509,7 @@
|
||||||
"integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=",
|
"integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-core": "6.26.2",
|
"babel-core": "6.26.3",
|
||||||
"babel-runtime": "6.26.0",
|
"babel-runtime": "6.26.0",
|
||||||
"core-js": "2.5.5",
|
"core-js": "2.5.5",
|
||||||
"home-or-tmp": "2.0.0",
|
"home-or-tmp": "2.0.0",
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
"url": "git://github.com/jashkenas/coffeescript.git"
|
"url": "git://github.com/jashkenas/coffeescript.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "~6.26.2",
|
"babel-core": "~6.26.3",
|
||||||
"babel-preset-babili": "~0.1.4",
|
"babel-preset-babili": "~0.1.4",
|
||||||
"babel-preset-env": "~1.6.1",
|
"babel-preset-env": "~1.6.1",
|
||||||
"babel-preset-minify": "^0.4.0",
|
"babel-preset-minify": "^0.4.0",
|
||||||
|
|
|
@ -4,12 +4,16 @@
|
||||||
# `text/coffeescript` script tags, source maps via data-URLs, and so on.
|
# `text/coffeescript` script tags, source maps via data-URLs, and so on.
|
||||||
|
|
||||||
CoffeeScript = require './coffeescript'
|
CoffeeScript = require './coffeescript'
|
||||||
compile = CoffeeScript.compile
|
{ compile } = CoffeeScript
|
||||||
|
|
||||||
# Use standard JavaScript `eval` to eval code.
|
# Use `window.eval` to evaluate code, rather than just `eval`, to run the
|
||||||
|
# script in a clean global scope rather than inheriting the scope of the
|
||||||
|
# CoffeeScript compiler. (So that `cake test:browser` also works in Node,
|
||||||
|
# use either `window.eval` or `global.eval` as appropriate).
|
||||||
CoffeeScript.eval = (code, options = {}) ->
|
CoffeeScript.eval = (code, options = {}) ->
|
||||||
options.bare ?= on
|
options.bare ?= on
|
||||||
eval compile code, options
|
globalRoot = if window? then window else global
|
||||||
|
globalRoot['eval'] compile code, options
|
||||||
|
|
||||||
# Running code does not provide access to this scope.
|
# Running code does not provide access to this scope.
|
||||||
CoffeeScript.run = (code, options = {}) ->
|
CoffeeScript.run = (code, options = {}) ->
|
||||||
|
|
Loading…
Reference in New Issue