Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade babel@7 #3785

Merged
merged 11 commits into from
Feb 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .babel-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const r = m => require.resolve(m)

function preset(context, options = {}) {
const { browser = false, debug = false } = options
const { NODE_ENV, BABEL_ENV } = process.env

const PRODUCTION = (BABEL_ENV || NODE_ENV) === "production"

const browserConfig = {
useBuiltIns: false,
targets: {
browsers: PRODUCTION
? [`last 4 versions`, `safari >= 7`, "ie >= 9"]
: [`last 2 versions`, `not ie <= 11`, `not android 4.4.3`],
},
}

const nodeConfig = {
targets: {
node: PRODUCTION ? 4.0 : "current",
},
}

return {
presets: [
[
r("@babel/preset-env"),
Object.assign(
{
loose: true,
debug: !!debug,
useBuiltIns: "entry",
shippedProposals: true,
sourceType: "unambiguous",
modules: "commonjs",
},
browser ? browserConfig : nodeConfig
),
],
[r("@babel/preset-react"), { development: !PRODUCTION }],
r("@babel/preset-flow"),
],
plugins: [
r("@babel/plugin-proposal-class-properties"),
[
r("@babel/plugin-transform-runtime"),
{
// we are only polyfilling the node environment
// so we need to enable the runtime replacements for the browser preset
polyfill: !!browser,
},
],
],
}
}

module.exports = preset
12 changes: 0 additions & 12 deletions .babelrc

This file was deleted.

64 changes: 10 additions & 54 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,13 @@
const r = m => require.resolve(m)
let ignore = [`**/dist/**`]

function preset(context, options = {}) {
const { browser = false, debug = false } = options
const { NODE_ENV, BABEL_ENV } = process.env

const PRODUCTION = (BABEL_ENV || NODE_ENV) === "production"

const browserConfig = {
useBuiltIns: false,
targets: {
browsers: PRODUCTION
? [`last 4 versions`, `safari >= 7`, "ie >= 9"]
: [`last 2 versions`, `not ie <= 11`, `not android 4.4.3`],
uglify: PRODUCTION,
},
}

const nodeConfig = {
targets: {
node: PRODUCTION ? 4.0 : "current",
},
}

return {
presets: [
[
r("babel-preset-env"),
Object.assign(
{
loose: true,
debug: !!debug,
useBuiltIns: true,
modules: "commonjs",
},
browser ? browserConfig : nodeConfig
),
],
r("babel-preset-react"),
r("babel-preset-flow"),
],
plugins: [
r("babel-plugin-transform-object-rest-spread"),
[
r("babel-plugin-transform-runtime"),
{
// we are only polyfilling the node environment
// so we need to enable the runtime replacements for the browser preset
polyfill: !!browser,
},
],
r(`babel-plugin-transform-flow-strip-types`),
],
}
// Jest needs to compile this code, but generally we don't want this copied
// to output folders
if (process.env !== `test`) {
ignore.push(`**/__tests__/**`)
}

module.exports = preset
module.exports = {
sourceMaps: true,
presets: [`./.babel-preset.js`],
ignore,
}
28 changes: 11 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.39",
"@babel/plugin-transform-runtime": "^7.0.0-beta.38",
"@babel/preset-env": "^7.0.0-beta.38",
"@babel/preset-flow": "^7.0.0-beta.38",
"@babel/preset-react": "^7.0.0-beta.38",
"@babel/runtime": "^7.0.0-beta.38",
"babel-core": "^7.0.0-0",
"babel-eslint": "^8.2.1",
"babel-jest": "^20.0.3",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"babel-runtime": "^6.26.0",
"babel-jest": "^22.2.0",
"chokidar": "^1.7.0",
"cross-env": "^5.0.5",
"eslint": "^4.5.0",
Expand All @@ -27,8 +22,7 @@
"eslint-plugin-react": "^7.3.0",
"flow-bin": "^0.42.0",
"glob": "^7.1.1",
"jest": "^20.0.4",
"jest-cli": "^20.0.4",
"jest": "^22.2.1",
"lerna": "^2.1.1",
"plop": "^1.8.1",
"prettier": "^1.9.2",
Expand All @@ -43,7 +37,7 @@
"private": true,
"scripts": {
"bootstrap": "yarn && npm run check-versions && lerna run prepublish",
"check-versions": "babel-node scripts/check-versions.js",
"check-versions": "node scripts/check-versions.js",
"format": "npm run format-packages && npm run format-cache-dir && npm run format-www && npm run format-examples && npm run format-scripts && npm run format-markdown",
"format-cache-dir": "prettier-eslint --write \"packages/gatsby/cache-dir/*.js\"",
"format-examples": "prettier-eslint --write \"examples/**/gatsby-node.js\" \"examples/**/gatsby-config.js\" \"examples/**/src/**/*.js\"",
Expand All @@ -54,7 +48,7 @@
"jest": "jest",
"lerna": "lerna",
"lint": "eslint --ext .js,.jsx packages/**/src",
"lint:flow": "babel-node scripts/flow-check.js",
"lint:flow": "node scripts/flow-check.js",
"plop": "plop",
"publish": "lerna publish",
"publish-canary": "lerna publish --canary --yes",
Expand Down
7 changes: 4 additions & 3 deletions packages/babel-plugin-remove-graphql-queries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
"build": "babel src --out-dir . --ignore **/__tests__/**",
"watch": "babel -w src --out-dir . --ignore **/__tests__/**"
},
"peerDependencies": {
"graphql": "^0.11.7"
},
"devDependencies": {
"babel-cli": "^6.26.0"
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38"
},
"author": "Jason Quense <monastic.panic@gmail.com>",
"license": "MIT"
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-1-config-css-modules/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*.js
!src/index.js
/__tests__
yarn.lock
9 changes: 5 additions & 4 deletions packages/gatsby-1-config-css-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "CSS Modules configuration for Gatsby v1 plugins",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__",
"build": "babel src --out-dir . --ignore **/__tests__/**",
"watch": "babel -w src --out-dir . --ignore **/__tests__/**",
"prepublish": "cross-env NODE_ENV=production npm run build"
},
"keywords": [
Expand All @@ -14,10 +14,11 @@
"author": "Ming Aldrich-Gan <mingaldrichgan@gmail.com>",
"license": "MIT",
"dependencies": {
"babel-runtime": "^6.26.0"
"@babel/runtime": "^7.0.0-beta.38"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38",
"cross-env": "^5.0.5"
}
}
11 changes: 6 additions & 5 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"lib"
],
"dependencies": {
"babel-code-frame": "^6.26.0",
"babel-runtime": "^6.26.0",
"@babel/code-frame": "^7.0.0-beta.38",
"@babel/runtime": "^7.0.0-beta.38",
"bluebird": "^3.5.0",
"common-tags": "^1.4.0",
"convert-hrtime": "^2.0.0",
Expand All @@ -29,7 +29,8 @@
"yurnalist": "^0.2.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38",
"cross-env": "^5.0.5"
},
"keywords": [
Expand All @@ -38,8 +39,8 @@
"license": "MIT",
"main": "lib/index.js",
"scripts": {
"build": "babel src --out-dir lib --ignore __tests__",
"watch": "babel -w src --out-dir lib --ignore __tests__",
"build": "babel src --out-dir lib --ignore **/__tests__/**",
"watch": "babel -w src --out-dir lib --ignore **/__tests__/**",
"prepublish": "cross-env NODE_ENV=production npm run build"
}
}
2 changes: 1 addition & 1 deletion packages/gatsby-cli/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// babel-preset-env doesn't find this import if you
// use require() with backtick strings so use the es6 syntax
import "babel-polyfill"
import "@babel/polyfill"

const createCli = require(`./create-cli`)
const report = require(`./reporter`)
Expand Down
5 changes: 3 additions & 2 deletions packages/gatsby-dev-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime": "^7.0.0-beta.38",
"chokidar": "^1.7.0",
"configstore": "^3.1.0",
"fs-extra": "^4.0.1",
Expand All @@ -13,7 +13,8 @@
"description": "CLI helpers for contributors working on Gatsby",
"main": "index.js",
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38",
"cross-env": "^5.0.5"
},
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-image/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": [
["../../.babelrc.js", { "browser": true }]
["../../.babel-preset.js", { "browser": true }]
]
}
9 changes: 5 additions & 4 deletions packages/gatsby-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Lazy-loading React image component with optional support for the blur-up effect.",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__",
"build": "babel src --out-dir . --ignore **/__tests__/**",
"watch": "babel -w src --out-dir . --ignore **/__tests__/**",
"prepublish": "cross-env NODE_ENV=production npm run build"
},
"keywords": [
Expand All @@ -16,11 +16,12 @@
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"license": "MIT",
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime": "^7.0.0-beta.38",
"prop-types": "^15.6.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38",
"cross-env": "^5.0.5"
}
}
Empty file removed packages/gatsby-image/src/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion packages/gatsby-link/.babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
["../../.babelrc.js", { "browser": true }]
["../../.babel-preset.js", { "browser": true }]
]
}

1 change: 1 addition & 0 deletions packages/gatsby-link/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/index.js
/__tests__
9 changes: 5 additions & 4 deletions packages/gatsby-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__",
"build": "babel src --out-dir . --ignore **/__tests__/**",
"watch": "babel -w src --out-dir . --ignore **/__tests__/**",
"prepublish": "cross-env NODE_ENV=production npm run build"
},
"keywords": [
Expand All @@ -16,12 +16,13 @@
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38",
"cross-env": "^5.0.5",
"react-router-dom": "^4.2.2"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime": "^7.0.0-beta.38",
"prop-types": "^15.5.8",
"ric": "^1.3.0"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-module-loader/.babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
["../../.babelrc.js", { "browser": true }]
["../../.babel-preset.js", { "browser": true }]
]
}

Loading