Skip to content
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
14 changes: 14 additions & 0 deletions packages/gatsby/cache-dir/api-runner-browser-plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// During bootstrap, we write requires at top of this file which looks
// basically like:
// module.exports = [
// {
// plugin: require("/path/to/plugin1/gatsby-browser.js"),
// options: { ... },
// },
// {
// plugin: require("/path/to/plugin2/gatsby-browser.js"),
// options: { ... },
// },
// ]

module.exports = []
15 changes: 1 addition & 14 deletions packages/gatsby/cache-dir/api-runner-browser.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
// During bootstrap, we write requires at top of this file which looks
// basically like:
// var plugins = [
// {
// plugin: require("/path/to/plugin1/gatsby-browser.js"),
// options: { ... },
// },
// {
// plugin: require("/path/to/plugin2/gatsby-browser.js"),
// options: { ... },
// },
// ]
const plugins = require(`./api-runner-browser-plugins`)

exports.apiRunner = (api, args, defaultReturn) => {
// eslint-disable-next-line no-undef
let results = plugins.map(plugin => {
if (!plugin.plugin[api]) {
return undefined
Expand All @@ -34,7 +22,6 @@ exports.apiRunner = (api, args, defaultReturn) => {
}

exports.apiRunnerAsync = (api, args, defaultReturn) =>
// eslint-disable-next-line no-undef
plugins.reduce(
(previous, next) =>
next.plugin[api]
Expand Down
15 changes: 2 additions & 13 deletions packages/gatsby/src/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,6 @@ module.exports = async (args: BootstrapArgs) => {
plugin => plugin.resolve
)

let browserAPIRunner = ``

try {
browserAPIRunner = fs.readFileSync(
`${siteDir}/api-runner-browser.js`,
`utf-8`
)
} catch (err) {
report.panic(`Failed to read ${siteDir}/api-runner-browser.js`, err)
}

const browserPluginsRequires = browserPlugins
.map(
plugin =>
Expand All @@ -229,7 +218,7 @@ module.exports = async (args: BootstrapArgs) => {
)
.join(`,`)

browserAPIRunner = `var plugins = [${browserPluginsRequires}]\n${browserAPIRunner}`
const browserAPIRunner = `module.exports = [${browserPluginsRequires}]\n`

let sSRAPIRunner = ``

Expand All @@ -251,7 +240,7 @@ module.exports = async (args: BootstrapArgs) => {
sSRAPIRunner = `var plugins = [${ssrPluginsRequires}]\n${sSRAPIRunner}`

fs.writeFileSync(
`${siteDir}/api-runner-browser.js`,
`${siteDir}/api-runner-browser-plugins.js`,
browserAPIRunner,
`utf-8`
)
Expand Down