Skip to content

Commit

Permalink
Merge pull request #662 from adamnoakes/babel_7_stable
Browse files Browse the repository at this point in the history
Update to babel 7 stable
  • Loading branch information
orta committed Sep 13, 2018
2 parents 7c7cb26 + 41d9842 commit b2366f8
Show file tree
Hide file tree
Showing 5 changed files with 798 additions and 605 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"presets": ["es2015", "stage-3"],
"plugins": ["syntax-async-functions", "transform-regenerator", "transform-flow-strip-types"]
"presets": [["@babel/preset-env", { "targets": { "node": "6" }, "useBuiltIns": "usage" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"]
}
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
},
"homepage": "https://github.com/danger/danger-js#readme",
"devDependencies": {
"@babel/cli": "7.0.0",
"@babel/core": "7.0.0",
"@babel/plugin-transform-flow-strip-types": "7.0.0",
"@babel/plugin-transform-typescript": "7.0.0",
"@babel/preset-env": "7.0.0",
"@babel/traverse": "7.0.0",
"@types/debug": "0.0.30",
"@types/get-stdin": "^5.0.1",
"@types/jest": "^23.3.1",
Expand All @@ -103,15 +109,6 @@
"@types/p-limit": "^1.1.2",
"@types/readline-sync": "^1.4.3",
"@types/voca": "^1.4.0",
"babel-cli": "7.0.0-alpha.19",
"babel-core": "7.0.0-alpha.19",
"babel-plugin-syntax-async-functions": "7.0.0-alpha.19",
"babel-plugin-transform-flow-strip-types": "7.0.0-alpha.19",
"babel-plugin-transform-regenerator": "7.0.0-alpha.19",
"babel-plugin-transform-typescript": "7.0.0-alpha.19",
"babel-preset-es2015": "7.0.0-alpha.19",
"babel-preset-stage-3": "7.0.0-alpha.19",
"babel-traverse": "7.0.0-alpha.19",
"danger-plugin-jest": "^1.0.1",
"danger-plugin-yarn": "^1.3.0",
"date-fns": "^1.29.0",
Expand All @@ -132,8 +129,8 @@
"typescript": "^3.0.1"
},
"dependencies": {
"@babel/polyfill": "^7.0.0",
"@octokit/rest": "^15.9.5",
"babel-polyfill": "^6.23.0",
"chalk": "^2.3.0",
"commander": "^2.13.0",
"debug": "^3.1.0",
Expand Down
2 changes: 0 additions & 2 deletions source/runner/_tests/fixtures/__DangerfileAsync.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "babel-polyfill"

const asyncAction = () =>
new Promise(res => {
setTimeout(() => {
Expand Down
12 changes: 6 additions & 6 deletions source/runner/runners/utils/transpiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ export const checkForNodeModules = () => {
}

try {
require.resolve("babel-core") // tslint:disable-line
require("babel-polyfill") // tslint:disable-line
require.resolve("@babel/core") // tslint:disable-line
require("@babel/polyfill") // tslint:disable-line
hasBabel = true

try {
require.resolve("babel-plugin-transform-typescript") // tslint:disable-line
require.resolve("@babel/plugin-transform-typescript") // tslint:disable-line
hasBabelTypeScript = true
} catch (e) {
d("Does not have Babel 7 TypeScript set up")
}

try {
require.resolve("babel-plugin-transform-flow-strip-types") // tslint:disable-line
require.resolve("@babel/plugin-transform-flow-strip-types") // tslint:disable-line
hasFlow = true
} catch (e) {
d("Does not have Flow set up")
Expand Down Expand Up @@ -76,7 +76,7 @@ const sanitizeTSConfig = (config: any) => {
}

export const babelify = (content: string, filename: string, extraPlugins: string[]): string => {
const babel = require("babel-core") // tslint:disable-line
const babel = require("@babel/core") // tslint:disable-line
if (!babel.transform) {
return content
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export default (code: string, filename: string) => {
} else if (hasBabel && hasBabelTypeScript && filetype.startsWith(".ts")) {
result = babelify(code, filename, ["transform-typescript"])
} else if (hasBabel && filetype.startsWith(".js")) {
result = babelify(code, filename, hasFlow ? ["transform-flow-strip-types"] : [])
result = babelify(code, filename, hasFlow ? ["@babel/plugin-transform-flow-strip-types"] : [])
}

return result
Expand Down

0 comments on commit b2366f8

Please sign in to comment.