1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Upgrade to Babel 7 stable (#5042) (major)

🎉 https://twitter.com/left_pad/status/1034204330352500736
This commit is contained in:
Tim Neutkens 2018-08-28 12:44:15 +02:00 committed by GitHub
parent 66ec2061c1
commit 4c891a7e8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 590 additions and 484 deletions

View file

@ -42,6 +42,11 @@
"prepublish": "npm run release",
"precommit": "lint-staged"
},
"taskr": {
"requires": [
"./taskfile-babel.js"
]
},
"standard": {
"parser": "babel-eslint",
"ignore": [
@ -57,17 +62,17 @@
"bin/*": "standard"
},
"dependencies": {
"@babel/core": "7.0.0-rc.1",
"@babel/plugin-proposal-class-properties": "7.0.0-rc.1",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-rc.1",
"@babel/plugin-syntax-dynamic-import": "7.0.0-rc.1",
"@babel/plugin-transform-react-jsx-source": "7.0.0-rc.1",
"@babel/plugin-transform-runtime": "7.0.0-rc.1",
"@babel/preset-env": "7.0.0-rc.1",
"@babel/preset-react": "7.0.0-rc.1",
"@babel/runtime": "7.0.0-rc.1",
"@babel/runtime-corejs2": "7.0.0-rc.1",
"@babel/template": "7.0.0-rc.1",
"@babel/core": "7.0.0",
"@babel/plugin-proposal-class-properties": "7.0.0",
"@babel/plugin-proposal-object-rest-spread": "7.0.0",
"@babel/plugin-syntax-dynamic-import": "7.0.0",
"@babel/plugin-transform-react-jsx-source": "7.0.0",
"@babel/plugin-transform-runtime": "7.0.0",
"@babel/preset-env": "7.0.0",
"@babel/preset-react": "7.0.0",
"@babel/runtime": "7.0.0",
"@babel/runtime-corejs2": "7.0.0",
"@babel/template": "7.0.0",
"ansi-html": "0.0.7",
"autodll-webpack-plugin": "0.4.2",
"babel-core": "7.0.0-bridge.0",
@ -113,16 +118,15 @@
"write-file-webpack-plugin": "4.3.2"
},
"devDependencies": {
"@babel/preset-flow": "7.0.0-rc.1",
"@taskr/babel": "1.1.0-next.1",
"@babel/preset-flow": "7.0.0",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
"@zeit/next-css": "0.2.1-canary.1",
"@zeit/next-sass": "0.2.1-canary.1",
"@zeit/next-typescript": "1.1.0",
"babel-eslint": "8.2.2",
"babel-jest": "21.2.0",
"babel-eslint": "9.0.0",
"babel-jest": "23.4.2",
"benchmark": "2.1.4",
"cheerio": "0.22.0",
"chromedriver": "2.32.3",
@ -131,6 +135,7 @@
"cross-env": "5.0.5",
"express": "4.15.5",
"fkill": "5.1.0",
"flatten": "1.0.2",
"flow-bin": "0.73.0",
"get-port": "3.2.0",
"husky": "0.14.3",

65
taskfile-babel.js Normal file
View file

@ -0,0 +1,65 @@
// taskr babel plugin with Babel 7 support
// https://github.com/lukeed/taskr/pull/305
'use strict'
const transform = require('@babel/core').transform
const flatten = require('flatten')
const BABEL_REGEX = /(^@babel\/)(preset|plugin)-(.*)/i
function getBabels () {
const pkg = require('./package.json')
return flatten(
['devDependencies', 'dependencies'].map(s => Object.keys(pkg[s] || {}))
).filter(s => BABEL_REGEX.test(s))
}
module.exports = function (task) {
let cache
task.plugin('babel', {}, function * (file, opts) {
if (opts.preload) {
delete opts.preload
// get dependencies
cache = cache || getBabels()
// attach any deps to babel's `opts`
cache.forEach(dep => {
const segs = BABEL_REGEX.exec(dep)
const type = `${segs[2]}s`
const name = `@babel/${segs[2]}-${segs[3]}`
opts[type] = opts[type] || []
// flatten all (advanced entries are arrays)
if (flatten(opts[type]).indexOf(name) === -1) {
opts[type] = opts[type].concat(name)
}
})
}
// attach file's name
opts.filename = file.base
const output = transform(file.data, opts)
if (output.map) {
const map = `${file.base}.map`
// append `sourceMappingURL` to original file
if (opts.sourceMaps !== 'both') {
output.code += Buffer.from(`\n//# sourceMappingURL=${map}`)
}
// add sourcemap to `files` array
this._.files.push({
base: map,
dir: file.dir,
data: Buffer.from(JSON.stringify(output.map))
})
}
// update file's data
file.data = Buffer.from(output.code)
})
}

974
yarn.lock

File diff suppressed because it is too large Load diff