Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix moduleAttributesVersion errors with stage-0 preset in babel stand…
…alone (#11631) * Fix moduleAttributesVersion errors with stage-0 preset in babel standalone * Add regression test for stage-0 not erroring on missing moduleattributes version * Remove moduleAttributesVersion from preset config
- Loading branch information
Showing
4 changed files
with
49 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,48 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>babel-standalone example</title> | ||
</head> | ||
<body> | ||
Input: | ||
<textarea id="input" style="width: 100%" rows="10"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>babel-standalone example</title> | ||
</head> | ||
<body> | ||
Input: | ||
<textarea id="input" style="width: 100%" rows="10"> | ||
const getMessage = () => 'Hello World'; | ||
const someDiv = <div>{getMessage()}</div>; | ||
</textarea> | ||
</textarea | ||
> | ||
|
||
Transformed code using Babel <strong id="version"></strong>: | ||
<pre id="output">Loading...</pre> | ||
Transformed code using Babel <strong id="version"></strong>: | ||
<pre id="output">Loading...</pre> | ||
|
||
<script src="../babel.js"></script> | ||
<script> | ||
console.log('Babel =', Babel); | ||
document.getElementById('version').innerHTML = Babel.version; | ||
var inputEl = document.getElementById('input'); | ||
var outputEl = document.getElementById('output'); | ||
<script src="../babel.js"></script> | ||
<script> | ||
console.log("Babel =", Babel); | ||
document.getElementById("version").innerHTML = Babel.version; | ||
var inputEl = document.getElementById("input"); | ||
var outputEl = document.getElementById("output"); | ||
|
||
function transform() { | ||
try { | ||
outputEl.innerHTML = Babel.transform(inputEl.value, { | ||
presets: ['es2015', 'react', 'stage-0'] | ||
}).code; | ||
} catch (ex) { | ||
outputEl.innerHTML = 'ERROR: ' + ex.message; | ||
function transform() { | ||
try { | ||
outputEl.innerHTML = Babel.transform(inputEl.value, { | ||
presets: [ | ||
"es2015", | ||
"react", | ||
[ | ||
"stage-0", | ||
{ | ||
decoratorsBeforeExport: false, | ||
}, | ||
], | ||
], | ||
}).code; | ||
} catch (ex) { | ||
outputEl.innerHTML = "ERROR: " + ex.message; | ||
} | ||
} | ||
} | ||
|
||
inputEl.addEventListener('keyup', transform, false); | ||
transform(); | ||
</script> | ||
</body> | ||
inputEl.addEventListener("keyup", transform, false); | ||
transform(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters