Skip to content

Commit

Permalink
Simplify node babel and move cache-dir (gatsbyjs#1757)
Browse files Browse the repository at this point in the history
* Simplify node babel and move cache-dir

* ignore tests in build

* fix tests

* add back lock file

* Add missing .gitignore

* Also delete index.js

* Format
  • Loading branch information
jquense authored and KyleAMathews committed Aug 11, 2017
1 parent 6eddf77 commit 5728c6b
Show file tree
Hide file tree
Showing 58 changed files with 471 additions and 583 deletions.
26 changes: 1 addition & 25 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
{
"sourceMaps": true,
// "env": {
// "development": {
// "sourceMaps": "inline"
// },
// "production": {
// "sourceMaps": false
// }
// },
"presets": [
[
"env",
{
"targets": {
"node": 4.0,
"uglify": true,
}
}
],
"react",
"flow"
],
"plugins": [
"transform-runtime",
"transform-object-rest-spread",
"transform-async-to-generator",
"transform-flow-strip-types"
"./.babelrc.js"
]
}
37 changes: 37 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const r = m => require.resolve(m)

function preset(_, options = {}) {
const PRODUCTION = process.env.NODE_ENV === "production"

return {
presets: [
[
r("babel-preset-env"),
{
loose: true,
debug: !!options.debug,
modules: "commonjs",
targets: {
node: PRODUCTION ? 4.0 : "current",
uglify: PRODUCTION ? true : false,
},
},
],
r("babel-preset-react"),
r("babel-preset-flow"),
],
plugins: [
r("babel-plugin-transform-object-rest-spread"),
[
r("babel-plugin-transform-runtime"),
{
polyfill: false,
regenerator: false,
},
],
r(`babel-plugin-transform-flow-strip-types`),
],
}
}

module.exports = preset
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"babel-register": "^6.24.1",
"babel-runtime": "^6.23.0",
"create-react-class": "^15.6.0",
"cross-env": "^5.0.5",
"eslint": "^4.2.0",
"eslint-config-google": "^0.9.1",
"eslint-config-prettier": "^2.3.0",
Expand Down Expand Up @@ -42,25 +43,25 @@
},
"private": true,
"scripts": {
"build": "lerna run build",
"build": "cross-env NODE_ENV=production lerna run build",
"check-versions": "babel-node scripts/check-versions.js",
"format": "npm run format-packages && npm run format-www && npm run format-examples && npm run format-scripts",
"format-examples": "prettier-eslint --write \"examples/**/gatsby-node.js\" \"examples/**/src/**/*.js\"",
"format-packages": "prettier-eslint --write \"packages/*/src/**/*.js\"",
"format-scripts": "prettier-eslint --write \"scripts/**/*.js\"",
"format-www": "prettier-eslint --write \"www/*.js\" \"www/src/**/*.js\"",
"lerna": "lerna",
"check-versions": "babel-node scripts/check-versions.js",
"lint": "npm run check-versions && eslint --ext .js,.jsx --ignore-path .gitignore .",
"lint:flow": "babel-node scripts/flow-check.js",
"plop": "plop",
"postinstall": "npm run check-versions && lerna bootstrap",
"publish": "npm run build && lerna publish",
"publish-canary": "lerna run build && lerna publish --canary --yes",
"publish-next": "lerna run build && lerna publish --npm-tag=next",
"publish": "lerna run build && lerna publish",
"remotedev": "remotedev --hostname=localhost --port=19999",
"test": "jest",
"test:watch": "jest --watch",
"test:update": "jest --updateSnapshot",
"test:watch": "jest --watch",
"test_bkup": "npm run lint && npm run test-node && npm run test-integration",
"watch": "lerna run watch --no-sort --stream --concurrency 999"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-dev-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ function watch(root, packages, { scanOnce, quiet }) {
copyPath(path, newPath, quiet)

// If this is from "cache-dir" also copy it into the site's .cache
if (_.includes(path, `dist/cache-dir`)) {
if (_.includes(path, `cache-dir`)) {
const newCachePath = syspath.join(
`.cache/`,
syspath.relative(syspath.join(prefix, `dist`, `cache-dir`), path)
syspath.relative(syspath.join(prefix, `cache-dir`), path)
)
copyPath(path, newCachePath, quiet)
}
Expand Down
4 changes: 2 additions & 2 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 .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-catch-links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Intercepts local links from markdown and other non-react pages and does a client-side pushState to avoid the browser having to refresh the page.",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-coffeescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"main": "index.js",
"readme": "README.md",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-feed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Creates an RSS feed for your Gatsby site.",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-glamor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-google-tagmanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Gatsby plugin which adds a manifest.json to make sites progressive web apps",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-offline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"dependencies": {
"sw-precache": "^5.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-postcss-sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"main": "index.js",
"readme": "README.md",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "A Gatsby plugin which replaces React with Preact",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"main": "index.js",
"readme": "README.md",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-stylus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"main": "./gatsby-node.js",
"readme": "README.md",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-remark-autolink-headers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-remark-copy-linked-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-remark-images/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"gatsby-plugin-sharp": "^1.6.0"
},
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
}
}
3 changes: 3 additions & 0 deletions packages/gatsby-remark-katex/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/index.js
/__tests__/*
tests
4 changes: 2 additions & 2 deletions packages/gatsby-remark-responsive-iframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Make iframes in Markdown processed by Remark responsive",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-remark-smartypants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Use retext-smartypants to auto-enhance typography of markdown",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ Object {
`;

exports[`Process contentful data builds list of resolvable data 1`] = `
Array [
Set {
"c7LAnCobuuWYSqks6wAwY2a",
"c24DPGBDeGEaYy8ms4Y8QMQ",
"c651CQ8rLoIYCeY6G0QG22q",
Expand All @@ -1620,7 +1620,7 @@ Array [
"wtrHxeu3zEoEce2MokCSi",
"c10TkaLheGeQG6qQGqWYqUI",
"c6s3iG2OVmoUcosmA8ocqsG",
]
}
`;

exports[`Process contentful data creates nodes for each asset 1`] = `
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-drupal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.3.0",
"description": "Gatsby source plugin for building websites using the Drupal CMS as a data source",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-filesystem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.4.1",
"description": "Gatsby plugin which parses files within a directory for further parsing by other plugins",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-hacker-news/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.0.1",
"description": "Gatsby source plugin for building websites using Hacker News as a data source",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"keywords": [
"gatsby",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-wordpress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"license": "MIT",
"name": "gatsby-source-wordpress",
"scripts": {
"build": "babel src --out-dir .",
"watch": "babel -w src --out-dir ."
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
},
"version": "1.7.2"
}
Loading

0 comments on commit 5728c6b

Please sign in to comment.