gatsby 4.17.0 → 4.18.0-alpha-engine-functions.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/get-config-file.js +27 -8
- package/dist/bootstrap/get-config-file.js.map +1 -1
- package/dist/bootstrap/load-plugins/load-internal-plugins.js +31 -8
- package/dist/bootstrap/load-plugins/load-internal-plugins.js.map +1 -1
- package/dist/bootstrap/load-plugins/process-plugin.js +29 -8
- package/dist/bootstrap/load-plugins/process-plugin.js.map +1 -1
- package/dist/bootstrap/load-plugins/resolve-plugin.js +7 -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/utils/handle-gatsby-cloud.js +4 -1
- package/dist/bootstrap/load-plugins/utils/handle-gatsby-cloud.js.map +1 -1
- package/dist/bootstrap/load-plugins/validate.js +23 -8
- 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/resolve-module-exports.js +22 -1
- package/dist/bootstrap/resolve-module-exports.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.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.js.map +1 -1
- package/dist/schema/graphql-engine/bundle-webpack.js +14 -10
- package/dist/schema/graphql-engine/bundle-webpack.js.map +1 -1
- package/dist/schema/graphql-engine/entry.js +30 -4
- package/dist/schema/graphql-engine/entry.js.map +1 -1
- package/dist/schema/graphql-engine/print-plugins.js +17 -6
- 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.js +115 -0
- package/dist/utils/dev-ssr/parse-error.js.map +1 -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.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.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.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/require-gatsby-config.js +20 -0
- package/dist/utils/require-gatsby-config.js.map +1 -0
- package/dist/utils/require-gatsby-plugin.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/validate-engines/index.js +2 -2
- package/dist/utils/validate-engines/index.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
- package/dist/bootstrap/__mocks__/get-config/ts-dir/gatsby-config.d.ts +0 -3
- package/dist/bootstrap/__mocks__/resolve-module-exports.d.ts +0 -1
- package/dist/bootstrap/create-graphql-runner.d.ts +0 -10
- package/dist/bootstrap/get-config-file.d.ts +0 -5
- package/dist/bootstrap/index.d.ts +0 -10
- package/dist/bootstrap/load-config/index.d.ts +0 -7
- package/dist/bootstrap/load-plugins/index.d.ts +0 -3
- package/dist/bootstrap/load-plugins/load-internal-plugins.d.ts +0 -2
- package/dist/bootstrap/load-plugins/process-plugin.d.ts +0 -2
- package/dist/bootstrap/load-plugins/resolve-plugin.d.ts +0 -13
- package/dist/bootstrap/load-plugins/types.d.ts +0 -48
- package/dist/bootstrap/load-plugins/utils/check-local-plugin.d.ts +0 -8
- package/dist/bootstrap/load-plugins/utils/create-hash.d.ts +0 -1
- package/dist/bootstrap/load-plugins/utils/create-id.d.ts +0 -10
- package/dist/bootstrap/load-plugins/utils/flatten-plugins.d.ts +0 -2
- package/dist/bootstrap/load-plugins/utils/get-api.d.ts +0 -12
- package/dist/bootstrap/load-plugins/utils/handle-gatsby-cloud.d.ts +0 -6
- package/dist/bootstrap/load-plugins/utils/normalize.d.ts +0 -5
- package/dist/bootstrap/load-plugins/validate.d.ts +0 -40
- package/dist/bootstrap/log-line-function.d.ts +0 -0
- package/dist/bootstrap/prefer-default.d.ts +0 -1
- package/dist/bootstrap/redirects-writer.d.ts +0 -2
- package/dist/bootstrap/remove-stale-jobs.d.ts +0 -2
- package/dist/bootstrap/requires-writer.d.ts +0 -10
- package/dist/bootstrap/resolve-module-exports.d.ts +0 -14
- package/dist/bootstrap/schema-hot-reloader.d.ts +0 -3
- package/dist/cache/cache-fs.d.ts +0 -1
- package/dist/cache/json-file-store.d.ts +0 -8
- package/dist/cache/wrap-callback.d.ts +0 -0
- package/dist/commands/build-html.d.ts +0 -55
- package/dist/commands/build-javascript.d.ts +0 -4
- package/dist/commands/build-utils.d.ts +0 -8
- package/dist/commands/build.d.ts +0 -1
- package/dist/commands/clean.d.ts +0 -1
- package/dist/commands/develop-process.d.ts +0 -1
- package/dist/commands/develop-static.d.ts +0 -3
- package/dist/commands/develop.d.ts +0 -2
- package/dist/commands/feedback.d.ts +0 -1
- package/dist/commands/repl.d.ts +0 -1
- package/dist/commands/serve.d.ts +0 -1
- package/dist/commands/types.d.ts +0 -48
- package/dist/constants.d.ts +0 -1
- package/dist/datastore/common/iterable.d.ts +0 -51
- package/dist/datastore/common/query.d.ts +0 -69
- package/dist/datastore/datastore.d.ts +0 -4
- package/dist/datastore/in-memory/in-memory-datastore.d.ts +0 -2
- package/dist/datastore/in-memory/indexing.d.ts +0 -79
- package/dist/datastore/in-memory/run-fast-filters.d.ts +0 -27
- package/dist/datastore/index.d.ts +0 -20
- package/dist/datastore/lmdb/lmdb-datastore.d.ts +0 -13
- package/dist/datastore/lmdb/query/common.d.ts +0 -23
- package/dist/datastore/lmdb/query/create-index.d.ts +0 -25
- package/dist/datastore/lmdb/query/filter-using-index.d.ts +0 -43
- package/dist/datastore/lmdb/query/run-query.d.ts +0 -9
- package/dist/datastore/lmdb/query/suggest-index.d.ts +0 -15
- package/dist/datastore/lmdb/updates/nodes-by-type.d.ts +0 -3
- package/dist/datastore/lmdb/updates/nodes.d.ts +0 -5
- package/dist/datastore/types.d.ts +0 -47
- package/dist/internal-plugins/functions/config.d.ts +0 -12
- package/dist/internal-plugins/functions/gatsby-node.d.ts +0 -3
- package/dist/internal-plugins/functions/middleware.d.ts +0 -9
- package/dist/internal-plugins/partytown/gatsby-node.d.ts +0 -2
- package/dist/internal-plugins/partytown/proxy.d.ts +0 -3
- package/dist/internal.d.ts +0 -5
- package/dist/joi-schemas/joi.d.ts +0 -5
- package/dist/query/error-parser.d.ts +0 -19
- package/dist/query/graphql-errors-codeframe.d.ts +0 -1
- package/dist/query/graphql-runner.d.ts +0 -38
- package/dist/query/graphql-span-tracer.d.ts +0 -19
- package/dist/query/index.d.ts +0 -26
- package/dist/query/query-runner.d.ts +0 -13
- package/dist/query/query-watcher.d.ts +0 -17
- package/dist/query/types.d.ts +0 -35
- package/dist/query/utils.d.ts +0 -4
- package/dist/redux/actions/add-page-dependency.d.ts +0 -7
- package/dist/redux/actions/index.d.ts +0 -14
- package/dist/redux/actions/internal.d.ts +0 -124
- package/dist/redux/actions/restricted.d.ts +0 -293
- package/dist/redux/index.d.ts +0 -20
- package/dist/redux/persist.d.ts +0 -5
- package/dist/redux/plugin-runner.d.ts +0 -1
- package/dist/redux/reducers/babelrc.d.ts +0 -9
- package/dist/redux/reducers/components.d.ts +0 -2
- package/dist/redux/reducers/config.d.ts +0 -2
- package/dist/redux/reducers/definitions.d.ts +0 -2
- package/dist/redux/reducers/flattened-plugins.d.ts +0 -17
- package/dist/redux/reducers/functions.d.ts +0 -2
- package/dist/redux/reducers/html.d.ts +0 -8
- package/dist/redux/reducers/index.d.ts +0 -38
- package/dist/redux/reducers/inference-metadata.d.ts +0 -7
- package/dist/redux/reducers/jobs.d.ts +0 -5
- package/dist/redux/reducers/jobsv2.d.ts +0 -6
- package/dist/redux/reducers/last-action.d.ts +0 -2
- package/dist/redux/reducers/node-manifest.d.ts +0 -2
- package/dist/redux/reducers/nodes-by-type.d.ts +0 -2
- package/dist/redux/reducers/nodes-touched.d.ts +0 -3
- package/dist/redux/reducers/nodes.d.ts +0 -2
- package/dist/redux/reducers/page-data-stats.d.ts +0 -2
- package/dist/redux/reducers/pages.d.ts +0 -2
- package/dist/redux/reducers/pending-page-data-writes.d.ts +0 -4
- package/dist/redux/reducers/program.d.ts +0 -2
- package/dist/redux/reducers/queries.d.ts +0 -26
- package/dist/redux/reducers/redirects.d.ts +0 -2
- package/dist/redux/reducers/resolved-nodes.d.ts +0 -2
- package/dist/redux/reducers/schema-customization.d.ts +0 -23
- package/dist/redux/reducers/schema.d.ts +0 -3
- package/dist/redux/reducers/set-request-headers.d.ts +0 -7
- package/dist/redux/reducers/static-queries-by-template.d.ts +0 -2
- package/dist/redux/reducers/static-query-components.d.ts +0 -2
- package/dist/redux/reducers/status.d.ts +0 -6
- package/dist/redux/reducers/telemetry.d.ts +0 -2
- package/dist/redux/reducers/visited-page.d.ts +0 -2
- package/dist/redux/reducers/webpack-compilation-hash.d.ts +0 -2
- package/dist/redux/reducers/webpack.d.ts +0 -2
- package/dist/redux/types.d.ts +0 -832
- package/dist/schema/context.d.ts +0 -14
- package/dist/schema/graphql-engine/bundle-webpack.d.ts +0 -5
- package/dist/schema/graphql-engine/entry.d.ts +0 -19
- package/dist/schema/graphql-engine/lmdb-bundling-patch.d.ts +0 -1
- package/dist/schema/graphql-engine/print-plugins.d.ts +0 -2
- package/dist/schema/graphql-engine/standalone-regenerate.d.ts +0 -2
- package/dist/schema/graphql-engine/webpack-remove-apis-loader.d.ts +0 -1
- package/dist/schema/infer/build-example-data.d.ts +0 -5
- package/dist/schema/infer/inference-metadata.d.ts +0 -72
- package/dist/schema/infer/is-file.d.ts +0 -1
- package/dist/schema/infer/type-conflict-reporter.d.ts +0 -28
- package/dist/schema/print.d.ts +0 -20
- package/dist/schema/resolvers.d.ts +0 -37
- package/dist/schema/schema-composer.d.ts +0 -3
- package/dist/schema/type-definitions.d.ts +0 -47
- package/dist/schema/types/built-in-types.d.ts +0 -5
- package/dist/schema/types/date.d.ts +0 -37
- package/dist/schema/types/derived-types.d.ts +0 -45
- package/dist/schema/types/filter.d.ts +0 -12
- package/dist/schema/types/media.d.ts +0 -2
- package/dist/schema/types/node-interface.d.ts +0 -14
- package/dist/schema/types/pagination.d.ts +0 -16
- package/dist/schema/types/remote-file-interface.d.ts +0 -3
- package/dist/schema/types/sort.d.ts +0 -18
- package/dist/schema/types/type-builders.d.ts +0 -36
- package/dist/services/build-schema.d.ts +0 -2
- package/dist/services/calculate-dirty-queries.d.ts +0 -5
- package/dist/services/create-pages.d.ts +0 -5
- package/dist/services/customize-schema.d.ts +0 -2
- package/dist/services/extract-queries.d.ts +0 -2
- package/dist/services/graphql-typegen.d.ts +0 -2
- package/dist/services/index.d.ts +0 -18
- package/dist/services/initialize.d.ts +0 -8
- package/dist/services/listen-for-mutations.d.ts +0 -2
- package/dist/services/listen-to-webpack.d.ts +0 -3
- package/dist/services/post-bootstrap.d.ts +0 -2
- package/dist/services/recompile.d.ts +0 -3
- package/dist/services/run-mutation-batch.d.ts +0 -2
- package/dist/services/run-page-queries.d.ts +0 -2
- package/dist/services/run-static-queries.d.ts +0 -2
- package/dist/services/source-nodes.d.ts +0 -5
- package/dist/services/start-webpack-server.d.ts +0 -9
- package/dist/services/types.d.ts +0 -52
- package/dist/services/write-out-redirects.d.ts +0 -2
- package/dist/services/write-out-requires.d.ts +0 -2
- package/dist/state-machines/data-layer/actions.d.ts +0 -8
- package/dist/state-machines/data-layer/index.d.ts +0 -24
- package/dist/state-machines/data-layer/services.d.ts +0 -3
- package/dist/state-machines/data-layer/types.d.ts +0 -27
- package/dist/state-machines/develop/actions.d.ts +0 -40
- package/dist/state-machines/develop/index.d.ts +0 -6
- package/dist/state-machines/develop/services.d.ts +0 -3
- package/dist/state-machines/index.d.ts +0 -7
- package/dist/state-machines/query-running/actions.d.ts +0 -9
- package/dist/state-machines/query-running/index.d.ts +0 -7
- package/dist/state-machines/query-running/services.d.ts +0 -3
- package/dist/state-machines/query-running/types.d.ts +0 -26
- package/dist/state-machines/waiting/actions.d.ts +0 -11
- package/dist/state-machines/waiting/index.d.ts +0 -12
- package/dist/state-machines/waiting/services.d.ts +0 -3
- package/dist/state-machines/waiting/types.d.ts +0 -12
- package/dist/types.d.ts +0 -9
- package/dist/utils/api-browser-docs.d.ts +0 -242
- package/dist/utils/api-node-docs.d.ts +0 -470
- package/dist/utils/api-runner-error-parser.d.ts +0 -5
- package/dist/utils/app-data.d.ts +0 -2
- package/dist/utils/assert-store.d.ts +0 -2
- package/dist/utils/babel/babel-module-exports-helpers.d.ts +0 -22
- package/dist/utils/babel/babel-plugin-remove-api.d.ts +0 -5
- package/dist/utils/babel-parse-to-ast.d.ts +0 -4
- package/dist/utils/batcher.d.ts +0 -15
- package/dist/utils/browserslist.d.ts +0 -2
- package/dist/utils/cache-lmdb.d.ts +0 -19
- package/dist/utils/cache.d.ts +0 -17
- package/dist/utils/call-deferred-api.d.ts +0 -8
- package/dist/utils/changed-pages.d.ts +0 -6
- package/dist/utils/clear-require-cache.d.ts +0 -1
- package/dist/utils/client-assets-for-template.d.ts +0 -9
- package/dist/utils/create-node-id.d.ts +0 -24
- package/dist/utils/create-schema-customization.d.ts +0 -6
- package/dist/utils/detect-node-mutations.d.ts +0 -4
- package/dist/utils/detect-port-in-use-and-prompt.d.ts +0 -1
- package/dist/utils/dev-ssr/render-dev-html.d.ts +0 -23
- package/dist/utils/develop-preload-headers.d.ts +0 -7
- package/dist/utils/develop-proxy.d.ts +0 -15
- package/dist/utils/did-you-mean.d.ts +0 -3
- package/dist/utils/engine-context.d.ts +0 -5
- package/dist/utils/engines-fs-provider.d.ts +0 -9
- package/dist/utils/engines-helpers.d.ts +0 -2
- package/dist/utils/eslint-config.d.ts +0 -4
- package/dist/utils/eslint-rules/limited-exports-page-templates.d.ts +0 -1
- package/dist/utils/eslint-rules/no-anonymous-exports-page-templates.d.ts +0 -1
- package/dist/utils/eslint-rules-helpers.d.ts +0 -4
- package/dist/utils/express-middlewares.d.ts +0 -4
- package/dist/utils/fast-refresh-module.d.ts +0 -22
- package/dist/utils/feedback.d.ts +0 -5
- package/dist/utils/find-page-by-path.d.ts +0 -2
- package/dist/utils/flags.d.ts +0 -41
- package/dist/utils/gatsby-cloud-config.d.ts +0 -4
- package/dist/utils/gatsby-dependents.d.ts +0 -8
- package/dist/utils/gatsby-webpack-eslint-graphql-schema-reload-plugin.d.ts +0 -8
- package/dist/utils/gatsby-webpack-stats-extractor.d.ts +0 -6
- package/dist/utils/gatsby-webpack-virtual-modules.d.ts +0 -6
- package/dist/utils/get-cache.d.ts +0 -2
- package/dist/utils/get-latest-apis.d.ts +0 -6
- package/dist/utils/get-page-data.d.ts +0 -3
- package/dist/utils/get-public-path.d.ts +0 -5
- package/dist/utils/get-server-data.d.ts +0 -19
- package/dist/utils/get-ssl-cert.d.ts +0 -9
- package/dist/utils/get-static-dir.d.ts +0 -12
- package/dist/utils/get-value-at.d.ts +0 -1
- package/dist/utils/graphql-typegen/file-writes.d.ts +0 -5
- package/dist/utils/graphql-typegen/ts-codegen.d.ts +0 -3
- package/dist/utils/graphql-typegen/utils.d.ts +0 -11
- package/dist/utils/handle-flags.d.ts +0 -8
- package/dist/utils/is-32-bit-integer.d.ts +0 -1
- package/dist/utils/jobs/manager.d.ts +0 -34
- package/dist/utils/jobs/types.d.ts +0 -63
- package/dist/utils/jobs/worker-messaging.d.ts +0 -10
- package/dist/utils/js-chunk-names.d.ts +0 -1
- package/dist/utils/loading-indicator.d.ts +0 -3
- package/dist/utils/local-eslint-config-finder.d.ts +0 -1
- package/dist/utils/merge-gatsby-config.d.ts +0 -27
- package/dist/utils/mett.d.ts +0 -10
- package/dist/utils/module-resolver.d.ts +0 -3
- package/dist/utils/node-manifest.d.ts +0 -45
- package/dist/utils/nodes.d.ts +0 -13
- package/dist/utils/normalize-path.d.ts +0 -2
- package/dist/utils/page-data-helpers.d.ts +0 -14
- package/dist/utils/page-data.d.ts +0 -19
- package/dist/utils/page-mode.d.ts +0 -18
- package/dist/utils/page-ssr-module/bundle-webpack.d.ts +0 -17
- package/dist/utils/page-ssr-module/entry.d.ts +0 -43
- package/dist/utils/parcel/compile-gatsby-files.d.ts +0 -18
- package/dist/utils/path.d.ts +0 -5
- package/dist/utils/prepare-regex.d.ts +0 -1
- package/dist/utils/prepare-urls.d.ts +0 -7
- package/dist/utils/print-instructions.d.ts +0 -2
- package/dist/utils/reach-router-add-basecontext-export-loader.d.ts +0 -1
- package/dist/utils/report-once.d.ts +0 -1
- package/dist/utils/require-gatsby-plugin.d.ts +0 -9
- package/dist/utils/restarting-screen.d.ts +0 -2
- package/dist/utils/sample-site-for-experiment.d.ts +0 -2
- package/dist/utils/show-experiment-notice.d.ts +0 -6
- package/dist/utils/source-nodes.d.ts +0 -8
- package/dist/utils/stack-trace-utils.d.ts +0 -24
- package/dist/utils/start-server.d.ts +0 -22
- package/dist/utils/state-machine-logging.d.ts +0 -2
- package/dist/utils/static-query-utils.d.ts +0 -16
- package/dist/utils/telemetry-server.d.ts +0 -1
- package/dist/utils/test-require-error.d.ts +0 -1
- package/dist/utils/tracer/index.d.ts +0 -12
- package/dist/utils/tracer/jaeger-local.d.ts +0 -4
- package/dist/utils/tracer/zipkin-local.d.ts +0 -11
- package/dist/utils/validate-engines/child.d.ts +0 -1
- package/dist/utils/validate-engines/index.d.ts +0 -1
- package/dist/utils/validate-page-component.d.ts +0 -12
- package/dist/utils/wait-until-jobs-complete.d.ts +0 -2
- package/dist/utils/webpack/bundle.d.ts +0 -9
- package/dist/utils/webpack/plugins/cache-folder-resolver.d.ts +0 -9
- package/dist/utils/webpack/plugins/corejs-resolver.d.ts +0 -12
- package/dist/utils/webpack/plugins/force-css-hmr-for-edge-cases.d.ts +0 -22
- package/dist/utils/webpack/plugins/static-query-mapper.d.ts +0 -7
- package/dist/utils/webpack/plugins/webpack-logging.d.ts +0 -12
- package/dist/utils/webpack-error-utils.d.ts +0 -24
- package/dist/utils/webpack-plugins.d.ts +0 -46
- package/dist/utils/webpack-status.d.ts +0 -3
- package/dist/utils/webpack-utils.d.ts +0 -121
- package/dist/utils/websocket-manager.d.ts +0 -40
- package/dist/utils/worker/child/index.d.ts +0 -5
- package/dist/utils/worker/child/load-config-and-plugins.d.ts +0 -2
- package/dist/utils/worker/child/queries.d.ts +0 -7
- package/dist/utils/worker/child/render-html.d.ts +0 -21
- package/dist/utils/worker/child/schema.d.ts +0 -2
- package/dist/utils/worker/child/state.d.ts +0 -2
- package/dist/utils/worker/messaging.d.ts +0 -8
- package/dist/utils/worker/pool.d.ts +0 -10
- package/dist/utils/worker/reporter.d.ts +0 -3
- package/dist/utils/worker/types.d.ts +0 -3
|
@@ -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
|
}
|
|
@@ -20,6 +20,8 @@ var _fsExistsCached = require("fs-exists-cached");
|
|
|
20
20
|
|
|
21
21
|
var _compileGatsbyFiles = require("../utils/parcel/compile-gatsby-files");
|
|
22
22
|
|
|
23
|
+
var _requireGatsbyConfig = require("../utils/require-gatsby-config");
|
|
24
|
+
|
|
23
25
|
function isNearMatch(fileName, configName, distance) {
|
|
24
26
|
if (!fileName) return false;
|
|
25
27
|
return (0, _fastestLevenshtein.distance)(fileName, configName) <= distance;
|
|
@@ -28,14 +30,24 @@ function isNearMatch(fileName, configName, distance) {
|
|
|
28
30
|
async function getConfigFile(siteDirectory, configName, distance = 3) {
|
|
29
31
|
let configPath = ``;
|
|
30
32
|
let configFilePath = ``;
|
|
31
|
-
let configModule;
|
|
33
|
+
let configModule;
|
|
34
|
+
|
|
35
|
+
const absoluteConfigPath = _path.default.join(siteDirectory, configName); // Attempt to find compiled gatsby-config.js in .cache/compiled/gatsby-config.js
|
|
36
|
+
|
|
32
37
|
|
|
33
38
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const configModuleFromCache = (0, _requireGatsbyConfig.requireGatsbyConfig)(absoluteConfigPath);
|
|
40
|
+
|
|
41
|
+
if (configModuleFromCache) {
|
|
42
|
+
configModule = configModuleFromCache;
|
|
43
|
+
} else {
|
|
44
|
+
configPath = _path.default.join(`${siteDirectory}/${_compileGatsbyFiles.COMPILED_CACHE_DIR}`, configName);
|
|
45
|
+
configFilePath = require.resolve(configPath);
|
|
46
|
+
configModule = require(configFilePath);
|
|
47
|
+
(0, _requireGatsbyConfig.setGatsbyConfigCache)(absoluteConfigPath, configModule);
|
|
48
|
+
}
|
|
37
49
|
} catch (outerError) {
|
|
38
|
-
var _outerError$requireSt, _outerError$requireSt2, _outerError$requireSt3;
|
|
50
|
+
var _ref, _outerError$requireSt, _outerError$requireSt2, _outerError$requireSt3, _outerError$requireSt4;
|
|
39
51
|
|
|
40
52
|
// Not all plugins will have a compiled file, so the err.message can look like this:
|
|
41
53
|
// "Cannot find module '<root>/node_modules/gatsby-source-filesystem/.cache/compiled/gatsby-config'"
|
|
@@ -43,7 +55,7 @@ async function getConfigFile(siteDirectory, configName, distance = 3) {
|
|
|
43
55
|
// "Cannot find module 'foobar'"
|
|
44
56
|
// So this is trying to differentiate between an error we're fine ignoring and an error that we should throw
|
|
45
57
|
const isModuleNotFoundError = outerError.code === `MODULE_NOT_FOUND`;
|
|
46
|
-
const isThisFileRequireError = (
|
|
58
|
+
const isThisFileRequireError = (_ref = (outerError === null || outerError === void 0 ? void 0 : (_outerError$requireSt = outerError.requireStack) === null || _outerError$requireSt === void 0 ? void 0 : (_outerError$requireSt2 = _outerError$requireSt[0]) === null || _outerError$requireSt2 === void 0 ? void 0 : _outerError$requireSt2.includes(`get-config-file`)) || (outerError === null || outerError === void 0 ? void 0 : (_outerError$requireSt3 = outerError.requireStack) === null || _outerError$requireSt3 === void 0 ? void 0 : (_outerError$requireSt4 = _outerError$requireSt3[0]) === null || _outerError$requireSt4 === void 0 ? void 0 : _outerError$requireSt4.includes(`query-engine`))) !== null && _ref !== void 0 ? _ref : true; // User's module require error inside gatsby-config.js
|
|
47
59
|
|
|
48
60
|
if (!(isModuleNotFoundError && isThisFileRequireError)) {
|
|
49
61
|
_reporter.default.panic({
|
|
@@ -60,8 +72,15 @@ async function getConfigFile(siteDirectory, configName, distance = 3) {
|
|
|
60
72
|
configPath = _path.default.join(siteDirectory, configName);
|
|
61
73
|
|
|
62
74
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
const configModuleFromCache = (0, _requireGatsbyConfig.requireGatsbyConfig)(absoluteConfigPath);
|
|
76
|
+
|
|
77
|
+
if (configModuleFromCache) {
|
|
78
|
+
configModule = configModuleFromCache;
|
|
79
|
+
} else {
|
|
80
|
+
configFilePath = require.resolve(configPath);
|
|
81
|
+
configModule = require(configFilePath);
|
|
82
|
+
(0, _requireGatsbyConfig.setGatsbyConfigCache)(absoluteConfigPath, configModule);
|
|
83
|
+
}
|
|
65
84
|
} catch (innerError) {
|
|
66
85
|
// Some other error that is not a require error
|
|
67
86
|
if (!(0, _testRequireError.testRequireError)(configPath, innerError)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-config-file.js","names":["isNearMatch","fileName","configName","distance","levenshtein","getConfigFile","siteDirectory","configPath","configFilePath","configModule","path","join","COMPILED_CACHE_DIR","require","resolve","outerError","isModuleNotFoundError","code","isThisFileRequireError","requireStack","includes","report","panic","id","error","context","message","innerError","testRequireError","files","fs","readdir","tsConfig","nearMatch","file","name","ext","parse","existsSync"],"sources":["../../src/bootstrap/get-config-file.ts"],"sourcesContent":["import { distance as levenshtein } from \"fastest-levenshtein\"\nimport fs from \"fs-extra\"\nimport { testRequireError } from \"../utils/test-require-error\"\nimport report from \"gatsby-cli/lib/reporter\"\nimport path from \"path\"\nimport { sync as existsSync } from \"fs-exists-cached\"\nimport { COMPILED_CACHE_DIR } from \"../utils/parcel/compile-gatsby-files\"\n\nexport function isNearMatch(\n fileName: string | undefined,\n configName: string,\n distance: number\n): boolean {\n if (!fileName) return false\n return levenshtein(fileName, configName) <= distance\n}\n\nexport async function getConfigFile(\n siteDirectory: string,\n configName: string,\n distance: number = 3\n): Promise<{\n configModule: any\n configFilePath: string\n}> {\n let configPath = ``\n let configFilePath = ``\n let configModule: any\n\n // Attempt to find compiled gatsby-config.js in .cache/compiled/gatsby-config.js\n try {\n configPath = path.join(`${siteDirectory}/${COMPILED_CACHE_DIR}
|
|
1
|
+
{"version":3,"file":"get-config-file.js","names":["isNearMatch","fileName","configName","distance","levenshtein","getConfigFile","siteDirectory","configPath","configFilePath","configModule","absoluteConfigPath","path","join","configModuleFromCache","requireGatsbyConfig","COMPILED_CACHE_DIR","require","resolve","setGatsbyConfigCache","outerError","isModuleNotFoundError","code","isThisFileRequireError","requireStack","includes","report","panic","id","error","context","message","innerError","testRequireError","files","fs","readdir","tsConfig","nearMatch","file","name","ext","parse","existsSync"],"sources":["../../src/bootstrap/get-config-file.ts"],"sourcesContent":["import { distance as levenshtein } from \"fastest-levenshtein\"\nimport fs from \"fs-extra\"\nimport { testRequireError } from \"../utils/test-require-error\"\nimport report from \"gatsby-cli/lib/reporter\"\nimport path from \"path\"\nimport { sync as existsSync } from \"fs-exists-cached\"\nimport { COMPILED_CACHE_DIR } from \"../utils/parcel/compile-gatsby-files\"\nimport {\n setGatsbyConfigCache,\n requireGatsbyConfig,\n} from \"../utils/require-gatsby-config\"\n\nexport function isNearMatch(\n fileName: string | undefined,\n configName: string,\n distance: number\n): boolean {\n if (!fileName) return false\n return levenshtein(fileName, configName) <= distance\n}\n\nexport async function getConfigFile(\n siteDirectory: string,\n configName: string,\n distance: number = 3\n): Promise<{\n configModule: any\n configFilePath: string\n}> {\n let configPath = ``\n let configFilePath = ``\n let configModule: any\n const absoluteConfigPath = path.join(siteDirectory, configName)\n\n // Attempt to find compiled gatsby-config.js in .cache/compiled/gatsby-config.js\n try {\n const configModuleFromCache = requireGatsbyConfig(absoluteConfigPath)\n if (configModuleFromCache) {\n configModule = configModuleFromCache\n } else {\n configPath = path.join(\n `${siteDirectory}/${COMPILED_CACHE_DIR}`,\n configName\n )\n configFilePath = require.resolve(configPath)\n configModule = require(configFilePath)\n setGatsbyConfigCache(absoluteConfigPath, configModule)\n }\n } catch (outerError) {\n // Not all plugins will have a compiled file, so the err.message can look like this:\n // \"Cannot find module '<root>/node_modules/gatsby-source-filesystem/.cache/compiled/gatsby-config'\"\n // But the compiled file can also have an error like this:\n // \"Cannot find module 'foobar'\"\n // So this is trying to differentiate between an error we're fine ignoring and an error that we should throw\n const isModuleNotFoundError = outerError.code === `MODULE_NOT_FOUND`\n const isThisFileRequireError =\n (outerError?.requireStack?.[0]?.includes(`get-config-file`) ||\n outerError?.requireStack?.[0]?.includes(`query-engine`)) ??\n true\n\n // User's module require error inside gatsby-config.js\n if (!(isModuleNotFoundError && isThisFileRequireError)) {\n report.panic({\n id: `11902`,\n error: outerError,\n context: {\n configName,\n message: outerError.message,\n },\n })\n }\n\n // Attempt to find uncompiled gatsby-config.js in root dir\n configPath = path.join(siteDirectory, configName)\n\n try {\n const configModuleFromCache = requireGatsbyConfig(absoluteConfigPath)\n if (configModuleFromCache) {\n configModule = configModuleFromCache\n } else {\n configFilePath = require.resolve(configPath)\n configModule = require(configFilePath)\n setGatsbyConfigCache(absoluteConfigPath, configModule)\n }\n } catch (innerError) {\n // Some other error that is not a require error\n if (!testRequireError(configPath, innerError)) {\n report.panic({\n id: `10123`,\n error: innerError,\n context: {\n configName,\n message: innerError.message,\n },\n })\n }\n\n const files = await fs.readdir(siteDirectory)\n\n let tsConfig = false\n let nearMatch = ``\n\n for (const file of files) {\n if (tsConfig || nearMatch) {\n break\n }\n\n const { name, ext } = path.parse(file)\n\n if (name === configName && ext === `.ts`) {\n tsConfig = true\n break\n }\n\n if (isNearMatch(name, configName, distance)) {\n nearMatch = file\n }\n }\n\n // gatsby-config.ts exists but compiled gatsby-config.js does not\n if (tsConfig) {\n report.panic({\n id: `10127`,\n error: innerError,\n context: {\n configName,\n },\n })\n }\n\n // gatsby-config is misnamed\n if (nearMatch) {\n report.panic({\n id: `10124`,\n error: innerError,\n context: {\n configName,\n nearMatch,\n },\n })\n }\n\n // gatsby-config.js is incorrectly located in src/gatsby-config.js\n if (existsSync(path.join(siteDirectory, `src`, configName + `.js`))) {\n report.panic({\n id: `10125`,\n context: {\n configName,\n },\n })\n }\n }\n }\n\n return { configModule, configFilePath }\n}\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKO,SAASA,WAAT,CACLC,QADK,EAELC,UAFK,EAGLC,QAHK,EAII;EACT,IAAI,CAACF,QAAL,EAAe,OAAO,KAAP;EACf,OAAO,IAAAG,4BAAA,EAAYH,QAAZ,EAAsBC,UAAtB,KAAqCC,QAA5C;AACD;;AAEM,eAAeE,aAAf,CACLC,aADK,EAELJ,UAFK,EAGLC,QAAgB,GAAG,CAHd,EAOJ;EACD,IAAII,UAAU,GAAI,EAAlB;EACA,IAAIC,cAAc,GAAI,EAAtB;EACA,IAAIC,YAAJ;;EACA,MAAMC,kBAAkB,GAAGC,aAAA,CAAKC,IA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,EAAG,OADM;UAEXC,KAAK,EAAEG,UAFI;UAGXF,OAAO,EAAE;YACP3B;UADO;QAHE,CAAb;MAOD,CA5CkB,CA8CnB;;;MACA,IAAImC,SAAJ,EAAe;QACbZ,iBAAA,CAAOC,KAAP,CAAa;UACXC,EAAE,EAAG,OADM;UAEXC,KAAK,EAAEG,UAFI;UAGXF,OAAO,EAAE;YACP3B,UADO;YAEPmC;UAFO;QAHE,CAAb;MAQD,CAxDkB,CA0DnB;;;MACA,IAAI,IAAAK,oBAAA,EAAW/B,aAAA,CAAKC,IAAL,CAAUN,aAAV,EAA0B,KAA1B,EAAgCJ,UAAU,GAAI,KAA9C,CAAX,CAAJ,EAAqE;QACnEuB,iBAAA,CAAOC,KAAP,CAAa;UACXC,EAAE,EAAG,OADM;UAEXE,OAAO,EAAE;YACP3B;UADO;QAFE,CAAb;MAMD;IACF;EACF;;EAED,OAAO;IAAEO,YAAF;IAAgBD;EAAhB,CAAP;AACD"}
|
|
@@ -34,14 +34,21 @@ function loadInternalPlugins(config = {}, rootDir) {
|
|
|
34
34
|
internalPlugins.forEach(relPath => {
|
|
35
35
|
const absPath = _path.default.join(__dirname, relPath);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
const processedPlugin = (0, _processPlugin.processPlugin)(absPath, rootDir);
|
|
38
|
+
|
|
39
|
+
if (processedPlugin) {
|
|
40
|
+
plugins.push(processedPlugin);
|
|
41
|
+
}
|
|
38
42
|
}); // Add plugins from the site config.
|
|
39
43
|
|
|
40
44
|
if (config.plugins) {
|
|
41
45
|
config.plugins.forEach(plugin => {
|
|
42
46
|
const processedPlugin = (0, _processPlugin.processPlugin)(plugin, rootDir);
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
if (processedPlugin) {
|
|
49
|
+
plugins.push(processedPlugin);
|
|
50
|
+
configuredPluginNames.add(processedPlugin.name);
|
|
51
|
+
}
|
|
45
52
|
});
|
|
46
53
|
} // the order of all of these page-creators matters. The "last plugin wins",
|
|
47
54
|
// so the user's site comes last, and each page-creator instance has to
|
|
@@ -51,13 +58,17 @@ function loadInternalPlugins(config = {}, rootDir) {
|
|
|
51
58
|
|
|
52
59
|
|
|
53
60
|
plugins.forEach(plugin => {
|
|
54
|
-
|
|
61
|
+
const processedPlugin = (0, _processPlugin.processPlugin)({
|
|
55
62
|
resolve: require.resolve(`gatsby-plugin-page-creator`),
|
|
56
63
|
options: {
|
|
57
64
|
path: (0, _gatsbyCoreUtils.slash)(_path.default.join(plugin.resolve, `src/pages`)),
|
|
58
65
|
pathCheck: false
|
|
59
66
|
}
|
|
60
|
-
}, rootDir)
|
|
67
|
+
}, rootDir);
|
|
68
|
+
|
|
69
|
+
if (processedPlugin) {
|
|
70
|
+
plugins.push(processedPlugin);
|
|
71
|
+
}
|
|
61
72
|
});
|
|
62
73
|
|
|
63
74
|
if ("4" === `4` && configuredPluginNames.has(_handleGatsbyCloud.GATSBY_CLOUD_PLUGIN_NAME) && (0, _handleGatsbyCloud.incompatibleGatsbyCloudPlugin)(plugins)) {
|
|
@@ -84,7 +95,10 @@ function loadInternalPlugins(config = {}, rootDir) {
|
|
|
84
95
|
jsxPragma: `React`
|
|
85
96
|
}
|
|
86
97
|
}, rootDir);
|
|
87
|
-
|
|
98
|
+
|
|
99
|
+
if (processedTypeScriptPlugin) {
|
|
100
|
+
plugins.push(processedTypeScriptPlugin);
|
|
101
|
+
}
|
|
88
102
|
} // Add the site's default "plugin" i.e. gatsby-x files in root of site.
|
|
89
103
|
|
|
90
104
|
|
|
@@ -120,11 +134,20 @@ function loadInternalPlugins(config = {}, rootDir) {
|
|
|
120
134
|
resolve: require.resolve(`gatsby-plugin-page-creator`),
|
|
121
135
|
options: pageCreatorOptions
|
|
122
136
|
}, rootDir);
|
|
123
|
-
|
|
137
|
+
|
|
138
|
+
if (processedPageCreatorPlugin) {
|
|
139
|
+
plugins.push(processedPageCreatorPlugin);
|
|
140
|
+
} // Partytown plugin collects usage of <Script strategy={"off-main-thread"} />
|
|
124
141
|
// in `wrapRootElement`, so we have to make sure it's the last one running to be able to
|
|
125
142
|
// collect scripts that users might inject in their `wrapRootElement`
|
|
126
143
|
|
|
127
|
-
|
|
144
|
+
|
|
145
|
+
const processedPartytownPlugin = (0, _processPlugin.processPlugin)(_path.default.join(__dirname, `../../internal-plugins/partytown`), rootDir);
|
|
146
|
+
|
|
147
|
+
if (processedPartytownPlugin) {
|
|
148
|
+
plugins.push(processedPartytownPlugin);
|
|
149
|
+
}
|
|
150
|
+
|
|
128
151
|
return plugins;
|
|
129
152
|
}
|
|
130
153
|
//# sourceMappingURL=load-internal-plugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-internal-plugins.js","names":["TYPESCRIPT_PLUGIN_NAME","loadInternalPlugins","config","rootDir","plugins","configuredPluginNames","Set","internalPlugins","filter","Boolean","forEach","relPath","absPath","path","join","__dirname","push","processPlugin","plugin","processedPlugin","add","name","resolve","require","options","slash","pathCheck","has","GATSBY_CLOUD_PLUGIN_NAME","incompatibleGatsbyCloudPlugin","reporter","panic","process","env","GATSBY_CLOUD","addGatsbyPluginCloudPluginWhenInstalled","GATSBY_PLUGIN_PREVIEW_NAME","addGatsbyPluginPreviewWhenInstalled","processedTypeScriptPlugin","allExtensions","isTSX","jsxPragma","cwd","id","createPluginId","version","createFileContentHash","pluginOptions","getResolvedFieldsForPlugin","program","store","getState","pageCreatorOptions","directory","pageCreatorPlugin","find","processedPageCreatorPlugin"],"sources":["../../../src/bootstrap/load-plugins/load-internal-plugins.ts"],"sourcesContent":["import { slash } from \"gatsby-core-utils\"\nimport path from \"path\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport { store } from \"../../redux\"\nimport {\n IPluginInfo,\n IPluginRefObject,\n IPluginRefOptions,\n ISiteConfig,\n} from \"./types\"\nimport { processPlugin } from \"./process-plugin\"\nimport { createPluginId } from \"./utils/create-id\"\nimport { createFileContentHash } from \"./utils/create-hash\"\nimport {\n addGatsbyPluginCloudPluginWhenInstalled,\n addGatsbyPluginPreviewWhenInstalled,\n incompatibleGatsbyCloudPlugin,\n GATSBY_CLOUD_PLUGIN_NAME,\n GATSBY_PLUGIN_PREVIEW_NAME,\n} from \"./utils/handle-gatsby-cloud\"\nimport { getResolvedFieldsForPlugin } from \"../../utils/parcel/compile-gatsby-files\"\n\nconst TYPESCRIPT_PLUGIN_NAME = `gatsby-plugin-typescript`\n\nexport function loadInternalPlugins(\n config: ISiteConfig = {},\n rootDir: string\n): Array<IPluginInfo> {\n // Instantiate plugins.\n const plugins: Array<IPluginInfo> = []\n const configuredPluginNames = new Set()\n\n // Add internal plugins\n const internalPlugins = [\n `../../internal-plugins/dev-404-page`,\n `../../internal-plugins/load-babel-config`,\n `../../internal-plugins/internal-data-bridge`,\n `../../internal-plugins/prod-404-500`,\n `../../internal-plugins/webpack-theme-component-shadowing`,\n `../../internal-plugins/bundle-optimisations`,\n `../../internal-plugins/functions`,\n ].filter(Boolean) as Array<string>\n\n internalPlugins.forEach(relPath => {\n const absPath = path.join(__dirname, relPath)\n plugins.push(processPlugin(absPath, rootDir))\n })\n\n // Add plugins from the site config.\n if (config.plugins) {\n config.plugins.forEach(plugin => {\n const processedPlugin = processPlugin(plugin, rootDir)\n plugins.push(processedPlugin)\n configuredPluginNames.add(processedPlugin.name)\n })\n }\n\n // the order of all of these page-creators matters. The \"last plugin wins\",\n // so the user's site comes last, and each page-creator instance has to\n // match the plugin definition order before that. This works fine for themes\n // because themes have already been added in the proper order to the plugins\n // array\n plugins.forEach(plugin => {\n plugins.push(\n processPlugin(\n {\n resolve: require.resolve(`gatsby-plugin-page-creator`),\n options: {\n path: slash(path.join(plugin.resolve, `src/pages`)),\n pathCheck: false,\n },\n },\n rootDir\n )\n )\n })\n\n if (\n _CFLAGS_.GATSBY_MAJOR === `4` &&\n configuredPluginNames.has(GATSBY_CLOUD_PLUGIN_NAME) &&\n incompatibleGatsbyCloudPlugin(plugins)\n ) {\n reporter.panic(\n `Plugin gatsby-plugin-gatsby-cloud is not compatible with your gatsby version. Please upgrade to gatsby-plugin-gatsby-cloud@next`\n )\n }\n\n if (\n !configuredPluginNames.has(GATSBY_CLOUD_PLUGIN_NAME) &&\n (process.env.GATSBY_CLOUD === `true` || process.env.GATSBY_CLOUD === `1`)\n ) {\n addGatsbyPluginCloudPluginWhenInstalled(plugins, rootDir)\n }\n\n if (\n !configuredPluginNames.has(GATSBY_PLUGIN_PREVIEW_NAME) &&\n (process.env.GATSBY_CLOUD === `true` || process.env.GATSBY_CLOUD === `1`)\n ) {\n addGatsbyPluginPreviewWhenInstalled(plugins, rootDir)\n }\n\n // Support Typescript by default but allow users to override it\n if (!configuredPluginNames.has(TYPESCRIPT_PLUGIN_NAME)) {\n const processedTypeScriptPlugin = processPlugin(\n {\n resolve: require.resolve(TYPESCRIPT_PLUGIN_NAME),\n options: {\n // TODO(@mxstbr): Do not hard-code these defaults but infer them from the\n // pluginOptionsSchema of gatsby-plugin-typescript\n allExtensions: false,\n isTSX: false,\n jsxPragma: `React`,\n },\n },\n rootDir\n )\n plugins.push(processedTypeScriptPlugin)\n }\n\n // Add the site's default \"plugin\" i.e. gatsby-x files in root of site.\n plugins.push({\n resolve: slash(process.cwd()),\n id: createPluginId(`default-site-plugin`),\n name: `default-site-plugin`,\n version: createFileContentHash(process.cwd(), `gatsby-*`),\n pluginOptions: {\n plugins: [],\n },\n ...getResolvedFieldsForPlugin(rootDir, `default-site-plugin`),\n })\n\n const program = store.getState().program\n\n // default options for gatsby-plugin-page-creator\n let pageCreatorOptions: IPluginRefOptions | undefined = {\n path: slash(path.join(program.directory, `src/pages`)),\n pathCheck: false,\n }\n\n if (config.plugins) {\n const pageCreatorPlugin = config.plugins.find(\n (plugin): plugin is IPluginRefObject =>\n typeof plugin !== `string` &&\n plugin.resolve === `gatsby-plugin-page-creator` &&\n slash((plugin.options && plugin.options.path) || ``) ===\n slash(path.join(program.directory, `src/pages`))\n )\n if (pageCreatorPlugin) {\n // override the options if there are any user specified options\n pageCreatorOptions = pageCreatorPlugin.options\n }\n }\n\n const processedPageCreatorPlugin = processPlugin(\n {\n resolve: require.resolve(`gatsby-plugin-page-creator`),\n options: pageCreatorOptions,\n },\n rootDir\n )\n\n plugins.push(processedPageCreatorPlugin)\n\n // Partytown plugin collects usage of <Script strategy={\"off-main-thread\"} />\n // in `wrapRootElement`, so we have to make sure it's the last one running to be able to\n // collect scripts that users might inject in their `wrapRootElement`\n plugins.push(\n processPlugin(\n path.join(__dirname, `../../internal-plugins/partytown`),\n rootDir\n )\n )\n\n return plugins\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AAOA;;AAEA,MAAMA,sBAAsB,GAAI,0BAAhC;;AAEO,SAASC,mBAAT,CACLC,MAAmB,GAAG,EADjB,EAELC,OAFK,EAGe;EACpB;EACA,MAAMC,OAA2B,GAAG,EAApC;EACA,MAAMC,qBAAqB,GAAG,IAAIC,GAAJ,EAA9B,CAHoB,CAKpB;;EACA,MAAMC,eAAe,GAAG,CACrB,qCADqB,EAErB,0CAFqB,EAGrB,6CAHqB,EAIrB,qCAJqB,EAKrB,0DALqB,EAMrB,6CANqB,EAOrB,kCAPqB,EAQtBC,MARsB,CAQfC,OARe,CAAxB;EAUAF,eAAe,CAACG,OAAhB,CAAwBC,OAAO,IAAI;IACjC,MAAMC,OAAO,GAAGC,aAAA,CAAKC,IAAL,CAAUC,SAAV,EAAqBJ,OAArB,CAAhB;;IACAP,OAAO,CAACY,IAAR,CAAa,IAAAC,4BAAA,EAAcL,OAAd,EAAuBT,OAAvB,CAAb;EACD,CAHD,EAhBoB,CAqBpB;;EACA,IAAID,MAAM,CAACE,OAAX,EAAoB;IAClBF,MAAM,CAACE,OAAP,CAAeM,OAAf,CAAuBQ,MAAM,IAAI;MAC/B,MAAMC,eAAe,GAAG,IAAAF,4BAAA,EAAcC,MAAd,EAAsBf,OAAtB,CAAxB;MACAC,OAAO,CAACY,IAAR,CAAaG,eAAb;MACA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,sBAAA,EAAMZ,aAAA,CAAKC,IAAL,CAAUmC,OAAO,CAACI,SAAlB,EAA8B,WAA9B,CAAN,CALoB,CAA1B;;IAOA,IAAIC,iBAAJ,EAAuB;MACrB;MACAF,kBAAkB,GAAGE,iBAAiB,CAAC9B,OAAvC;IACD;EACF;;EAED,MAAMgC,0BAA0B,GAAG,IAAAvC,4BAAA,EACjC;IACEK,OAAO,EAAEC,OAAO,CAACD,OAAR,CAAiB,4BAAjB,CADX;IAEEE,OAAO,EAAE4B;EAFX,CADiC,EAKjCjD,OALiC,CAAnC;EAQAC,OAAO,CAACY,IAAR,CAAawC,0BAAb,EAtIoB,CAwIpB;EACA;EACA;;EACApD,OAAO,CAACY,IAAR,CACE,IAAAC,4BAAA,EACEJ,aAAA,CAAKC,IAAL,CAAUC,SAAV,EAAsB,kCAAtB,CADF,EAEEZ,OAFF,CADF;EAOA,OAAOC,OAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"load-internal-plugins.js","names":["TYPESCRIPT_PLUGIN_NAME","loadInternalPlugins","config","rootDir","plugins","configuredPluginNames","Set","internalPlugins","filter","Boolean","forEach","relPath","absPath","path","join","__dirname","processedPlugin","processPlugin","push","plugin","add","name","resolve","require","options","slash","pathCheck","has","GATSBY_CLOUD_PLUGIN_NAME","incompatibleGatsbyCloudPlugin","reporter","panic","process","env","GATSBY_CLOUD","addGatsbyPluginCloudPluginWhenInstalled","GATSBY_PLUGIN_PREVIEW_NAME","addGatsbyPluginPreviewWhenInstalled","processedTypeScriptPlugin","allExtensions","isTSX","jsxPragma","cwd","id","createPluginId","version","createFileContentHash","pluginOptions","getResolvedFieldsForPlugin","program","store","getState","pageCreatorOptions","directory","pageCreatorPlugin","find","processedPageCreatorPlugin","processedPartytownPlugin"],"sources":["../../../src/bootstrap/load-plugins/load-internal-plugins.ts"],"sourcesContent":["import { slash } from \"gatsby-core-utils\"\nimport path from \"path\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport { store } from \"../../redux\"\nimport {\n IPluginInfo,\n IPluginRefObject,\n IPluginRefOptions,\n ISiteConfig,\n} from \"./types\"\nimport { processPlugin } from \"./process-plugin\"\nimport { createPluginId } from \"./utils/create-id\"\nimport { createFileContentHash } from \"./utils/create-hash\"\nimport {\n addGatsbyPluginCloudPluginWhenInstalled,\n addGatsbyPluginPreviewWhenInstalled,\n incompatibleGatsbyCloudPlugin,\n GATSBY_CLOUD_PLUGIN_NAME,\n GATSBY_PLUGIN_PREVIEW_NAME,\n} from \"./utils/handle-gatsby-cloud\"\nimport { getResolvedFieldsForPlugin } from \"../../utils/parcel/compile-gatsby-files\"\n\nconst TYPESCRIPT_PLUGIN_NAME = `gatsby-plugin-typescript`\n\nexport function loadInternalPlugins(\n config: ISiteConfig = {},\n rootDir: string\n): Array<IPluginInfo> {\n // Instantiate plugins.\n const plugins: Array<IPluginInfo> = []\n const configuredPluginNames = new Set()\n\n // Add internal plugins\n const internalPlugins = [\n `../../internal-plugins/dev-404-page`,\n `../../internal-plugins/load-babel-config`,\n `../../internal-plugins/internal-data-bridge`,\n `../../internal-plugins/prod-404-500`,\n `../../internal-plugins/webpack-theme-component-shadowing`,\n `../../internal-plugins/bundle-optimisations`,\n `../../internal-plugins/functions`,\n ].filter(Boolean) as Array<string>\n\n internalPlugins.forEach(relPath => {\n const absPath = path.join(__dirname, relPath)\n const processedPlugin = processPlugin(absPath, rootDir)\n if (processedPlugin) {\n plugins.push(processedPlugin)\n }\n })\n\n // Add plugins from the site config.\n if (config.plugins) {\n config.plugins.forEach(plugin => {\n const processedPlugin = processPlugin(plugin, rootDir)\n if (processedPlugin) {\n plugins.push(processedPlugin)\n configuredPluginNames.add(processedPlugin.name)\n }\n })\n }\n\n // the order of all of these page-creators matters. The \"last plugin wins\",\n // so the user's site comes last, and each page-creator instance has to\n // match the plugin definition order before that. This works fine for themes\n // because themes have already been added in the proper order to the plugins\n // array\n plugins.forEach(plugin => {\n const processedPlugin = processPlugin(\n {\n resolve: require.resolve(`gatsby-plugin-page-creator`),\n options: {\n path: slash(path.join(plugin.resolve, `src/pages`)),\n pathCheck: false,\n },\n },\n rootDir\n )\n if (processedPlugin) {\n plugins.push(processedPlugin)\n }\n })\n\n if (\n _CFLAGS_.GATSBY_MAJOR === `4` &&\n configuredPluginNames.has(GATSBY_CLOUD_PLUGIN_NAME) &&\n incompatibleGatsbyCloudPlugin(plugins)\n ) {\n reporter.panic(\n `Plugin gatsby-plugin-gatsby-cloud is not compatible with your gatsby version. Please upgrade to gatsby-plugin-gatsby-cloud@next`\n )\n }\n\n if (\n !configuredPluginNames.has(GATSBY_CLOUD_PLUGIN_NAME) &&\n (process.env.GATSBY_CLOUD === `true` || process.env.GATSBY_CLOUD === `1`)\n ) {\n addGatsbyPluginCloudPluginWhenInstalled(plugins, rootDir)\n }\n\n if (\n !configuredPluginNames.has(GATSBY_PLUGIN_PREVIEW_NAME) &&\n (process.env.GATSBY_CLOUD === `true` || process.env.GATSBY_CLOUD === `1`)\n ) {\n addGatsbyPluginPreviewWhenInstalled(plugins, rootDir)\n }\n\n // Support Typescript by default but allow users to override it\n if (!configuredPluginNames.has(TYPESCRIPT_PLUGIN_NAME)) {\n const processedTypeScriptPlugin = processPlugin(\n {\n resolve: require.resolve(TYPESCRIPT_PLUGIN_NAME),\n options: {\n // TODO(@mxstbr): Do not hard-code these defaults but infer them from the\n // pluginOptionsSchema of gatsby-plugin-typescript\n allExtensions: false,\n isTSX: false,\n jsxPragma: `React`,\n },\n },\n rootDir\n )\n if (processedTypeScriptPlugin) {\n plugins.push(processedTypeScriptPlugin)\n }\n }\n\n // Add the site's default \"plugin\" i.e. gatsby-x files in root of site.\n plugins.push({\n resolve: slash(process.cwd()),\n id: createPluginId(`default-site-plugin`),\n name: `default-site-plugin`,\n version: createFileContentHash(process.cwd(), `gatsby-*`),\n pluginOptions: {\n plugins: [],\n },\n ...getResolvedFieldsForPlugin(rootDir, `default-site-plugin`),\n })\n\n const program = store.getState().program\n\n // default options for gatsby-plugin-page-creator\n let pageCreatorOptions: IPluginRefOptions | undefined = {\n path: slash(path.join(program.directory, `src/pages`)),\n pathCheck: false,\n }\n\n if (config.plugins) {\n const pageCreatorPlugin = config.plugins.find(\n (plugin): plugin is IPluginRefObject =>\n typeof plugin !== `string` &&\n plugin.resolve === `gatsby-plugin-page-creator` &&\n slash((plugin.options && plugin.options.path) || ``) ===\n slash(path.join(program.directory, `src/pages`))\n )\n if (pageCreatorPlugin) {\n // override the options if there are any user specified options\n pageCreatorOptions = pageCreatorPlugin.options\n }\n }\n\n const processedPageCreatorPlugin = processPlugin(\n {\n resolve: require.resolve(`gatsby-plugin-page-creator`),\n options: pageCreatorOptions,\n },\n rootDir\n )\n\n if (processedPageCreatorPlugin) {\n plugins.push(processedPageCreatorPlugin)\n }\n\n // Partytown plugin collects usage of <Script strategy={\"off-main-thread\"} />\n // in `wrapRootElement`, so we have to make sure it's the last one running to be able to\n // collect scripts that users might inject in their `wrapRootElement`\n const processedPartytownPlugin = processPlugin(\n path.join(__dirname, `../../internal-plugins/partytown`),\n rootDir\n )\n if (processedPartytownPlugin) {\n plugins.push(processedPartytownPlugin)\n }\n\n return plugins\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AAOA;;AAEA,MAAMA,sBAAsB,GAAI,0BAAhC;;AAEO,SAASC,mBAAT,CACLC,MAAmB,GAAG,EADjB,EAELC,OAFK,EAGe;EACpB;EACA,MAAMC,OAA2B,GAAG,EAApC;EACA,MAAMC,qBAAqB,GAAG,IAAIC,GAAJ,EAA9B,CAHoB,CAKpB;;EACA,MAAMC,eAAe,GAAG,CACrB,qCADqB,EAErB,0CAFqB,EAGrB,6CAHqB,EAIrB,qCAJqB,EAKrB,0DALqB,EAMrB,6CANqB,EAOrB,kCAPqB,EAQtBC,MARsB,CAQfC,OARe,CAAxB;EAUAF,eAAe,CAACG,OAAhB,CAAwBC,OAAO,IAAI;IACjC,MAAMC,OAAO,GAAGC,aAAA,CAAKC,IA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C,wBAAb;EACD;;EAED,OAAOrD,OAAP;AACD"}
|
|
@@ -1,20 +1,33 @@
|
|
|
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);
|
|
26
|
+
|
|
27
|
+
if (!info) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
18
31
|
return { ...info,
|
|
19
32
|
pluginOptions: {
|
|
20
33
|
plugins: []
|
|
@@ -24,7 +37,7 @@ function processPlugin(plugin, rootDir) {
|
|
|
24
37
|
|
|
25
38
|
plugin.options = plugin.options || {}; // Throw an error if there is an "option" key.
|
|
26
39
|
|
|
27
|
-
if ((0,
|
|
40
|
+
if ((0, _isEmpty2.default)(plugin.options) && !(0, _isEmpty2.default)(plugin.option)) {
|
|
28
41
|
throw new Error(`Plugin "${plugin.resolve}" has an "option" key in the configuration. Did you mean "options"?`);
|
|
29
42
|
} // Plugins can have plugins.
|
|
30
43
|
|
|
@@ -49,10 +62,13 @@ function processPlugin(plugin, rootDir) {
|
|
|
49
62
|
|
|
50
63
|
for (const root of roots) {
|
|
51
64
|
const result = processPlugin(root, rootDir);
|
|
52
|
-
|
|
65
|
+
|
|
66
|
+
if (result) {
|
|
67
|
+
processed.push(result);
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
70
|
|
|
55
|
-
(0,
|
|
71
|
+
(0, _set2.default)(plugin.options, pathToSwap, processed);
|
|
56
72
|
}
|
|
57
73
|
} // Add some default values for tests as we don't actually
|
|
58
74
|
// want to try to load anything during tests.
|
|
@@ -72,12 +88,17 @@ function processPlugin(plugin, rootDir) {
|
|
|
72
88
|
}
|
|
73
89
|
|
|
74
90
|
const info = (0, _resolvePlugin.resolvePlugin)(plugin, rootDir);
|
|
91
|
+
|
|
92
|
+
if (!info) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
75
96
|
return { ...info,
|
|
76
97
|
modulePath: plugin.modulePath,
|
|
77
98
|
module: plugin.module,
|
|
78
99
|
subPluginPaths: plugin.subPluginPaths ? Array.from(plugin.subPluginPaths) : undefined,
|
|
79
100
|
id: (0, _createId.createPluginId)(info.name, plugin),
|
|
80
|
-
pluginOptions: (0,
|
|
101
|
+
pluginOptions: (0, _merge2.default)({
|
|
81
102
|
plugins: []
|
|
82
103
|
}, plugin.options)
|
|
83
104
|
};
|
|
@@ -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(\n plugin: PluginRef,\n rootDir: string\n): IPluginInfo | null {\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 if (!info) {\n return null\n }\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 if (result) {\n processed.push(result)\n }\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 if (!info) {\n return null\n }\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,CACLC,MADK,EAELC,OAFK,EAGe;EACpB;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,IAAI,CAACE,IAAL,EAAW;MACT,OAAO,IAAP;IACD;;IAED,OAAO,EACL,GAAGA,IADE;MAELE,aAAa,EAAE;QACbC,OAAO,EAAE;MADI;IAFV,CAAP;EAMD;;EAEDN,MAAM,CAACO,OAAP,GAAiBP,MAAM,CAACO,OAAP,IAAkB,EAAnC,CAnBoB,CAqBpB;;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,CA7BmB,CA+BpB;;;EACA,IAAIV,MAAM,CAACW,cAAX,EAA2B;IACzB,KAAK,MAAMC,aAAX,IAA4BZ,MAAM,CAACW,cAAnC,EAAmD;MACjD,MAAME,QAAQ,GAAGD,aAAa,CAACE,KAAd,CAAqB,GAArB,CAAjB;MACA,IAAIC,KAAiB,GAAG,CAACf,MAAM,CAACO,OAAR,CAAxB;MAEA,IAAIS,UAAU,GAAGH,QAAjB;;MAEA,KAAK,MAAMI,OAAX,IAAsBJ,QAAtB,EAAgC;QAC9B,IAAII,OAAO,KAAM,IAAjB,EAAsB;UACpBD,UAAU,GAAGA,UAAU,CAACE,KAAX,CAAiB,CAAjB,EAAoBF,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,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,
|
|
@@ -76,6 +76,10 @@ function resolvePlugin(plugin, rootDir) {
|
|
|
76
76
|
version: packageJSON.version
|
|
77
77
|
};
|
|
78
78
|
} catch (err) {
|
|
79
|
+
if (process.env.GATSBY_IS_GRAPHQL_ENGINE) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
if (process.env.gatsby_log_level === `verbose`) {
|
|
80
84
|
_reporter.default.panicOnBuild(`plugin "${pluginName} threw the following error:\n`, err);
|
|
81
85
|
} else {
|