gatsby 4.17.0 → 4.18.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache-dir/commonjs/develop-static-entry.js +5 -5
- package/cache-dir/commonjs/ssr-develop-static-entry.js +42 -15
- package/cache-dir/ssr-develop-static-entry.js +13 -5
- package/dist/bootstrap/load-plugins/process-plugin.js +15 -7
- package/dist/bootstrap/load-plugins/process-plugin.js.map +1 -1
- package/dist/bootstrap/load-plugins/resolve-plugin.js +3 -3
- package/dist/bootstrap/load-plugins/resolve-plugin.js.map +1 -1
- package/dist/bootstrap/load-plugins/utils/get-api.js +5 -3
- package/dist/bootstrap/load-plugins/utils/get-api.js.map +1 -1
- package/dist/bootstrap/load-plugins/validate.js +13 -7
- package/dist/bootstrap/load-plugins/validate.js.map +1 -1
- package/dist/bootstrap/redirects-writer.js +2 -3
- package/dist/bootstrap/redirects-writer.js.map +1 -1
- package/dist/bootstrap/requires-writer.js +23 -13
- package/dist/bootstrap/requires-writer.js.map +1 -1
- package/dist/bootstrap/schema-hot-reloader.js +5 -3
- package/dist/bootstrap/schema-hot-reloader.js.map +1 -1
- package/dist/commands/build-html.d.ts +2 -5
- package/dist/commands/build-html.js +89 -15
- package/dist/commands/build-html.js.map +1 -1
- package/dist/datastore/common/query.js +8 -8
- package/dist/datastore/common/query.js.map +1 -1
- package/dist/datastore/in-memory/indexing.js +3 -3
- package/dist/datastore/in-memory/indexing.js.map +1 -1
- package/dist/datastore/in-memory/run-fast-filters.js +2 -2
- package/dist/datastore/in-memory/run-fast-filters.js.map +1 -1
- package/dist/internal-plugins/functions/gatsby-node.js +6 -5
- package/dist/internal-plugins/functions/gatsby-node.js.map +1 -1
- package/dist/joi-schemas/joi.js +13 -1
- package/dist/joi-schemas/joi.js.map +1 -1
- package/dist/query/graphql-errors.js +5 -3
- package/dist/query/graphql-errors.js.map +1 -1
- package/dist/query/graphql-runner.js +3 -3
- package/dist/query/graphql-runner.js.map +1 -1
- package/dist/query/index.js +2 -2
- package/dist/query/index.js.map +1 -1
- package/dist/query/query-runner.js +2 -2
- package/dist/query/query-runner.js.map +1 -1
- package/dist/redux/actions/restricted.js +2 -2
- package/dist/redux/actions/restricted.js.map +1 -1
- package/dist/redux/index.js +3 -5
- package/dist/redux/index.js.map +1 -1
- package/dist/redux/reducers/babelrc.js +7 -7
- package/dist/redux/reducers/babelrc.js.map +1 -1
- package/dist/redux/reducers/inference-metadata.js +4 -4
- package/dist/redux/reducers/inference-metadata.js.map +1 -1
- package/dist/redux/reducers/jobs.js +9 -7
- package/dist/redux/reducers/jobs.js.map +1 -1
- package/dist/redux/reducers/redirects.js +2 -2
- package/dist/redux/reducers/redirects.js.map +1 -1
- package/dist/redux/reducers/status.js +5 -3
- package/dist/redux/reducers/status.js.map +1 -1
- package/dist/redux/types.d.ts +4 -1
- package/dist/redux/types.js.map +1 -1
- package/dist/schema/graphql-engine/bundle-webpack.js +12 -9
- package/dist/schema/graphql-engine/bundle-webpack.js.map +1 -1
- package/dist/schema/graphql-engine/print-plugins.js +5 -3
- package/dist/schema/graphql-engine/print-plugins.js.map +1 -1
- package/dist/schema/infer/build-example-data.js +4 -3
- package/dist/schema/infer/build-example-data.js.map +1 -1
- package/dist/schema/infer/inference-metadata.js +4 -61
- package/dist/schema/infer/inference-metadata.js.map +1 -1
- package/dist/schema/print.js +6 -4
- package/dist/schema/print.js.map +1 -1
- package/dist/services/graphql-typegen.js +8 -2
- package/dist/services/graphql-typegen.js.map +1 -1
- package/dist/services/initialize.js +5 -3
- package/dist/services/initialize.js.map +1 -1
- package/dist/state-machines/develop/actions.js +9 -2
- package/dist/state-machines/develop/actions.js.map +1 -1
- package/dist/utils/changed-pages.js +5 -3
- package/dist/utils/changed-pages.js.map +1 -1
- package/dist/utils/dev-ssr/parse-error.d.ts +22 -0
- package/dist/utils/dev-ssr/parse-error.js +115 -0
- package/dist/utils/dev-ssr/parse-error.js.map +1 -0
- package/dist/utils/dev-ssr/render-dev-html-child.d.ts +13 -0
- package/dist/utils/dev-ssr/render-dev-html-child.js +25 -103
- package/dist/utils/dev-ssr/render-dev-html-child.js.map +1 -1
- package/dist/utils/dev-ssr/render-dev-html.d.ts +10 -10
- package/dist/utils/dev-ssr/render-dev-html.js +57 -32
- package/dist/utils/dev-ssr/render-dev-html.js.map +1 -1
- package/dist/utils/flags.js +4 -19
- package/dist/utils/flags.js.map +1 -1
- package/dist/utils/gatsby-dependents.js +5 -3
- package/dist/utils/gatsby-dependents.js.map +1 -1
- package/dist/utils/graphql-typegen/ts-codegen.d.ts +3 -2
- package/dist/utils/graphql-typegen/ts-codegen.js +5 -3
- package/dist/utils/graphql-typegen/ts-codegen.js.map +1 -1
- package/dist/utils/graphql-typegen/utils.js +3 -5
- package/dist/utils/graphql-typegen/utils.js.map +1 -1
- package/dist/utils/handle-flags.js +2 -2
- package/dist/utils/handle-flags.js.map +1 -1
- package/dist/utils/jobs/manager.js +3 -3
- package/dist/utils/jobs/manager.js.map +1 -1
- package/dist/utils/js-chunk-names.js +3 -3
- package/dist/utils/js-chunk-names.js.map +1 -1
- package/dist/utils/merge-gatsby-config.js +19 -8
- package/dist/utils/merge-gatsby-config.js.map +1 -1
- package/dist/utils/node-manifest.d.ts +2 -1
- package/dist/utils/node-manifest.js +24 -4
- package/dist/utils/node-manifest.js.map +1 -1
- package/dist/utils/prepare-regex.js +2 -2
- package/dist/utils/prepare-regex.js.map +1 -1
- package/dist/utils/sanitize-node.js +15 -9
- package/dist/utils/sanitize-node.js.map +1 -1
- package/dist/utils/start-server.js +34 -10
- package/dist/utils/start-server.js.map +1 -1
- package/dist/utils/webpack/plugins/static-query-mapper.js +3 -3
- package/dist/utils/webpack/plugins/static-query-mapper.js.map +1 -1
- package/dist/utils/worker/child/render-html.js +3 -3
- package/dist/utils/worker/child/render-html.js.map +1 -1
- package/dist/utils/worker/pool.js +4 -4
- package/dist/utils/worker/pool.js.map +1 -1
- package/index.d.ts +8 -7
- package/package.json +20 -21
|
@@ -6,12 +6,12 @@ exports.__esModule = true;
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.getPageChunk = getPageChunk;
|
|
8
8
|
|
|
9
|
+
var _merge2 = _interopRequireDefault(require("lodash/merge"));
|
|
10
|
+
|
|
9
11
|
var _react = _interopRequireDefault(require("react"));
|
|
10
12
|
|
|
11
13
|
var _server = require("react-dom/server");
|
|
12
14
|
|
|
13
|
-
var _lodash = require("lodash");
|
|
14
|
-
|
|
15
15
|
var _apiRunnerSsr = require("./api-runner-ssr");
|
|
16
16
|
|
|
17
17
|
var _asyncRequires = _interopRequireDefault(require("$virtual/async-requires"));
|
|
@@ -62,11 +62,11 @@ var _default = ({
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
const setHtmlAttributes = attributes => {
|
|
65
|
-
htmlAttributes = (0,
|
|
65
|
+
htmlAttributes = (0, _merge2.default)(htmlAttributes, attributes);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
const setBodyAttributes = attributes => {
|
|
69
|
-
bodyAttributes = (0,
|
|
69
|
+
bodyAttributes = (0, _merge2.default)(bodyAttributes, attributes);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
const setPreBodyComponents = components => {
|
|
@@ -78,7 +78,7 @@ var _default = ({
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
const setBodyProps = props => {
|
|
81
|
-
bodyProps = (0,
|
|
81
|
+
bodyProps = (0, _merge2.default)({}, bodyProps, props);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
const getHeadComponents = () => headComponents;
|
|
@@ -4,6 +4,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.default = staticPage;
|
|
7
|
+
exports.getPageChunk = getPageChunk;
|
|
8
|
+
|
|
9
|
+
var _concat2 = _interopRequireDefault(require("lodash/concat"));
|
|
10
|
+
|
|
11
|
+
var _uniqBy2 = _interopRequireDefault(require("lodash/uniqBy"));
|
|
12
|
+
|
|
13
|
+
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
|
|
14
|
+
|
|
15
|
+
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
16
|
+
|
|
17
|
+
var _merge2 = _interopRequireDefault(require("lodash/merge"));
|
|
18
|
+
|
|
19
|
+
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
7
20
|
|
|
8
21
|
var _react = _interopRequireDefault(require("react"));
|
|
9
22
|
|
|
@@ -11,8 +24,6 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
11
24
|
|
|
12
25
|
var _server = require("react-dom/server");
|
|
13
26
|
|
|
14
|
-
var _lodash = require("lodash");
|
|
15
|
-
|
|
16
27
|
var _path = _interopRequireDefault(require("path"));
|
|
17
28
|
|
|
18
29
|
var _apiRunnerSsr = require("./api-runner-ssr");
|
|
@@ -26,10 +37,13 @@ var _routeAnnouncerProps = require("./route-announcer-props");
|
|
|
26
37
|
var _router = require("@reach/router");
|
|
27
38
|
|
|
28
39
|
/* global BROWSER_ESM_ONLY */
|
|
29
|
-
//
|
|
40
|
+
// prefer default export if available
|
|
41
|
+
const preferDefault = m => m && m.default || m; // import testRequireError from "./test-require-error"
|
|
30
42
|
// For some extremely mysterious reason, webpack adds the above module *after*
|
|
31
43
|
// this module so that when this code runs, testRequireError is undefined.
|
|
32
44
|
// So in the meantime, we'll just inline it.
|
|
45
|
+
|
|
46
|
+
|
|
33
47
|
const testRequireError = (moduleName, err) => {
|
|
34
48
|
const regex = new RegExp(`Error: Cannot find module\\s.${moduleName}`);
|
|
35
49
|
const firstLine = err.toString().split(`\n`)[0];
|
|
@@ -62,7 +76,13 @@ try {
|
|
|
62
76
|
|
|
63
77
|
Html = Html && Html.__esModule ? Html.default : Html;
|
|
64
78
|
|
|
65
|
-
async function staticPage(
|
|
79
|
+
async function staticPage({
|
|
80
|
+
pagePath,
|
|
81
|
+
isClientOnlyPage,
|
|
82
|
+
publicDir,
|
|
83
|
+
error,
|
|
84
|
+
serverData
|
|
85
|
+
}) {
|
|
66
86
|
let bodyHtml = ``;
|
|
67
87
|
let headComponents = [/*#__PURE__*/_react.default.createElement("meta", {
|
|
68
88
|
key: "environment",
|
|
@@ -92,11 +112,11 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
92
112
|
};
|
|
93
113
|
|
|
94
114
|
const setHtmlAttributes = attributes => {
|
|
95
|
-
htmlAttributes = (0,
|
|
115
|
+
htmlAttributes = (0, _merge2.default)(htmlAttributes, attributes);
|
|
96
116
|
};
|
|
97
117
|
|
|
98
118
|
const setBodyAttributes = attributes => {
|
|
99
|
-
bodyAttributes = (0,
|
|
119
|
+
bodyAttributes = (0, _merge2.default)(bodyAttributes, attributes);
|
|
100
120
|
};
|
|
101
121
|
|
|
102
122
|
const setPreBodyComponents = components => {
|
|
@@ -108,7 +128,7 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
108
128
|
};
|
|
109
129
|
|
|
110
130
|
const setBodyProps = props => {
|
|
111
|
-
bodyProps = (0,
|
|
131
|
+
bodyProps = (0, _merge2.default)({}, bodyProps, props);
|
|
112
132
|
};
|
|
113
133
|
|
|
114
134
|
const getHeadComponents = () => headComponents;
|
|
@@ -156,11 +176,11 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
156
176
|
const {
|
|
157
177
|
componentChunkName
|
|
158
178
|
} = pageData;
|
|
159
|
-
let scriptsAndStyles = (0,
|
|
179
|
+
let scriptsAndStyles = (0, _flatten2.default)([`commons`].map(chunkKey => {
|
|
160
180
|
const fetchKey = `assetsByChunkName[${chunkKey}]`;
|
|
161
181
|
const stats = getStats(publicDir);
|
|
162
|
-
let chunks = (0,
|
|
163
|
-
const namedChunkGroups = (0,
|
|
182
|
+
let chunks = (0, _get2.default)(stats, fetchKey);
|
|
183
|
+
const namedChunkGroups = (0, _get2.default)(stats, `namedChunkGroups`);
|
|
164
184
|
|
|
165
185
|
if (!chunks) {
|
|
166
186
|
return null;
|
|
@@ -184,7 +204,7 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
184
204
|
|
|
185
205
|
for (const rel in childAssets) {
|
|
186
206
|
if (childAssets.hasownProperty(rel)) {
|
|
187
|
-
chunks = (0,
|
|
207
|
+
chunks = (0, _concat2.default)(chunks, childAssets[rel].map(chunk => {
|
|
188
208
|
return {
|
|
189
209
|
rel,
|
|
190
210
|
name: chunk
|
|
@@ -194,9 +214,9 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
194
214
|
}
|
|
195
215
|
|
|
196
216
|
return chunks;
|
|
197
|
-
})).filter(s => (0,
|
|
217
|
+
})).filter(s => (0, _isObject2.default)(s)).sort((s1, _s2) => s1.rel == `preload` ? -1 : 1); // given priority to preload
|
|
198
218
|
|
|
199
|
-
scriptsAndStyles = (0,
|
|
219
|
+
scriptsAndStyles = (0, _uniqBy2.default)(scriptsAndStyles, item => item.name);
|
|
200
220
|
const styles = scriptsAndStyles.filter(style => style.name && style.name.endsWith(`.css`));
|
|
201
221
|
styles.slice(0).reverse().forEach(style => {
|
|
202
222
|
headComponents.unshift( /*#__PURE__*/_react.default.createElement("link", {
|
|
@@ -214,6 +234,7 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
214
234
|
|
|
215
235
|
const props = { ...this.props,
|
|
216
236
|
...pageData.result,
|
|
237
|
+
serverData,
|
|
217
238
|
params: { ...(0, _findPath.grabMatchParams)(this.props.location.pathname),
|
|
218
239
|
...(((_pageData$result = pageData.result) === null || _pageData$result === void 0 ? void 0 : (_pageData$result$page = _pageData$result.pageContext) === null || _pageData$result$page === void 0 ? void 0 : _pageData$result$page.__params) || {})
|
|
219
240
|
}
|
|
@@ -221,7 +242,7 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
221
242
|
let pageElement;
|
|
222
243
|
|
|
223
244
|
if (_ssrSyncRequires.default.ssrComponents[componentChunkName] && !isClientOnlyPage) {
|
|
224
|
-
pageElement = /*#__PURE__*/_react.default.createElement(_ssrSyncRequires.default.ssrComponents[componentChunkName], props);
|
|
245
|
+
pageElement = /*#__PURE__*/_react.default.createElement(preferDefault(_ssrSyncRequires.default.ssrComponents[componentChunkName]), props);
|
|
225
246
|
} else {
|
|
226
247
|
// If this is a client-only page or the pageComponent didn't finish
|
|
227
248
|
// compiling yet, just render an empty component.
|
|
@@ -334,5 +355,11 @@ async function staticPage(pagePath, isClientOnlyPage, publicDir, error, callback
|
|
|
334
355
|
|
|
335
356
|
let htmlStr = (0, _server.renderToStaticMarkup)(htmlElement);
|
|
336
357
|
htmlStr = `<!DOCTYPE html>${htmlStr}`;
|
|
337
|
-
|
|
358
|
+
return htmlStr;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function getPageChunk({
|
|
362
|
+
componentChunkName
|
|
363
|
+
}) {
|
|
364
|
+
return _ssrSyncRequires.default.ssrComponents[componentChunkName];
|
|
338
365
|
}
|
|
@@ -11,6 +11,9 @@ import syncRequires from "$virtual/ssr-sync-requires"
|
|
|
11
11
|
import { RouteAnnouncerProps } from "./route-announcer-props"
|
|
12
12
|
import { ServerLocation, Router, isRedirect } from "@reach/router"
|
|
13
13
|
|
|
14
|
+
// prefer default export if available
|
|
15
|
+
const preferDefault = m => (m && m.default) || m
|
|
16
|
+
|
|
14
17
|
// import testRequireError from "./test-require-error"
|
|
15
18
|
// For some extremely mysterious reason, webpack adds the above module *after*
|
|
16
19
|
// this module so that when this code runs, testRequireError is undefined.
|
|
@@ -48,13 +51,13 @@ try {
|
|
|
48
51
|
|
|
49
52
|
Html = Html && Html.__esModule ? Html.default : Html
|
|
50
53
|
|
|
51
|
-
export default async function staticPage(
|
|
54
|
+
export default async function staticPage({
|
|
52
55
|
pagePath,
|
|
53
56
|
isClientOnlyPage,
|
|
54
57
|
publicDir,
|
|
55
58
|
error,
|
|
56
|
-
|
|
57
|
-
) {
|
|
59
|
+
serverData,
|
|
60
|
+
}) {
|
|
58
61
|
let bodyHtml = ``
|
|
59
62
|
let headComponents = [
|
|
60
63
|
<meta key="environment" name="note" content="environment=development" />,
|
|
@@ -225,6 +228,7 @@ export default async function staticPage(
|
|
|
225
228
|
const props = {
|
|
226
229
|
...this.props,
|
|
227
230
|
...pageData.result,
|
|
231
|
+
serverData,
|
|
228
232
|
params: {
|
|
229
233
|
...grabMatchParams(this.props.location.pathname),
|
|
230
234
|
...(pageData.result?.pageContext?.__params || {}),
|
|
@@ -237,7 +241,7 @@ export default async function staticPage(
|
|
|
237
241
|
!isClientOnlyPage
|
|
238
242
|
) {
|
|
239
243
|
pageElement = React.createElement(
|
|
240
|
-
syncRequires.ssrComponents[componentChunkName],
|
|
244
|
+
preferDefault(syncRequires.ssrComponents[componentChunkName]),
|
|
241
245
|
props
|
|
242
246
|
)
|
|
243
247
|
} else {
|
|
@@ -348,5 +352,9 @@ export default async function staticPage(
|
|
|
348
352
|
let htmlStr = renderToStaticMarkup(htmlElement)
|
|
349
353
|
htmlStr = `<!DOCTYPE html>${htmlStr}`
|
|
350
354
|
|
|
351
|
-
|
|
355
|
+
return htmlStr
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export function getPageChunk({ componentChunkName }) {
|
|
359
|
+
return syncRequires.ssrComponents[componentChunkName]
|
|
352
360
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
exports.__esModule = true;
|
|
4
6
|
exports.processPlugin = processPlugin;
|
|
5
7
|
|
|
8
|
+
var _merge2 = _interopRequireDefault(require("lodash/merge"));
|
|
9
|
+
|
|
10
|
+
var _set2 = _interopRequireDefault(require("lodash/set"));
|
|
11
|
+
|
|
12
|
+
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
13
|
+
|
|
14
|
+
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
15
|
+
|
|
6
16
|
var _createId = require("./utils/create-id");
|
|
7
17
|
|
|
8
18
|
var _resolvePlugin = require("./resolve-plugin");
|
|
9
19
|
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
20
|
function processPlugin(plugin, rootDir) {
|
|
13
21
|
// Respect the directory that the plugin was sourced from initially
|
|
14
|
-
rootDir = !(0,
|
|
22
|
+
rootDir = !(0, _isString2.default)(plugin) && plugin.parentDir || rootDir;
|
|
15
23
|
|
|
16
|
-
if ((0,
|
|
24
|
+
if ((0, _isString2.default)(plugin)) {
|
|
17
25
|
const info = (0, _resolvePlugin.resolvePlugin)(plugin, rootDir);
|
|
18
26
|
return { ...info,
|
|
19
27
|
pluginOptions: {
|
|
@@ -24,7 +32,7 @@ function processPlugin(plugin, rootDir) {
|
|
|
24
32
|
|
|
25
33
|
plugin.options = plugin.options || {}; // Throw an error if there is an "option" key.
|
|
26
34
|
|
|
27
|
-
if ((0,
|
|
35
|
+
if ((0, _isEmpty2.default)(plugin.options) && !(0, _isEmpty2.default)(plugin.option)) {
|
|
28
36
|
throw new Error(`Plugin "${plugin.resolve}" has an "option" key in the configuration. Did you mean "options"?`);
|
|
29
37
|
} // Plugins can have plugins.
|
|
30
38
|
|
|
@@ -52,7 +60,7 @@ function processPlugin(plugin, rootDir) {
|
|
|
52
60
|
processed.push(result);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
(0,
|
|
63
|
+
(0, _set2.default)(plugin.options, pathToSwap, processed);
|
|
56
64
|
}
|
|
57
65
|
} // Add some default values for tests as we don't actually
|
|
58
66
|
// want to try to load anything during tests.
|
|
@@ -77,7 +85,7 @@ function processPlugin(plugin, rootDir) {
|
|
|
77
85
|
module: plugin.module,
|
|
78
86
|
subPluginPaths: plugin.subPluginPaths ? Array.from(plugin.subPluginPaths) : undefined,
|
|
79
87
|
id: (0, _createId.createPluginId)(info.name, plugin),
|
|
80
|
-
pluginOptions: (0,
|
|
88
|
+
pluginOptions: (0, _merge2.default)({
|
|
81
89
|
plugins: []
|
|
82
90
|
}, plugin.options)
|
|
83
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-plugin.js","names":["processPlugin","plugin","rootDir","
|
|
1
|
+
{"version":3,"file":"process-plugin.js","names":["processPlugin","plugin","rootDir","parentDir","info","resolvePlugin","pluginOptions","plugins","options","option","Error","resolve","subPluginPaths","subPluginPath","segments","split","roots","pathToSwap","segment","slice","length","flat","map","root","processed","result","push","name","id","createPluginId","version","modulePath","module","Array","from","undefined"],"sources":["../../../src/bootstrap/load-plugins/process-plugin.ts"],"sourcesContent":["import { IPluginInfo, PluginRef } from \"./types\"\nimport { createPluginId } from \"./utils/create-id\"\nimport { resolvePlugin } from \"./resolve-plugin\"\nimport { isString, isEmpty, set, merge } from \"lodash\"\n\nexport function processPlugin(plugin: PluginRef, rootDir: string): IPluginInfo {\n // Respect the directory that the plugin was sourced from initially\n rootDir = (!isString(plugin) && plugin.parentDir) || rootDir\n\n if (isString(plugin)) {\n const info = resolvePlugin(plugin, rootDir)\n\n return {\n ...info,\n pluginOptions: {\n plugins: [],\n },\n }\n }\n\n plugin.options = plugin.options || {}\n\n // Throw an error if there is an \"option\" key.\n if (\n isEmpty(plugin.options) &&\n !isEmpty((plugin as { option?: unknown }).option)\n ) {\n throw new Error(\n `Plugin \"${plugin.resolve}\" has an \"option\" key in the configuration. Did you mean \"options\"?`\n )\n }\n\n // Plugins can have plugins.\n if (plugin.subPluginPaths) {\n for (const subPluginPath of plugin.subPluginPaths) {\n const segments = subPluginPath.split(`.`)\n let roots: Array<any> = [plugin.options]\n\n let pathToSwap = segments\n\n for (const segment of segments) {\n if (segment === `[]`) {\n pathToSwap = pathToSwap.slice(0, pathToSwap.length - 1)\n roots = roots.flat()\n } else {\n roots = roots.map(root => root[segment])\n }\n }\n roots = roots.flat()\n\n const processed: Array<IPluginInfo> = []\n\n for (const root of roots) {\n const result = processPlugin(root, rootDir)\n processed.push(result)\n }\n\n set(plugin.options, pathToSwap, processed)\n }\n }\n\n // Add some default values for tests as we don't actually\n // want to try to load anything during tests.\n if (plugin.resolve === `___TEST___`) {\n const name = `TEST`\n\n return {\n id: createPluginId(name, plugin),\n name,\n version: `0.0.0-test`,\n pluginOptions: {\n plugins: [],\n },\n resolve: `__TEST__`,\n }\n }\n\n const info = resolvePlugin(plugin, rootDir)\n\n return {\n ...info,\n modulePath: plugin.modulePath,\n module: plugin.module,\n subPluginPaths: plugin.subPluginPaths\n ? Array.from(plugin.subPluginPaths)\n : undefined,\n id: createPluginId(info.name, plugin),\n pluginOptions: merge({ plugins: [] }, plugin.options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA;;AACA;;AAGO,SAASA,aAAT,CAAuBC,MAAvB,EAA0CC,OAA1C,EAAwE;EAC7E;EACAA,OAAO,GAAI,CAAC,wBAASD,MAAT,CAAD,IAAqBA,MAAM,CAACE,SAA7B,IAA2CD,OAArD;;EAEA,IAAI,wBAASD,MAAT,CAAJ,EAAsB;IACpB,MAAMG,IAAI,GAAG,IAAAC,4BAAA,EAAcJ,MAAd,EAAsBC,OAAtB,CAAb;IAEA,OAAO,EACL,GAAGE,IADE;MAELE,aAAa,EAAE;QACbC,OAAO,EAAE;MADI;IAFV,CAAP;EAMD;;EAEDN,MAAM,CAACO,OAAP,GAAiBP,MAAM,CAACO,OAAP,IAAkB,EAAnC,CAf6E,CAiB7E;;EACA,IACE,uBAAQP,MAAM,CAACO,OAAf,KACA,CAAC,uBAASP,MAAD,CAAiCQ,MAAzC,CAFH,EAGE;IACA,MAAM,IAAIC,KAAJ,CACH,WAAUT,MAAM,CAACU,OAAQ,qEADtB,CAAN;EAGD,CAzB4E,CA2B7E;;;EACA,IAAIV,MAAM,CAACW,cAAX,EAA2B;IACzB,KAAK,MAAMC,aAAX,IAA4BZ,MAAM,CAACW,cAAnC,EAAmD;MACjD,MAAME,QAAQ,GAAGD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MAAM,CAAC8B,UAFd;IAGLC,MAAM,EAAE/B,MAAM,CAAC+B,MAHV;IAILpB,cAAc,EAAEX,MAAM,CAACW,cAAP,GACZqB,KAAK,CAACC,IAAN,CAAWjC,MAAM,CAACW,cAAlB,CADY,GAEZuB,SANC;IAOLP,EAAE,EAAE,IAAAC,wBAAA,EAAezB,IAAI,CAACuB,IAApB,EAA0B1B,MAA1B,CAPC;IAQLK,aAAa,EAAE,qBAAM;MAAEC,OAAO,EAAE;IAAX,CAAN,EAAuBN,MAAM,CAACO,OAA9B;EARV,CAAP;AAUD"}
|
|
@@ -5,6 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.resolvePlugin = resolvePlugin;
|
|
7
7
|
|
|
8
|
+
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
9
|
+
|
|
8
10
|
var _path = _interopRequireDefault(require("path"));
|
|
9
11
|
|
|
10
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
@@ -19,8 +21,6 @@ var _createHash = require("./utils/create-hash");
|
|
|
19
21
|
|
|
20
22
|
var _reporter = _interopRequireDefault(require("gatsby-cli/lib/reporter"));
|
|
21
23
|
|
|
22
|
-
var _lodash = require("lodash");
|
|
23
|
-
|
|
24
24
|
var _checkLocalPlugin = require("./utils/check-local-plugin");
|
|
25
25
|
|
|
26
26
|
var _compileGatsbyFiles = require("../../utils/parcel/compile-gatsby-files");
|
|
@@ -37,7 +37,7 @@ var _compileGatsbyFiles = require("../../utils/parcel/compile-gatsby-files");
|
|
|
37
37
|
* This is the project location, from which are found the plugins
|
|
38
38
|
*/
|
|
39
39
|
function resolvePlugin(plugin, rootDir) {
|
|
40
|
-
const pluginName = (0,
|
|
40
|
+
const pluginName = (0, _isString2.default)(plugin) ? plugin : plugin.resolve; // Handle local plugins
|
|
41
41
|
|
|
42
42
|
const {
|
|
43
43
|
validLocalPlugin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-plugin.js","names":["resolvePlugin","plugin","rootDir","pluginName","
|
|
1
|
+
{"version":3,"file":"resolve-plugin.js","names":["resolvePlugin","plugin","rootDir","pluginName","resolve","validLocalPlugin","localPluginPath","checkLocalPlugin","packageJSON","JSON","parse","fs","readFileSync","name","warnOnIncompatiblePeerDependency","id","createPluginId","version","createFileContentHash","getResolvedFieldsForPlugin","requireSource","createRequireFromPath","require","resolvedPath","slash","path","dirname","isAbsolute","err","process","env","gatsby_log_level","reporter","panicOnBuild","Error"],"sources":["../../../src/bootstrap/load-plugins/resolve-plugin.ts"],"sourcesContent":["import path from \"path\"\nimport fs from \"fs\"\nimport { slash, createRequireFromPath } from \"gatsby-core-utils\"\nimport { warnOnIncompatiblePeerDependency } from \"./validate\"\nimport { PackageJson } from \"../../..\"\nimport { IPluginInfo, PluginRef } from \"./types\"\nimport { createPluginId } from \"./utils/create-id\"\nimport { createFileContentHash } from \"./utils/create-hash\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport { isString } from \"lodash\"\nimport { checkLocalPlugin } from \"./utils/check-local-plugin\"\nimport { getResolvedFieldsForPlugin } from \"../../utils/parcel/compile-gatsby-files\"\n\n/**\n * @param plugin\n * This should be a plugin spec object where possible but can also be the\n * name of a plugin.\n *\n * When it is a name, it can be a name of a local plugin, the name of a plugin\n * located in node_modules, or a Gatsby internal plugin. In the last case the\n * plugin will be an absolute path.\n * @param rootDir\n * This is the project location, from which are found the plugins\n */\nexport function resolvePlugin(plugin: PluginRef, rootDir: string): IPluginInfo {\n const pluginName = isString(plugin) ? plugin : plugin.resolve\n\n // Handle local plugins\n const { validLocalPlugin, localPluginPath = `` } = checkLocalPlugin(\n plugin,\n rootDir\n )\n\n if (validLocalPlugin && localPluginPath) {\n const packageJSON = JSON.parse(\n fs.readFileSync(`${localPluginPath}/package.json`, `utf-8`)\n ) as PackageJson\n const name = packageJSON.name || pluginName\n warnOnIncompatiblePeerDependency(name, packageJSON)\n\n return {\n resolve: localPluginPath,\n name,\n id: createPluginId(name),\n version:\n packageJSON?.version || createFileContentHash(localPluginPath, `**`),\n ...getResolvedFieldsForPlugin(rootDir, name),\n }\n }\n\n /**\n * Here we have an absolute path to an internal plugin, or a name of a module\n * which should be located in node_modules.\n */\n try {\n const requireSource =\n rootDir !== null\n ? createRequireFromPath(`${rootDir}/:internal:`)\n : require\n\n // If the path is absolute, resolve the directory of the internal plugin,\n // otherwise resolve the directory containing the package.json\n const resolvedPath = slash(\n path.dirname(\n requireSource.resolve(\n path.isAbsolute(pluginName)\n ? pluginName\n : `${pluginName}/package.json`\n )\n )\n )\n\n const packageJSON = JSON.parse(\n fs.readFileSync(`${resolvedPath}/package.json`, `utf-8`)\n )\n warnOnIncompatiblePeerDependency(packageJSON.name, packageJSON)\n\n return {\n resolve: resolvedPath,\n id: createPluginId(packageJSON.name),\n name: packageJSON.name,\n version: packageJSON.version,\n }\n } catch (err) {\n if (process.env.gatsby_log_level === `verbose`) {\n reporter.panicOnBuild(\n `plugin \"${pluginName} threw the following error:\\n`,\n err\n )\n } else {\n reporter.panicOnBuild(\n `There was a problem loading plugin \"${pluginName}\". Perhaps you need to install its package?\\nUse --verbose to see actual error.`\n )\n }\n throw new Error(`unreachable`)\n }\n}\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAuBC,MAAvB,EAA0CC,OAA1C,EAAwE;EAC7E,MAAMC,UAAU,GAAG,wBAASF,MAAT,IAAmBA,MAAnB,GAA4BA,MAAM,CAACG,OAAtD,CAD6E,CAG7E;;EACA,MAAM;IAAEC,gBAAF;IAAoBC,eAAe,GAAI;EAAvC,IAA6C,IAAAC,kCAAA,EACjDN,MADiD,EAEjDC,OAFiD,CAAnD;;EAKA,IAAIG,gBAAgB,IAAIC,eAAxB,EAAyC;IACvC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b;MAILI,OAAO,EAAET,WAAW,CAACS;IAJhB,CAAP;EAMD,CA7BD,CA6BE,OAAOW,GAAP,EAAY;IACZ,IAAIC,OAAO,CAACC,GAAR,CAAYC,gBAAZ,KAAkC,SAAtC,EAAgD;MAC9CC,iBAAA,CAASC,YAAT,CACG,WAAU9B,UAAW,+BADxB,EAEEyB,GAFF;IAID,CALD,MAKO;MACLI,iBAAA,CAASC,YAAT,CACG,uCAAsC9B,UAAW,iFADpD;IAGD;;IACD,MAAM,IAAI+B,KAAJ,CAAW,aAAX,CAAN;EACD;AACF"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
exports.__esModule = true;
|
|
4
6
|
exports.getAPI = void 0;
|
|
5
7
|
|
|
6
|
-
var
|
|
8
|
+
var _keys2 = _interopRequireDefault(require("lodash/keys"));
|
|
7
9
|
|
|
8
|
-
const getAPI = api => (0,
|
|
9
|
-
merged[key] = (0,
|
|
10
|
+
const getAPI = api => (0, _keys2.default)(api).reduce((merged, key) => {
|
|
11
|
+
merged[key] = (0, _keys2.default)(api[key]);
|
|
10
12
|
return merged;
|
|
11
13
|
}, {});
|
|
12
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-api.js","names":["getAPI","api","
|
|
1
|
+
{"version":3,"file":"get-api.js","names":["getAPI","api","reduce","merged","key"],"sources":["../../../../src/bootstrap/load-plugins/utils/get-api.ts"],"sourcesContent":["import { ExportType, ICurrentAPIs } from \"../validate\"\nimport { keys } from \"lodash\"\n\nexport const getAPI = (api: {\n [exportType in ExportType]: { [api: string]: boolean }\n}): ICurrentAPIs =>\n keys(api).reduce<Partial<ICurrentAPIs>>((merged, key) => {\n merged[key] = keys(api[key])\n return merged\n }, {}) as ICurrentAPIs\n"],"mappings":";;;;;;;;;AAGO,MAAMA,MAAM,GAAIC,GAAD,IAGpB,oBAAKA,GAAL,EAAUC,MAAV,CAAwC,CAACC,MAAD,EAASC,GAAT,KAAiB;EACvDD,MAAM,CAACC,GAAD,CAAN,GAAc,oBAAKH,GAAG,CAACG,GAAD,CAAR,CAAd;EACA,OAAOD,MAAP;AACD,CAHD,EAGG,EAHH,CAHK"}
|
|
@@ -9,7 +9,13 @@ exports.handleMultipleReplaceRenderers = void 0;
|
|
|
9
9
|
exports.validateConfigPluginsOptions = validateConfigPluginsOptions;
|
|
10
10
|
exports.warnOnIncompatiblePeerDependency = warnOnIncompatiblePeerDependency;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
13
|
+
|
|
14
|
+
var _intersection2 = _interopRequireDefault(require("lodash/intersection"));
|
|
15
|
+
|
|
16
|
+
var _toPairs2 = _interopRequireDefault(require("lodash/toPairs"));
|
|
17
|
+
|
|
18
|
+
var _difference2 = _interopRequireDefault(require("lodash/difference"));
|
|
13
19
|
|
|
14
20
|
var _path = _interopRequireDefault(require("path"));
|
|
15
21
|
|
|
@@ -52,7 +58,7 @@ const getGatsbyUpgradeVersion = entries => entries.reduce((version, entry) => {
|
|
|
52
58
|
function getBadExports(plugin, pluginAPIKeys, apis) {
|
|
53
59
|
let badExports = []; // Discover any exports from plugins which are not "known"
|
|
54
60
|
|
|
55
|
-
badExports = badExports.concat(
|
|
61
|
+
badExports = badExports.concat((0, _difference2.default)(pluginAPIKeys, apis).map(e => {
|
|
56
62
|
return {
|
|
57
63
|
exportName: e,
|
|
58
64
|
pluginName: plugin.name,
|
|
@@ -105,7 +111,7 @@ async function handleBadExports({
|
|
|
105
111
|
if (hasBadExports) {
|
|
106
112
|
const latestAPIs = await (0, _getLatestApis.getLatestAPIs)(); // Output error messages for all bad exports
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
(0, _toPairs2.default)(badExports).forEach(badItem => {
|
|
109
115
|
const [exportType, entries] = badItem;
|
|
110
116
|
|
|
111
117
|
if (entries.length > 0) {
|
|
@@ -324,17 +330,17 @@ function collatePluginAPIs({
|
|
|
324
330
|
const pluginSSRExports = (0, _resolveModuleExports.resolveModuleExports)(`${plugin.resolve}/gatsby-ssr`);
|
|
325
331
|
|
|
326
332
|
if (pluginNodeExports.length > 0) {
|
|
327
|
-
plugin.nodeAPIs =
|
|
333
|
+
plugin.nodeAPIs = (0, _intersection2.default)(pluginNodeExports, currentAPIs.node);
|
|
328
334
|
badExports.node = badExports.node.concat(getBadExports(plugin, pluginNodeExports, currentAPIs.node)); // Collate any bad exports
|
|
329
335
|
}
|
|
330
336
|
|
|
331
337
|
if (pluginBrowserExports.length > 0) {
|
|
332
|
-
plugin.browserAPIs =
|
|
338
|
+
plugin.browserAPIs = (0, _intersection2.default)(pluginBrowserExports, currentAPIs.browser);
|
|
333
339
|
badExports.browser = badExports.browser.concat(getBadExports(plugin, pluginBrowserExports, currentAPIs.browser)); // Collate any bad exports
|
|
334
340
|
}
|
|
335
341
|
|
|
336
342
|
if (pluginSSRExports.length > 0) {
|
|
337
|
-
plugin.ssrAPIs =
|
|
343
|
+
plugin.ssrAPIs = (0, _intersection2.default)(pluginSSRExports, currentAPIs.ssr);
|
|
338
344
|
badExports.ssr = badExports.ssr.concat(getBadExports(plugin, pluginSSRExports, currentAPIs.ssr)); // Collate any bad exports
|
|
339
345
|
}
|
|
340
346
|
});
|
|
@@ -397,7 +403,7 @@ exports.handleMultipleReplaceRenderers = handleMultipleReplaceRenderers;
|
|
|
397
403
|
|
|
398
404
|
function warnOnIncompatiblePeerDependency(name, packageJSON) {
|
|
399
405
|
// Note: In the future the peer dependency should be enforced for all plugins.
|
|
400
|
-
const gatsbyPeerDependency =
|
|
406
|
+
const gatsbyPeerDependency = (0, _get2.default)(packageJSON, `peerDependencies.gatsby`);
|
|
401
407
|
|
|
402
408
|
if (!_gatsbyWorker.isWorker && gatsbyPeerDependency && !semver.satisfies(_package.version, gatsbyPeerDependency, {
|
|
403
409
|
includePrerelease: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","names":["getGatsbyUpgradeVersion","entries","reduce","version","entry","api","semver","gt","getBadExports","plugin","pluginAPIKeys","apis","badExports","concat","_","difference","map","e","exportName","pluginName","name","pluginVersion","getErrorContext","exportType","currentAPIs","latestAPIs","ex","gatsbyUpgradeVersion","errors","fixes","forEach","similarities","stringSimilarity","findBestMatch","isDefaultPlugin","message","push","bestMatch","rating","target","sourceMessage","length","filter","Boolean","join","handleBadExports","hasBadExports","Object","keys","find","getLatestAPIs","toPairs","badItem","context","reporter","error","id","validatePluginsOptions","plugins","rootDir","newPlugins","Promise","all","gatsbyNode","resolvedPlugin","resolvePlugin","require","resolve","err","pluginOptionsSchema","subPluginPaths","Set","optionsSchema","Joi","extend","joi","type","base","array","items","alternatives","string","object","options","unknown","custom","arrayValue","helpers","schema","_flags","value","modulePath","module","normalizedPath","state","path","key","index","Array","isArray","ancestors","Error","add","console","log","default","args","$_setFlag","clone","configDir","parentDir","relative","isSchema","warn","describe","append","warning","validateOptionsSchema","validationWarnings","details","stripIndent","trackCli","valueString","subErrors","subPlugins","size","from","ValidationError","validationErrors","validateConfigPluginsOptions","config","process","exit","collatePluginAPIs","flattenedPlugins","node","browser","ssr","nodeAPIs","browserAPIs","ssrAPIs","pluginNodeExports","resolveModuleExports","resolvedCompiledGatsbyNode","mode","pluginBrowserExports","pluginSSRExports","intersection","handleMultipleReplaceRenderers","rendererPlugins","includes","env","NODE_ENV","ignorable","slice","messages","fp","i","skipSSR","m","warnOnIncompatiblePeerDependency","packageJSON","gatsbyPeerDependency","get","isWorker","satisfies","gatsbyVersion","includePrerelease"],"sources":["../../../src/bootstrap/load-plugins/validate.ts"],"sourcesContent":["import _ from \"lodash\"\nimport path from \"path\"\nimport * as semver from \"semver\"\nimport * as stringSimilarity from \"string-similarity\"\nimport { version as gatsbyVersion } from \"gatsby/package.json\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport { validateOptionsSchema, Joi } from \"gatsby-plugin-utils\"\nimport { IPluginRefObject } from \"gatsby-plugin-utils/dist/types\"\nimport { stripIndent } from \"common-tags\"\nimport { trackCli } from \"gatsby-telemetry\"\nimport { isWorker } from \"gatsby-worker\"\nimport { resolveModuleExports } from \"../resolve-module-exports\"\nimport { getLatestAPIs } from \"../../utils/get-latest-apis\"\nimport { GatsbyNode, PackageJson } from \"../../../\"\nimport {\n IPluginInfo,\n IFlattenedPlugin,\n IPluginInfoOptions,\n ISiteConfig,\n} from \"./types\"\nimport { resolvePlugin } from \"./resolve-plugin\"\n\ninterface IApi {\n version?: string\n}\n\nexport interface IEntry {\n exportName: string\n pluginName: string\n pluginVersion: string\n api?: IApi\n}\n\nexport type ExportType = \"node\" | \"browser\" | \"ssr\"\n\ntype IEntryMap = {\n [exportType in ExportType]: Array<IEntry>\n}\n\nexport type ICurrentAPIs = {\n [exportType in ExportType]: Array<string>\n}\n\nconst getGatsbyUpgradeVersion = (entries: ReadonlyArray<IEntry>): string =>\n entries.reduce((version, entry) => {\n if (entry.api && entry.api.version) {\n return semver.gt(entry.api.version, version || `0.0.0`)\n ? entry.api.version\n : version\n }\n return version\n }, ``)\n\n// Given a plugin object, an array of the API names it exports and an\n// array of valid API names, return an array of invalid API exports.\nfunction getBadExports(\n plugin: IPluginInfo,\n pluginAPIKeys: ReadonlyArray<string>,\n apis: ReadonlyArray<string>\n): Array<IEntry> {\n let badExports: Array<IEntry> = []\n // Discover any exports from plugins which are not \"known\"\n badExports = badExports.concat(\n _.difference(pluginAPIKeys, apis).map(e => {\n return {\n exportName: e,\n pluginName: plugin.name,\n pluginVersion: plugin.version,\n }\n })\n )\n return badExports\n}\n\nfunction getErrorContext(\n badExports: Array<IEntry>,\n exportType: ExportType,\n currentAPIs: ICurrentAPIs,\n latestAPIs: { [exportType in ExportType]: { [exportName: string]: IApi } }\n): {\n errors: Array<string>\n entries: Array<IEntry>\n exportType: ExportType\n fixes: Array<string>\n sourceMessage: string\n} {\n const entries = badExports.map(ex => {\n return {\n ...ex,\n api: latestAPIs[exportType][ex.exportName],\n }\n })\n\n const gatsbyUpgradeVersion = getGatsbyUpgradeVersion(entries)\n const errors: Array<string> = []\n const fixes = gatsbyUpgradeVersion\n ? [`npm install gatsby@^${gatsbyUpgradeVersion}`]\n : []\n\n entries.forEach(entry => {\n const similarities = stringSimilarity.findBestMatch(\n entry.exportName,\n currentAPIs[exportType]\n )\n const isDefaultPlugin = entry.pluginName == `default-site-plugin`\n\n const message = entry.api\n ? entry.api.version\n ? `was introduced in gatsby@${entry.api.version}`\n : `is not available in your version of Gatsby`\n : `is not a known API`\n\n if (isDefaultPlugin) {\n errors.push(\n `- Your local gatsby-${exportType}.js is using the API \"${entry.exportName}\" which ${message}.`\n )\n } else {\n errors.push(\n `- The plugin ${entry.pluginName}@${entry.pluginVersion} is using the API \"${entry.exportName}\" which ${message}.`\n )\n }\n\n if (similarities.bestMatch.rating > 0.5) {\n fixes.push(\n `Rename \"${entry.exportName}\" -> \"${similarities.bestMatch.target}\"`\n )\n }\n })\n\n return {\n errors,\n entries,\n exportType,\n fixes,\n // note: this is a fallback if gatsby-cli is not updated with structured error\n sourceMessage: [\n `Your plugins must export known APIs from their gatsby-node.js.`,\n ]\n .concat(errors)\n .concat(\n fixes.length > 0\n ? [`\\n`, `Some of the following may help fix the error(s):`, ...fixes]\n : []\n )\n .filter(Boolean)\n .join(`\\n`),\n }\n}\n\nexport async function handleBadExports({\n currentAPIs,\n badExports,\n}: {\n currentAPIs: ICurrentAPIs\n badExports: { [api in ExportType]: Array<IEntry> }\n}): Promise<void> {\n const hasBadExports = Object.keys(badExports).find(\n api => badExports[api].length > 0\n )\n if (hasBadExports) {\n const latestAPIs = await getLatestAPIs()\n // Output error messages for all bad exports\n _.toPairs(badExports).forEach(badItem => {\n const [exportType, entries] = badItem\n if (entries.length > 0) {\n const context = getErrorContext(\n entries,\n exportType as keyof typeof badExports,\n currentAPIs,\n latestAPIs\n )\n reporter.error({\n id: `11329`,\n context,\n })\n }\n })\n }\n}\n\nasync function validatePluginsOptions(\n plugins: Array<IPluginRefObject>,\n rootDir: string\n): Promise<{\n errors: number\n plugins: Array<IPluginRefObject>\n}> {\n let errors = 0\n const newPlugins = await Promise.all(\n plugins.map(async plugin => {\n let gatsbyNode\n try {\n const resolvedPlugin = resolvePlugin(plugin, rootDir)\n gatsbyNode = require(`${resolvedPlugin.resolve}/gatsby-node`)\n } catch (err) {\n gatsbyNode = {}\n }\n\n if (!gatsbyNode.pluginOptionsSchema) return plugin\n\n const subPluginPaths = new Set<string>()\n\n let optionsSchema = (\n gatsbyNode.pluginOptionsSchema as Exclude<\n GatsbyNode[\"pluginOptionsSchema\"],\n undefined\n >\n )({\n Joi: Joi.extend(joi => {\n return {\n type: `subPlugins`,\n base: joi\n .array()\n .items(\n joi.alternatives(\n joi.string(),\n joi.object({\n resolve: Joi.string(),\n options: Joi.object({}).unknown(true),\n })\n )\n )\n .custom((arrayValue, helpers) => {\n const entry = helpers.schema._flags.entry\n return arrayValue.map(value => {\n if (typeof value === `string`) {\n value = { resolve: value }\n }\n\n try {\n const resolvedPlugin = resolvePlugin(value, rootDir)\n const modulePath = require.resolve(\n `${resolvedPlugin.resolve}${entry ? `/${entry}` : ``}`\n )\n value.modulePath = modulePath\n value.module = require(modulePath)\n\n const normalizedPath = helpers.state.path\n .map((key, index) => {\n // if subplugin is part of an array - swap concrete index key with `[]`\n if (\n typeof key === `number` &&\n Array.isArray(\n helpers.state.ancestors[\n helpers.state.path.length - index - 1\n ]\n )\n ) {\n if (index !== helpers.state.path.length - 1) {\n throw new Error(\n `No support for arrays not at the end of path`\n )\n }\n return `[]`\n }\n\n return key\n })\n .join(`.`)\n\n subPluginPaths.add(normalizedPath)\n } catch (err) {\n console.log(err)\n }\n\n return value\n })\n }, `Gatsby specific subplugin validation`)\n .default([]),\n args: (schema: any, args: any): any => {\n if (\n args?.entry &&\n schema &&\n typeof schema === `object` &&\n schema.$_setFlag\n ) {\n return schema.$_setFlag(`entry`, args.entry, { clone: true })\n }\n return schema\n },\n }\n }),\n })\n\n // If rootDir and plugin.parentDir are the same, i.e. if this is a plugin a user configured in their gatsby-config.js (and not a sub-theme that added it), this will be \"\"\n // Otherwise, this will contain (and show) the relative path\n const configDir =\n (plugin.parentDir &&\n rootDir &&\n path.relative(rootDir, plugin.parentDir)) ||\n null\n\n if (!Joi.isSchema(optionsSchema) || optionsSchema.type !== `object`) {\n // Validate correct usage of pluginOptionsSchema\n reporter.warn(\n `Plugin \"${plugin.resolve}\" has an invalid options schema so we cannot verify your configuration for it.`\n )\n return plugin\n }\n\n try {\n if (!optionsSchema.describe().keys.plugins) {\n // All plugins have \"plugins: []\"\" added to their options in load.ts, even if they\n // do not have subplugins. We add plugins to the schema if it does not exist already\n // to make sure they pass validation.\n optionsSchema = optionsSchema.append({\n plugins: Joi.array().length(0),\n })\n }\n\n const { value, warning } = await validateOptionsSchema(\n optionsSchema,\n (plugin.options as IPluginInfoOptions) || {}\n )\n\n plugin.options = value\n\n // Handle unknown key warnings\n const validationWarnings = warning?.details\n\n if (validationWarnings?.length > 0) {\n reporter.warn(\n stripIndent(`\n Warning: there are unknown plugin options for \"${plugin.resolve}\"${\n configDir ? `, configured by ${configDir}` : ``\n }: ${validationWarnings\n .map(error => error.path.join(`.`))\n .join(`, `)}\n Please open an issue at https://ghub.io/${\n plugin.resolve\n } if you believe this option is valid.\n `)\n )\n trackCli(`UNKNOWN_PLUGIN_OPTION`, {\n name: plugin.resolve,\n valueString: validationWarnings\n .map(error => error.path.join(`.`))\n .join(`, `),\n })\n // We do not increment errors++ here as we do not want to process.exit if there are only warnings\n }\n\n // Validate subplugins\n if (plugin.options?.plugins) {\n const { errors: subErrors, plugins: subPlugins } =\n await validatePluginsOptions(\n plugin.options.plugins as Array<IPluginRefObject>,\n rootDir\n )\n plugin.options.plugins = subPlugins\n if (subPlugins.length > 0) {\n subPluginPaths.add(`plugins`)\n }\n errors += subErrors\n }\n if (subPluginPaths.size > 0) {\n plugin.subPluginPaths = Array.from(subPluginPaths)\n }\n } catch (error) {\n if (error instanceof Joi.ValidationError) {\n const validationErrors = error.details\n if (validationErrors.length > 0) {\n reporter.error({\n id: `11331`,\n context: {\n configDir,\n validationErrors,\n pluginName: plugin.resolve,\n },\n })\n errors++\n }\n return plugin\n }\n\n throw error\n }\n\n return plugin\n })\n )\n return { errors, plugins: newPlugins }\n}\n\nexport async function validateConfigPluginsOptions(\n config: ISiteConfig = {},\n rootDir: string\n): Promise<void> {\n if (!config.plugins) return\n\n const { errors, plugins } = await validatePluginsOptions(\n config.plugins,\n rootDir\n )\n\n config.plugins = plugins\n\n if (errors > 0) {\n process.exit(1)\n }\n}\n\n/**\n * Identify which APIs each plugin exports\n */\nexport function collatePluginAPIs({\n currentAPIs,\n flattenedPlugins,\n}: {\n currentAPIs: ICurrentAPIs\n flattenedPlugins: Array<IPluginInfo & Partial<IFlattenedPlugin>>\n}): { flattenedPlugins: Array<IFlattenedPlugin>; badExports: IEntryMap } {\n // Get a list of bad exports\n const badExports: IEntryMap = {\n node: [],\n browser: [],\n ssr: [],\n }\n\n flattenedPlugins.forEach(plugin => {\n plugin.nodeAPIs = []\n plugin.browserAPIs = []\n plugin.ssrAPIs = []\n\n // Discover which APIs this plugin implements and store an array against\n // the plugin node itself *and* in an API to plugins map for faster lookups\n // later.\n const pluginNodeExports = resolveModuleExports(\n plugin.resolvedCompiledGatsbyNode ?? `${plugin.resolve}/gatsby-node`,\n {\n mode: `require`,\n }\n )\n const pluginBrowserExports = resolveModuleExports(\n `${plugin.resolve}/gatsby-browser`\n )\n const pluginSSRExports = resolveModuleExports(\n `${plugin.resolve}/gatsby-ssr`\n )\n\n if (pluginNodeExports.length > 0) {\n plugin.nodeAPIs = _.intersection(pluginNodeExports, currentAPIs.node)\n badExports.node = badExports.node.concat(\n getBadExports(plugin, pluginNodeExports, currentAPIs.node)\n ) // Collate any bad exports\n }\n\n if (pluginBrowserExports.length > 0) {\n plugin.browserAPIs = _.intersection(\n pluginBrowserExports,\n currentAPIs.browser\n )\n badExports.browser = badExports.browser.concat(\n getBadExports(plugin, pluginBrowserExports, currentAPIs.browser)\n ) // Collate any bad exports\n }\n\n if (pluginSSRExports.length > 0) {\n plugin.ssrAPIs = _.intersection(pluginSSRExports, currentAPIs.ssr)\n badExports.ssr = badExports.ssr.concat(\n getBadExports(plugin, pluginSSRExports, currentAPIs.ssr)\n ) // Collate any bad exports\n }\n })\n\n return {\n flattenedPlugins: flattenedPlugins as Array<IFlattenedPlugin>,\n badExports,\n }\n}\n\nexport const handleMultipleReplaceRenderers = ({\n flattenedPlugins,\n}: {\n flattenedPlugins: Array<IFlattenedPlugin>\n}): Array<IFlattenedPlugin> => {\n // multiple replaceRenderers may cause problems at build time\n const rendererPlugins = flattenedPlugins\n .filter(plugin => plugin.ssrAPIs.includes(`replaceRenderer`))\n .map(plugin => plugin.name)\n if (rendererPlugins.length > 1) {\n if (rendererPlugins.includes(`default-site-plugin`)) {\n reporter.warn(`replaceRenderer API found in these plugins:`)\n reporter.warn(rendererPlugins.join(`, `))\n reporter.warn(\n `This might be an error, see: https://www.gatsbyjs.com/docs/debugging-replace-renderer-api/`\n )\n } else {\n console.log(``)\n reporter.error(\n `Gatsby's replaceRenderer API is implemented by multiple plugins:`\n )\n reporter.error(rendererPlugins.join(`, `))\n reporter.error(`This will break your build`)\n reporter.error(\n `See: https://www.gatsbyjs.com/docs/debugging-replace-renderer-api/`\n )\n if (process.env.NODE_ENV === `production`) process.exit(1)\n }\n\n // Now update plugin list so only final replaceRenderer will run\n const ignorable = rendererPlugins.slice(0, -1)\n\n // For each plugin in ignorable, set a skipSSR flag to true\n // This prevents apiRunnerSSR() from attempting to run it later\n const messages: Array<string> = []\n flattenedPlugins.forEach((fp, i) => {\n if (ignorable.includes(fp.name)) {\n messages.push(\n `Duplicate replaceRenderer found, skipping gatsby-ssr.js for plugin: ${fp.name}`\n )\n flattenedPlugins[i].skipSSR = true\n }\n })\n if (messages.length > 0) {\n console.log(``)\n messages.forEach(m => reporter.warn(m))\n console.log(``)\n }\n }\n\n return flattenedPlugins\n}\n\nexport function warnOnIncompatiblePeerDependency(\n name: string,\n packageJSON: PackageJson\n): void {\n // Note: In the future the peer dependency should be enforced for all plugins.\n const gatsbyPeerDependency = _.get(packageJSON, `peerDependencies.gatsby`)\n if (\n !isWorker &&\n gatsbyPeerDependency &&\n !semver.satisfies(gatsbyVersion, gatsbyPeerDependency, {\n includePrerelease: true,\n })\n ) {\n reporter.warn(\n `Plugin ${name} is not compatible with your gatsby version ${gatsbyVersion} - It requires gatsby@${gatsbyPeerDependency}`\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAQA;;;;;;AAuBA,MAAMA,uBAAuB,GAAIC,OAAD,IAC9BA,OAAO,CAACC,MAAR,CAAe,CAACC,OAAD,EAAUC,KAAV,KAAoB;EACjC,IAAIA,KAAK,CAACC,GAAN,IAAaD,KAAK,CAACC,GAAN,CAAUF,OAA3B,EAAoC;IAClC,OAAOG,MAAM,CAACC,EAAP,CAAUH,KAAK,CAACC,GAAN,CAAUF,OAApB,EAA6BA,OAAO,IAAK,OAAzC,IACHC,KAAK,CAACC,GAAN,CAAUF,OADP,GAEHA,OAFJ;EAGD;;EACD,OAAOA,OAAP;AACD,CAPD,EAOI,EAPJ,CADF,C,CAUA;AACA;;;AACA,SAASK,aAAT,CACEC,MADF,EAEEC,aAFF,EAGEC,IAHF,EAIiB;EACf,IAAIC,UAAyB,GAAG,EAAhC,CADe,CAEf;;EACAA,UAAU,GAAGA,UAAU,CAACC,MAAX,CACXC,eAAA,CAAEC,UAAF,CAAaL,aAAb,EAA4BC,IAA5B,EAAkCK,GAAlC,CAAsCC,CAAC,IAAI;IACzC,OAAO;MACLC,UAAU,EAAED,CADP;MAELE,UAAU,EAAEV,MAAM,CAACW,IAFd;MAGLC,aAAa,EAAEZ,MAAM,CAACN;IAHjB,CAAP;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ries","reduce","version","entry","api","semver","gt","getBadExports","plugin","pluginAPIKeys","apis","badExports","concat","map","e","exportName","pluginName","name","pluginVersion","getErrorContext","exportType","currentAPIs","latestAPIs","ex","gatsbyUpgradeVersion","errors","fixes","forEach","similarities","stringSimilarity","findBestMatch","isDefaultPlugin","message","push","bestMatch","rating","target","sourceMessage","length","filter","Boolean","join","handleBadExports","hasBadExports","Object","keys","find","getLatestAPIs","badItem","context","reporter","error","id","validatePluginsOptions","plugins","rootDir","newPlugins","Promise","all","gatsbyNode","resolvedPlugin","resolvePlugin","require","resolve","err","pluginOptionsSchema","subPluginPaths","Set","optionsSchema","Joi","extend","joi","type","base","array","items","alternatives","string","object","options","unknown","custom","arrayValue","helpers","schema","_flags","value","modulePath","module","normalizedPath","state","path","key","index","Array","isArray","ancestors","Error","add","console","log","default","args","$_setFlag","clone","configDir","parentDir","relative","isSchema","warn","describe","append","warning","validateOptionsSchema","validationWarnings","details","stripIndent","trackCli","valueString","subErrors","subPlugins","size","from","ValidationError","validationErrors","validateConfigPluginsOptions","config","process","exit","collatePluginAPIs","flattenedPlugins","node","browser","ssr","nodeAPIs","browserAPIs","ssrAPIs","pluginNodeExports","resolveModuleExports","resolvedCompiledGatsbyNode","mode","pluginBrowserExports","pluginSSRExports","handleMultipleReplaceRenderers","rendererPlugins","includes","env","NODE_ENV","ignorable","slice","messages","fp","i","skipSSR","m","warnOnIncompatiblePeerDependency","packageJSON","gatsbyPeerDependency","isWorker","satisfies","gatsbyVersion","includePrerelease"],"sources":["../../../src/bootstrap/load-plugins/validate.ts"],"sourcesContent":["import _ from \"lodash\"\nimport path from \"path\"\nimport * as semver from \"semver\"\nimport * as stringSimilarity from \"string-similarity\"\nimport { version as gatsbyVersion } from \"gatsby/package.json\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport { validateOptionsSchema, Joi } from \"gatsby-plugin-utils\"\nimport { IPluginRefObject } from \"gatsby-plugin-utils/dist/types\"\nimport { stripIndent } from \"common-tags\"\nimport { trackCli } from \"gatsby-telemetry\"\nimport { isWorker } from \"gatsby-worker\"\nimport { resolveModuleExports } from \"../resolve-module-exports\"\nimport { getLatestAPIs } from \"../../utils/get-latest-apis\"\nimport { GatsbyNode, PackageJson } from \"../../../\"\nimport {\n IPluginInfo,\n IFlattenedPlugin,\n IPluginInfoOptions,\n ISiteConfig,\n} from \"./types\"\nimport { resolvePlugin } from \"./resolve-plugin\"\n\ninterface IApi {\n version?: string\n}\n\nexport interface IEntry {\n exportName: string\n pluginName: string\n pluginVersion: string\n api?: IApi\n}\n\nexport type ExportType = \"node\" | \"browser\" | \"ssr\"\n\ntype IEntryMap = {\n [exportType in ExportType]: Array<IEntry>\n}\n\nexport type ICurrentAPIs = {\n [exportType in ExportType]: Array<string>\n}\n\nconst getGatsbyUpgradeVersion = (entries: ReadonlyArray<IEntry>): string =>\n entries.reduce((version, entry) => {\n if (entry.api && entry.api.version) {\n return semver.gt(entry.api.version, version || `0.0.0`)\n ? entry.api.version\n : version\n }\n return version\n }, ``)\n\n// Given a plugin object, an array of the API names it exports and an\n// array of valid API names, return an array of invalid API exports.\nfunction getBadExports(\n plugin: IPluginInfo,\n pluginAPIKeys: ReadonlyArray<string>,\n apis: ReadonlyArray<string>\n): Array<IEntry> {\n let badExports: Array<IEntry> = []\n // Discover any exports from plugins which are not \"known\"\n badExports = badExports.concat(\n _.difference(pluginAPIKeys, apis).map(e => {\n return {\n exportName: e,\n pluginName: plugin.name,\n pluginVersion: plugin.version,\n }\n })\n )\n return badExports\n}\n\nfunction getErrorContext(\n badExports: Array<IEntry>,\n exportType: ExportType,\n currentAPIs: ICurrentAPIs,\n latestAPIs: { [exportType in ExportType]: { [exportName: string]: IApi } }\n): {\n errors: Array<string>\n entries: Array<IEntry>\n exportType: ExportType\n fixes: Array<string>\n sourceMessage: string\n} {\n const entries = badExports.map(ex => {\n return {\n ...ex,\n api: latestAPIs[exportType][ex.exportName],\n }\n })\n\n const gatsbyUpgradeVersion = getGatsbyUpgradeVersion(entries)\n const errors: Array<string> = []\n const fixes = gatsbyUpgradeVersion\n ? [`npm install gatsby@^${gatsbyUpgradeVersion}`]\n : []\n\n entries.forEach(entry => {\n const similarities = stringSimilarity.findBestMatch(\n entry.exportName,\n currentAPIs[exportType]\n )\n const isDefaultPlugin = entry.pluginName == `default-site-plugin`\n\n const message = entry.api\n ? entry.api.version\n ? `was introduced in gatsby@${entry.api.version}`\n : `is not available in your version of Gatsby`\n : `is not a known API`\n\n if (isDefaultPlugin) {\n errors.push(\n `- Your local gatsby-${exportType}.js is using the API \"${entry.exportName}\" which ${message}.`\n )\n } else {\n errors.push(\n `- The plugin ${entry.pluginName}@${entry.pluginVersion} is using the API \"${entry.exportName}\" which ${message}.`\n )\n }\n\n if (similarities.bestMatch.rating > 0.5) {\n fixes.push(\n `Rename \"${entry.exportName}\" -> \"${similarities.bestMatch.target}\"`\n )\n }\n })\n\n return {\n errors,\n entries,\n exportType,\n fixes,\n // note: this is a fallback if gatsby-cli is not updated with structured error\n sourceMessage: [\n `Your plugins must export known APIs from their gatsby-node.js.`,\n ]\n .concat(errors)\n .concat(\n fixes.length > 0\n ? [`\\n`, `Some of the following may help fix the error(s):`, ...fixes]\n : []\n )\n .filter(Boolean)\n .join(`\\n`),\n }\n}\n\nexport async function handleBadExports({\n currentAPIs,\n badExports,\n}: {\n currentAPIs: ICurrentAPIs\n badExports: { [api in ExportType]: Array<IEntry> }\n}): Promise<void> {\n const hasBadExports = Object.keys(badExports).find(\n api => badExports[api].length > 0\n )\n if (hasBadExports) {\n const latestAPIs = await getLatestAPIs()\n // Output error messages for all bad exports\n _.toPairs(badExports).forEach(badItem => {\n const [exportType, entries] = badItem\n if (entries.length > 0) {\n const context = getErrorContext(\n entries,\n exportType as keyof typeof badExports,\n currentAPIs,\n latestAPIs\n )\n reporter.error({\n id: `11329`,\n context,\n })\n }\n })\n }\n}\n\nasync function validatePluginsOptions(\n plugins: Array<IPluginRefObject>,\n rootDir: string\n): Promise<{\n errors: number\n plugins: Array<IPluginRefObject>\n}> {\n let errors = 0\n const newPlugins = await Promise.all(\n plugins.map(async plugin => {\n let gatsbyNode\n try {\n const resolvedPlugin = resolvePlugin(plugin, rootDir)\n gatsbyNode = require(`${resolvedPlugin.resolve}/gatsby-node`)\n } catch (err) {\n gatsbyNode = {}\n }\n\n if (!gatsbyNode.pluginOptionsSchema) return plugin\n\n const subPluginPaths = new Set<string>()\n\n let optionsSchema = (\n gatsbyNode.pluginOptionsSchema as Exclude<\n GatsbyNode[\"pluginOptionsSchema\"],\n undefined\n >\n )({\n Joi: Joi.extend(joi => {\n return {\n type: `subPlugins`,\n base: joi\n .array()\n .items(\n joi.alternatives(\n joi.string(),\n joi.object({\n resolve: Joi.string(),\n options: Joi.object({}).unknown(true),\n })\n )\n )\n .custom((arrayValue, helpers) => {\n const entry = helpers.schema._flags.entry\n return arrayValue.map(value => {\n if (typeof value === `string`) {\n value = { resolve: value }\n }\n\n try {\n const resolvedPlugin = resolvePlugin(value, rootDir)\n const modulePath = require.resolve(\n `${resolvedPlugin.resolve}${entry ? `/${entry}` : ``}`\n )\n value.modulePath = modulePath\n value.module = require(modulePath)\n\n const normalizedPath = helpers.state.path\n .map((key, index) => {\n // if subplugin is part of an array - swap concrete index key with `[]`\n if (\n typeof key === `number` &&\n Array.isArray(\n helpers.state.ancestors[\n helpers.state.path.length - index - 1\n ]\n )\n ) {\n if (index !== helpers.state.path.length - 1) {\n throw new Error(\n `No support for arrays not at the end of path`\n )\n }\n return `[]`\n }\n\n return key\n })\n .join(`.`)\n\n subPluginPaths.add(normalizedPath)\n } catch (err) {\n console.log(err)\n }\n\n return value\n })\n }, `Gatsby specific subplugin validation`)\n .default([]),\n args: (schema: any, args: any): any => {\n if (\n args?.entry &&\n schema &&\n typeof schema === `object` &&\n schema.$_setFlag\n ) {\n return schema.$_setFlag(`entry`, args.entry, { clone: true })\n }\n return schema\n },\n }\n }),\n })\n\n // If rootDir and plugin.parentDir are the same, i.e. if this is a plugin a user configured in their gatsby-config.js (and not a sub-theme that added it), this will be \"\"\n // Otherwise, this will contain (and show) the relative path\n const configDir =\n (plugin.parentDir &&\n rootDir &&\n path.relative(rootDir, plugin.parentDir)) ||\n null\n\n if (!Joi.isSchema(optionsSchema) || optionsSchema.type !== `object`) {\n // Validate correct usage of pluginOptionsSchema\n reporter.warn(\n `Plugin \"${plugin.resolve}\" has an invalid options schema so we cannot verify your configuration for it.`\n )\n return plugin\n }\n\n try {\n if (!optionsSchema.describe().keys.plugins) {\n // All plugins have \"plugins: []\"\" added to their options in load.ts, even if they\n // do not have subplugins. We add plugins to the schema if it does not exist already\n // to make sure they pass validation.\n optionsSchema = optionsSchema.append({\n plugins: Joi.array().length(0),\n })\n }\n\n const { value, warning } = await validateOptionsSchema(\n optionsSchema,\n (plugin.options as IPluginInfoOptions) || {}\n )\n\n plugin.options = value\n\n // Handle unknown key warnings\n const validationWarnings = warning?.details\n\n if (validationWarnings?.length > 0) {\n reporter.warn(\n stripIndent(`\n Warning: there are unknown plugin options for \"${plugin.resolve}\"${\n configDir ? `, configured by ${configDir}` : ``\n }: ${validationWarnings\n .map(error => error.path.join(`.`))\n .join(`, `)}\n Please open an issue at https://ghub.io/${\n plugin.resolve\n } if you believe this option is valid.\n `)\n )\n trackCli(`UNKNOWN_PLUGIN_OPTION`, {\n name: plugin.resolve,\n valueString: validationWarnings\n .map(error => error.path.join(`.`))\n .join(`, `),\n })\n // We do not increment errors++ here as we do not want to process.exit if there are only warnings\n }\n\n // Validate subplugins\n if (plugin.options?.plugins) {\n const { errors: subErrors, plugins: subPlugins } =\n await validatePluginsOptions(\n plugin.options.plugins as Array<IPluginRefObject>,\n rootDir\n )\n plugin.options.plugins = subPlugins\n if (subPlugins.length > 0) {\n subPluginPaths.add(`plugins`)\n }\n errors += subErrors\n }\n if (subPluginPaths.size > 0) {\n plugin.subPluginPaths = Array.from(subPluginPaths)\n }\n } catch (error) {\n if (error instanceof Joi.ValidationError) {\n const validationErrors = error.details\n if (validationErrors.length > 0) {\n reporter.error({\n id: `11331`,\n context: {\n configDir,\n validationErrors,\n pluginName: plugin.resolve,\n },\n })\n errors++\n }\n return plugin\n }\n\n throw error\n }\n\n return plugin\n })\n )\n return { errors, plugins: newPlugins }\n}\n\nexport async function validateConfigPluginsOptions(\n config: ISiteConfig = {},\n rootDir: string\n): Promise<void> {\n if (!config.plugins) return\n\n const { errors, plugins } = await validatePluginsOptions(\n config.plugins,\n rootDir\n )\n\n config.plugins = plugins\n\n if (errors > 0) {\n process.exit(1)\n }\n}\n\n/**\n * Identify which APIs each plugin exports\n */\nexport function collatePluginAPIs({\n currentAPIs,\n flattenedPlugins,\n}: {\n currentAPIs: ICurrentAPIs\n flattenedPlugins: Array<IPluginInfo & Partial<IFlattenedPlugin>>\n}): { flattenedPlugins: Array<IFlattenedPlugin>; badExports: IEntryMap } {\n // Get a list of bad exports\n const badExports: IEntryMap = {\n node: [],\n browser: [],\n ssr: [],\n }\n\n flattenedPlugins.forEach(plugin => {\n plugin.nodeAPIs = []\n plugin.browserAPIs = []\n plugin.ssrAPIs = []\n\n // Discover which APIs this plugin implements and store an array against\n // the plugin node itself *and* in an API to plugins map for faster lookups\n // later.\n const pluginNodeExports = resolveModuleExports(\n plugin.resolvedCompiledGatsbyNode ?? `${plugin.resolve}/gatsby-node`,\n {\n mode: `require`,\n }\n )\n const pluginBrowserExports = resolveModuleExports(\n `${plugin.resolve}/gatsby-browser`\n )\n const pluginSSRExports = resolveModuleExports(\n `${plugin.resolve}/gatsby-ssr`\n )\n\n if (pluginNodeExports.length > 0) {\n plugin.nodeAPIs = _.intersection(pluginNodeExports, currentAPIs.node)\n badExports.node = badExports.node.concat(\n getBadExports(plugin, pluginNodeExports, currentAPIs.node)\n ) // Collate any bad exports\n }\n\n if (pluginBrowserExports.length > 0) {\n plugin.browserAPIs = _.intersection(\n pluginBrowserExports,\n currentAPIs.browser\n )\n badExports.browser = badExports.browser.concat(\n getBadExports(plugin, pluginBrowserExports, currentAPIs.browser)\n ) // Collate any bad exports\n }\n\n if (pluginSSRExports.length > 0) {\n plugin.ssrAPIs = _.intersection(pluginSSRExports, currentAPIs.ssr)\n badExports.ssr = badExports.ssr.concat(\n getBadExports(plugin, pluginSSRExports, currentAPIs.ssr)\n ) // Collate any bad exports\n }\n })\n\n return {\n flattenedPlugins: flattenedPlugins as Array<IFlattenedPlugin>,\n badExports,\n }\n}\n\nexport const handleMultipleReplaceRenderers = ({\n flattenedPlugins,\n}: {\n flattenedPlugins: Array<IFlattenedPlugin>\n}): Array<IFlattenedPlugin> => {\n // multiple replaceRenderers may cause problems at build time\n const rendererPlugins = flattenedPlugins\n .filter(plugin => plugin.ssrAPIs.includes(`replaceRenderer`))\n .map(plugin => plugin.name)\n if (rendererPlugins.length > 1) {\n if (rendererPlugins.includes(`default-site-plugin`)) {\n reporter.warn(`replaceRenderer API found in these plugins:`)\n reporter.warn(rendererPlugins.join(`, `))\n reporter.warn(\n `This might be an error, see: https://www.gatsbyjs.com/docs/debugging-replace-renderer-api/`\n )\n } else {\n console.log(``)\n reporter.error(\n `Gatsby's replaceRenderer API is implemented by multiple plugins:`\n )\n reporter.error(rendererPlugins.join(`, `))\n reporter.error(`This will break your build`)\n reporter.error(\n `See: https://www.gatsbyjs.com/docs/debugging-replace-renderer-api/`\n )\n if (process.env.NODE_ENV === `production`) process.exit(1)\n }\n\n // Now update plugin list so only final replaceRenderer will run\n const ignorable = rendererPlugins.slice(0, -1)\n\n // For each plugin in ignorable, set a skipSSR flag to true\n // This prevents apiRunnerSSR() from attempting to run it later\n const messages: Array<string> = []\n flattenedPlugins.forEach((fp, i) => {\n if (ignorable.includes(fp.name)) {\n messages.push(\n `Duplicate replaceRenderer found, skipping gatsby-ssr.js for plugin: ${fp.name}`\n )\n flattenedPlugins[i].skipSSR = true\n }\n })\n if (messages.length > 0) {\n console.log(``)\n messages.forEach(m => reporter.warn(m))\n console.log(``)\n }\n }\n\n return flattenedPlugins\n}\n\nexport function warnOnIncompatiblePeerDependency(\n name: string,\n packageJSON: PackageJson\n): void {\n // Note: In the future the peer dependency should be enforced for all plugins.\n const gatsbyPeerDependency = _.get(packageJSON, `peerDependencies.gatsby`)\n if (\n !isWorker &&\n gatsbyPeerDependency &&\n !semver.satisfies(gatsbyVersion, gatsbyPeerDependency, {\n includePrerelease: true,\n })\n ) {\n reporter.warn(\n `Plugin ${name} is not compatible with your gatsby version ${gatsbyVersion} - It requires gatsby@${gatsbyPeerDependency}`\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAQA;;;;;;AAuBA,MAAMA,uBAAuB,GAAIC,OAAD,IAC9BA,OAAO,CAACC,MAAR,CAAe,CAACC,OAAD,EAAUC,KAAV,KAAoB;EACjC,IAAIA,KAAK,CAACC,GAAN,IAAaD,KAAK,CAACC,GAAN,CAAUF,OAA3B,EAAoC;IAClC,OAAOG,MAAM,CAACC,EAAP,CAAUH,KAAK,CAACC,GAAN,CAAUF,OAApB,EAA6BA,OAAO,IAAK,OAAzC,IACHC,KAAK,CAACC,GAAN,CAAUF,OADP,GAEHA,OAFJ;EAGD;;EACD,OAAOA,OAAP;AACD,CAPD,EAOI,EAPJ,CADF,C,CAUA;AACA;;;AACA,SAASK,aAAT,CACEC,MADF,EAEEC,aAFF,EAGEC,IAHF,EAIiB;EACf,IAAIC,UAAyB,GAAG,EAAhC,CADe,CAEf;;EACAA,UAAU,GAAGA,UAAU,CAACC,MAAX,CACX,0BAAaH,aAAb,EAA4BC,IAA5B,EAAkCG,GAAlC,CAAsCC,CAAC,IAAI;IACzC,OAAO;MACLC,UAAU,EAAED,CADP;MAELE,UAAU,EAAER,MAAM,CAACS,IAFd;MAGLC,aAAa,EAAEV,MAAM,CAACN;IAHjB,CAAP;EAKD,CAND,CADW,CAAb;EASA,OAAOS,UAAP;AACD;;AAED,SAASQ,eAAT,CACER,UADF,EAEES,UAFF,EAGEC,WAHF,EAIEC,UAJF,EA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