Skip to content

Commit

Permalink
[wip] revert compling cache-dir and remove non standard code from cac…
Browse files Browse the repository at this point in the history
…he-dir (#6183)

* dont transpile cache-dir - just remove flow types

* flow-remove-types doesnt support optional chaining

* format

* move cache-dir back to root Gatsby dir, remove flow used in prefetcher.js

* cleanup package.json

* update yarn.lock

* run tests in gatsby/cache-dir again

* test running babel with miminimal config on cache-dir

* doh, I don't need out-dir at all

* format .babelrc
  • Loading branch information
pieh authored and m-allanson committed Jul 2, 2018
1 parent 6ea82e2 commit 2fd9026
Show file tree
Hide file tree
Showing 36 changed files with 80 additions and 26 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pkgs = glob.sync(`./packages/*`).map(p => p.replace(/^\./, `<rootDir>`))

const reGatsby = /gatsby$/
const gatsbyDir = pkgs.find(p => reGatsby.exec(p))
const gatsbyBuildDirs = [`dist`, `cache-dir`].map(dir => path.join(gatsbyDir, dir))
const gatsbyBuildDirs = [`dist`].map(dir => path.join(gatsbyDir, dir))
const builtTestsDirs = pkgs.map(p => path.join(p, `__tests__`))

const ignoreDirs = [].concat(gatsbyBuildDirs, builtTestsDirs)
Expand Down
4 changes: 0 additions & 4 deletions packages/gatsby/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,3 @@ node_modules

decls
dist
cache-dir

# Never ignore the src cache-dir (https://github.com/gatsbyjs/gatsby/pull/5863)
!/src/cache-dir
File renamed without changes.
41 changes: 41 additions & 0 deletions packages/gatsby/cache-dir/__tests__/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
babelrc: false,
presets: [
[
"@babel/preset-env",
{
loose: true,
modules: false,
useBuiltIns: "usage",
shippedProposals: true,
targets: {
browsers: [">0.25%", "not dead"],
},
},
],
[
"@babel/preset-react",
{
useBuiltIns: true,
pragma: "React.createElement",
},
],
],
plugins: [
[
"@babel/plugin-proposal-class-properties",
{
loose: true,
},
],
"@babel/plugin-syntax-dynamic-import",
[
"@babel/plugin-transform-runtime",
{
helpers: true,
regenerator: true,
polyfill: false,
},
],
],
}
30 changes: 30 additions & 0 deletions packages/gatsby/cache-dir/__tests__/minimal-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const path = require(`path`)
const child = require(`child_process`)

it(`Builds cache-dir with minimal config`, done => {
const args = [
require.resolve(`@babel/cli/bin/babel.js`),
path.join(__dirname, `..`),
`--config-file`,
path.join(__dirname, `.babelrc`),
]

const spawn = child.spawn(process.execPath, args)

let stderr = ``
let stdout = ``

spawn.stderr.on(`data`, function (chunk) {
stderr += chunk
})

spawn.stdout.on(`data`, function (chunk) {
stdout += chunk
})

spawn.on(`close`, function () {
expect(stderr).toEqual(``)
expect(stdout).not.toEqual(``)
done()
})
}, 30000)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import PageRenderer from "./page-renderer"
import { StaticQueryContext } from "gatsby"
import socketIo, { getStaticQueryData, getPageQueryData } from "./socketIo"

const getPathFromProps = props => props.pageResources?.page?.path
const getPathFromProps = props =>
props.pageResources && props.pageResources.page
? props.pageResources.page.path
: undefined

class JSONStore extends React.Component {
constructor(props) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
// @flow

type PrefetcherOptions = {
fetchNextResource: () => ?Promise,
}

module.exports = ({ fetchNextResource }: PrefetcherOptions) => {
module.exports = ({ fetchNextResource }) => {
let pagesLoading = []
let current = null
const clearCurrent = () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 3 additions & 7 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
"cross-env": "^5.1.4",
"jest": "^22.4.3",
"lerna": "^2.9.0",
"npm-run-all": "4.1.2",
"nyc": "^7.0.0",
"rimraf": "^2.6.1"
},
Expand Down Expand Up @@ -179,17 +178,14 @@
"graphql": "^0.13.2"
},
"scripts": {
"build": "rimraf dist && rimraf cache-dir && npm-run-all -p build:*",
"build:cache-dir": "babel src/cache-dir --out-dir cache-dir",
"build": "rimraf dist && npm run build:src && npm run build:internal-plugins && npm run build:rawfiles",
"build:internal-plugins": "copyfiles -u 1 src/internal-plugins/**/package.json dist",
"build:rawfiles": "copyfiles -u 1 src/internal-plugins/**/raw_* dist",
"build:src": "babel src --out-dir dist --source-maps --ignore **/gatsby-cli.js,**/raw_*,**/__tests__,**/cache-dir",
"build:src": "babel src --out-dir dist --source-maps --ignore **/gatsby-cli.js,**/raw_*,**/__tests__",
"clean-test-bundles": "find test/ -type f -name bundle.js* -exec rm -rf {} +",
"prepare": "cross-env NODE_ENV=production npm run build",
"test-coverage": "node_modules/.bin/nyc --reporter=lcov --reporter=text npm test",
"watch": "rimraf dist && rimraf cache-dir && mkdir dist && npm run build:internal-plugins && npm run build:rawfiles && npm-run-all -p watch:*",
"watch:cache-dir": "npm run build:cache-dir -- --watch",
"watch:src": "npm run build:src -- --watch"
"watch": "rimraf dist && mkdir dist && npm run build:internal-plugins && npm run build:rawfiles && npm run build:src -- --watch"
},
"types": "index.d.ts"
}
6 changes: 0 additions & 6 deletions packages/gatsby/src/cache-dir/.babelrc

This file was deleted.

0 comments on commit 2fd9026

Please sign in to comment.