Skip to content
Permalink
Browse files

feat(gatsby-ssr): update exclude to excludeFiles

This is to be more specific to what is being excluded

BREAKING CHANGE: the option of exclude has been changed to excludeFiles. Anything using exclude
still will not have stuff excluded
  • Loading branch information
wmontgomery committed Jul 19, 2019
1 parent 4605c70 commit 057bc58e624b9de4faf97f5e7d292cd4622bfd7b
Showing with 6 additions and 6 deletions.
  1. +1 −1 README.md
  2. +2 −2 src/gatsby-ssr.spec.ts
  3. +3 −3 src/gatsby-ssr.ts
@@ -18,7 +18,7 @@ handlers then this should not effect you. This feature may be something this plu

## Available options

`exclude`: `string (optional)`
`excludeFiles`: `string (optional)`
* Will be used as a regular expression to test whether or not a Gatsby javascript file should be excluded by this plugin. The default behavior is that all Gatsby javascript files
are removed by this plugin, so this option gives you a chance to "exclude them from being excluded :sweat_smile:".
* A use case for this option is to not remove the webpack-runtime.js file that Gatsby ships by default in case you have other javascript that relies on that runtime.
@@ -57,7 +57,7 @@ describe('gatsby-ssr.js', () => {
replaceHeadComponents: replaceHeadComponentsSpy,
getPostBodyComponents,
replacePostBodyComponents: replacePostBodyComponentsSpy
}, { exclude: /webpack-runtime/ })
}, { excludeFiles: /webpack-runtime/ })
expect(replaceHeadComponentsSpy).toHaveBeenCalledWith([headComponentsData[13]])
})

@@ -137,7 +137,7 @@ describe('gatsby-ssr.js', () => {
replaceHeadComponents: replaceHeadComponentsSpy,
getPostBodyComponents,
replacePostBodyComponents: replacePostBodyComponentsSpy
}, { exclude: /webpack-runtime/ })
}, { excludeFiles: /webpack-runtime/ })
expect(replacePostBodyComponentsSpy).toHaveBeenCalledWith([postBodyComponentsData[3]])
})

@@ -18,7 +18,7 @@ export interface Script {
}

export interface PluginOptions {
exclude?: RegExp | string
excludeFiles?: RegExp | string
excludePaths?: any[]
}

@@ -61,7 +61,7 @@ function getHeadComponentsNoJS (headComponents: ReactNode[], pluginOptions: Plug
return true
}

if (pluginOptions.exclude && headComponent.props.href && RegExp(pluginOptions.exclude).test(headComponent.props.href)) {
if (pluginOptions.excludeFiles && headComponent.props.href && RegExp(pluginOptions.excludeFiles).test(headComponent.props.href)) {
return true
}

@@ -85,7 +85,7 @@ function getPostBodyComponentsNoJS (postBodyComponents: ReactNode[], pluginOptio
return true
}

if (pluginOptions.exclude && postBodyComponent.props.src && RegExp(pluginOptions.exclude).test(postBodyComponent.props.src)) {
if (pluginOptions.excludeFiles && postBodyComponent.props.src && RegExp(pluginOptions.excludeFiles).test(postBodyComponent.props.src)) {
return true
}

0 comments on commit 057bc58

Please sign in to comment.
You can’t perform that action at this time.