Created
September 30, 2018 21:36
-
-
Save AoiYamada/d8e8a84fcf99bb0f0334944914dfeaab to your computer and use it in GitHub Desktop.
Babel 6 setting to support IE 9+
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
Show hidden characters
// http://imweb.io/topic/59dc5a8b856028aa249e2a58 | |
// https://segmentfault.com/a/1190000006930013 | |
// 總之,IE真的是毒瘤... | |
{ | |
"presets": [ | |
["es2015", | |
{ | |
"loose": true | |
}], | |
"stage-0" | |
], | |
"plugins": [ | |
[ | |
"transform-builtin-extend", | |
{ | |
"globals": ["Array"], | |
"approximate": false | |
}, | |
"transform-es2015-destructuring" | |
], | |
"transform-es3-member-expression-literals", | |
"transform-es3-property-literals" | |
] | |
} |
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
{ | |
"name": "", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "nyc mocha --recursive \"./{,!(node_modules)/**/}*spec.js\" -s 3", | |
"build": "browserify browser.js -o ./dist/build.js -t babelify", | |
"build-testcases": "browserify browser-test.js -o ./dist/testcases.js -t babelify" | |
}, | |
"author": "Yamada246", | |
"license": "ISC", | |
"devDependencies": { | |
"babel-core": "^6.26.3", | |
"babel-plugin-transform-builtin-extend": "^1.1.2", | |
"babel-plugin-transform-es2015-destructuring": "^6.23.0", | |
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0", | |
"babel-plugin-transform-es3-property-literals": "^6.22.0", | |
"babel-preset-es2015": "^6.24.1", | |
"babel-preset-stage-0": "^6.24.1", | |
"babelify": "^8.0.0", | |
"browserify": "^16.2.0", | |
"chai": "^4.1.2", | |
"core-js": "^2.5.7", | |
"mocha": "^5.1.1", | |
"nyc": "^12.0.1" | |
} | |
} |
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
// https://github.com/angular/angular/issues/24488 | |
(function() { | |
Object.setPrototypeOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties); | |
function setProtoOf(obj, proto) { | |
obj.__proto__ = proto; | |
return obj; | |
} | |
function mixinProperties(obj, proto) { | |
for (const prop in proto) { | |
if (!obj.hasOwnProperty(prop)) { | |
obj[prop] = proto[prop]; | |
} | |
} | |
return obj; | |
} | |
})(); | |
require('core-js'); |
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
// https://stackoverflow.com/questions/3895478/does-javascript-have-a-method-like-range-to-generate-a-range-within-the-supp | |
function range(start = 0, end = start + 1) { | |
// return [...Array(end - start).keys()].map(i => i + start); | |
// Destructing not work for iterator in babel 6 | |
const iterator = Array(end - start).keys(); | |
const result = []; | |
for (const v of iterator) { | |
result.push(v); | |
} | |
return result.map(i => i + start); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment