Merge branch 'core-js' into 2.0.0
Conflicts: lib/6to5/polyfill.js
This commit is contained in:
commit
fa71f2a7f9
@ -1,12 +1,11 @@
|
|||||||
# Polyfill
|
# Polyfill
|
||||||
|
|
||||||
6to5 includes a polyfill that includes the
|
6to5 includes a polyfill that includes a custom
|
||||||
[regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js) and the
|
[regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js) and
|
||||||
[es6-shim](https://github.com/paulmillr/es6-shim) and
|
[core.js](https://github.com/zloirock/core-js).
|
||||||
[es6-symbol](https://github.com/medikoo/es6-symbol) polyfills.
|
|
||||||
|
|
||||||
This will emulate a full ES6 environment. This polyfill is automatically loaded
|
This will emulate a full ES6 environment. This polyfill is automatically loaded
|
||||||
when using [6to5-node](usage.md#node).
|
when using [6to5-node](usage.md#node) and [6to5/register](usage.md#register-hook).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@ -1,53 +1,2 @@
|
|||||||
/* jshint newcap: false, freeze: false */
|
require("core-js/shim");
|
||||||
|
require("./transformation/transformers/es6-generators/runtime");
|
||||||
var ensureSymbol = function (key) {
|
|
||||||
Symbol[key] = Symbol[key] || Symbol(key);
|
|
||||||
};
|
|
||||||
|
|
||||||
var ensureProto = function (Constructor, key, val) {
|
|
||||||
var proto = Constructor.prototype;
|
|
||||||
if (!proto[key]) {
|
|
||||||
Object.defineProperty(proto, key, {
|
|
||||||
value: val
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
if (typeof Symbol === "undefined") {
|
|
||||||
require("es6-symbol/implement");
|
|
||||||
|
|
||||||
var globSymbols = {};
|
|
||||||
|
|
||||||
Symbol.for = function (key) {
|
|
||||||
return globSymbols[key] = globSymbols[key] || Symbol(key);
|
|
||||||
};
|
|
||||||
|
|
||||||
Symbol.keyFor = function (sym) {
|
|
||||||
return sym.__description__;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
require("es6-shim");
|
|
||||||
require("regenerator/runtime");
|
|
||||||
|
|
||||||
ensureSymbol("species");
|
|
||||||
|
|
||||||
// Abstract references
|
|
||||||
|
|
||||||
ensureSymbol("referenceGet");
|
|
||||||
ensureSymbol("referenceSet");
|
|
||||||
ensureSymbol("referenceDelete");
|
|
||||||
|
|
||||||
ensureProto(Function, Symbol.referenceGet, function () { return this; });
|
|
||||||
|
|
||||||
ensureProto(Map, Symbol.referenceGet, Map.prototype.get);
|
|
||||||
ensureProto(Map, Symbol.referenceSet, Map.prototype.set);
|
|
||||||
ensureProto(Map, Symbol.referenceDelete, Map.prototype.delete);
|
|
||||||
|
|
||||||
if (global.WeakMap) {
|
|
||||||
ensureProto(WeakMap, Symbol.referenceGet, WeakMap.prototype.get);
|
|
||||||
ensureProto(WeakMap, Symbol.referenceSet, WeakMap.prototype.set);
|
|
||||||
ensureProto(WeakMap, Symbol.referenceDelete, WeakMap.prototype.delete);
|
|
||||||
}
|
|
||||||
|
|||||||
@ -39,8 +39,7 @@
|
|||||||
"ast-types": "~0.6.1",
|
"ast-types": "~0.6.1",
|
||||||
"chokidar": "0.11.1",
|
"chokidar": "0.11.1",
|
||||||
"commander": "2.5.0",
|
"commander": "2.5.0",
|
||||||
"es6-shim": "0.21.0",
|
"core-js": "^0.2.2",
|
||||||
"es6-symbol": "0.1.1",
|
|
||||||
"estraverse": "1.8.0",
|
"estraverse": "1.8.0",
|
||||||
"esutils": "1.1.6",
|
"esutils": "1.1.6",
|
||||||
"fs-readdir-recursive": "0.1.0",
|
"fs-readdir-recursive": "0.1.0",
|
||||||
|
|||||||
@ -7,6 +7,8 @@ var chai = require("chai");
|
|||||||
var util = require("../lib/6to5/util");
|
var util = require("../lib/6to5/util");
|
||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
|
|
||||||
|
require("../lib/6to5/polyfill");
|
||||||
|
|
||||||
var run = function (task, done) {
|
var run = function (task, done) {
|
||||||
var actual = task.actual;
|
var actual = task.actual;
|
||||||
var expect = task.expect;
|
var expect = task.expect;
|
||||||
@ -26,8 +28,6 @@ var run = function (task, done) {
|
|||||||
result = transform(execCode, getOpts(exec));
|
result = transform(execCode, getOpts(exec));
|
||||||
execCode = result.code;
|
execCode = result.code;
|
||||||
|
|
||||||
require("../lib/6to5/polyfill");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var fn = new Function("assert", "done", "genHelpers", execCode);
|
var fn = new Function("assert", "done", "genHelpers", execCode);
|
||||||
fn(assert, done, genHelpers);
|
fn(assert, done, genHelpers);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user