gatsby 2.32.7 → 2.32.11

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/cache-dir/app.js +2 -3
  3. package/cache-dir/commonjs/app.js +2 -1
  4. package/cache-dir/commonjs/loading-indicator/indicator.js +3 -2
  5. package/cache-dir/loading-indicator/indicator.js +2 -1
  6. package/dist/commands/build.js +5 -1
  7. package/dist/commands/build.js.map +1 -1
  8. package/dist/commands/develop-process.js +5 -1
  9. package/dist/commands/develop-process.js.map +1 -1
  10. package/dist/commands/develop.js +8 -2
  11. package/dist/commands/develop.js.map +1 -1
  12. package/dist/state-machines/develop/index.js +1 -3
  13. package/dist/state-machines/develop/index.js.map +1 -1
  14. package/dist/utils/dev-ssr/develop-html-route.js +3 -3
  15. package/dist/utils/dev-ssr/develop-html-route.js.map +1 -1
  16. package/dist/utils/dev-ssr/render-dev-html.js +3 -2
  17. package/dist/utils/dev-ssr/render-dev-html.js.map +1 -1
  18. package/dist/utils/develop-preload-headers.js +1 -1
  19. package/dist/utils/develop-preload-headers.js.map +1 -1
  20. package/dist/utils/websocket-manager.d.ts +6 -6
  21. package/dist/utils/websocket-manager.js +12 -5
  22. package/dist/utils/websocket-manager.js.map +1 -1
  23. package/gatsby-admin-public/4c744e84-6c27fb4a13dc8c8c3e88.js.map +1 -1
  24. package/gatsby-admin-public/69bd6bf3-00a5b50945cce68e041c.js.map +1 -1
  25. package/gatsby-admin-public/784b2cee55c07b638f20445dec340adf9f1888a3-d690a55f56dedc0f95b3.js.map +1 -1
  26. package/gatsby-admin-public/854a7ef1f34af0aefbdfdd9304a0c00251662775-30cef3c004238987a416.js.map +1 -1
  27. package/gatsby-admin-public/app-749bdcbe1800236c1de3.js +3 -0
  28. package/gatsby-admin-public/{app-984c5d97f9bd5157ed94.js.LICENSE.txt → app-749bdcbe1800236c1de3.js.LICENSE.txt} +0 -2
  29. package/gatsby-admin-public/app-749bdcbe1800236c1de3.js.map +1 -0
  30. package/gatsby-admin-public/c432bec7e9afb3443fd639df9e5f119e13575cf7-976ea4aa8380d4a68cb1.js.map +1 -1
  31. package/gatsby-admin-public/chunk-map.json +1 -1
  32. package/gatsby-admin-public/component---src-pages-index-tsx-70aa31e4e1eca0a560a8.js.map +1 -1
  33. package/gatsby-admin-public/component---src-pages-plugins-tsx-c6700b48ed9ac88a9768.js.map +1 -1
  34. package/gatsby-admin-public/{component---src-pages-recipe-js-48fb05e6af01805f0a27.js → component---src-pages-recipe-js-e508d7ea0c80b0071ca7.js} +1 -1
  35. package/gatsby-admin-public/component---src-pages-recipe-js-e508d7ea0c80b0071ca7.js.map +1 -0
  36. package/gatsby-admin-public/e2852b4470dcb2615e49edcd9de2a3c8119d4bec-fbd253211b90ee4d944c.js.map +1 -1
  37. package/gatsby-admin-public/framework-b5530edc347e85dd3979.js.map +1 -1
  38. package/gatsby-admin-public/index.html +1 -1
  39. package/gatsby-admin-public/page-data/app-data.json +1 -1
  40. package/gatsby-admin-public/pages/index.html +1 -1
  41. package/gatsby-admin-public/plugins/index.html +1 -1
  42. package/gatsby-admin-public/polyfill-bb3950ad41cd96a6ba64.js.map +1 -1
  43. package/gatsby-admin-public/recipe/index.html +1 -1
  44. package/gatsby-admin-public/recipes/index.html +1 -1
  45. package/gatsby-admin-public/{webpack-runtime-ece0b6a1fdfb71d1b025.js → webpack-runtime-276364d320252125351e.js} +2 -2
  46. package/gatsby-admin-public/{webpack-runtime-ece0b6a1fdfb71d1b025.js.map → webpack-runtime-276364d320252125351e.js.map} +1 -1
  47. package/gatsby-admin-public/webpack.stats.json +1 -1
  48. package/package.json +4 -5
  49. package/gatsby-admin-public/app-984c5d97f9bd5157ed94.js +0 -3
  50. package/gatsby-admin-public/app-984c5d97f9bd5157ed94.js.map +0 -1
  51. package/gatsby-admin-public/component---src-pages-recipe-js-48fb05e6af01805f0a27.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,29 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.32.11](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.32.10...gatsby@2.32.11) (2021-03-09)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **gatsby:** don't ignore SOURCE_FILE_CHANGED event ([#30127](https://github.com/gatsbyjs/gatsby/issues/30127)) ([#30129](https://github.com/gatsbyjs/gatsby/issues/30129)) ([123e47c](https://github.com/gatsbyjs/gatsby/commit/123e47c1d7a79ccf1d2ff5003ae44dc4326129c8))
11
+ - **gatsby:** set program.verbose when VERBOSE env var is used ([#30123](https://github.com/gatsbyjs/gatsby/issues/30123)) ([#30138](https://github.com/gatsbyjs/gatsby/issues/30138)) ([ff7d46e](https://github.com/gatsbyjs/gatsby/commit/ff7d46e1a5954bffcf9b1f893d1ce097f0dea49f))
12
+
13
+ ## [2.32.10](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.32.9...gatsby@2.32.10) (2021-03-08)
14
+
15
+ ### Bug Fixes
16
+
17
+ - **gatsby:** Fix various small DEV_SSR bugs exposed in development_runtime tests ([#29748](https://github.com/gatsbyjs/gatsby/issues/29748)) ([890d5e5](https://github.com/gatsbyjs/gatsby/commit/890d5e5c8fc98819d32dd23cbf2679c37e0121c5))
18
+
19
+ ## [2.32.9](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.32.8...gatsby@2.32.9) (2021-03-01)
20
+
21
+ ### Bug Fixes
22
+
23
+ - query on demand loading indicator always active on preact. ([#29829](https://github.com/gatsbyjs/gatsby/issues/29829)) ([#29882](https://github.com/gatsbyjs/gatsby/issues/29882)) ([706a754](https://github.com/gatsbyjs/gatsby/commit/706a754479a161a8c8bf99be7971e1ab06401229))
24
+
25
+ ## [2.32.8](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.32.7...gatsby@2.32.8) (2021-02-25)
26
+
27
+ **Note:** Version bump only for package gatsby
28
+
6
29
  ## [2.32.7](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.32.6...gatsby@2.32.7) (2021-02-25)
7
30
 
8
31
  ### Features
package/cache-dir/app.js CHANGED
@@ -117,14 +117,13 @@ apiRunnerAsync(`onClientEntry`).then(() => {
117
117
 
118
118
  const rootElement = document.getElementById(`___gatsby`)
119
119
 
120
+ const focusEl = document.getElementById(`gatsby-focus-wrapper`)
120
121
  const renderer = apiRunner(
121
122
  `replaceHydrateFunction`,
122
123
  undefined,
123
124
  // Client only pages have any empty body so we just do a normal
124
125
  // render to avoid React complaining about hydration mis-matches.
125
- document.getElementById(`___gatsby`).children.length === 0
126
- ? ReactDOM.render
127
- : ReactDOM.hydrate
126
+ focusEl && focusEl.children.length > 0 ? ReactDOM.hydrate : ReactDOM.render
128
127
  )[0]
129
128
 
130
129
  let dismissLoadingIndicator
@@ -107,9 +107,10 @@ function notCalledFunction() {
107
107
  }
108
108
 
109
109
  const rootElement = document.getElementById(`___gatsby`);
110
+ const focusEl = document.getElementById(`gatsby-focus-wrapper`);
110
111
  const renderer = (0, _apiRunnerBrowser.apiRunner)(`replaceHydrateFunction`, undefined, // Client only pages have any empty body so we just do a normal
111
112
  // render to avoid React complaining about hydration mis-matches.
112
- document.getElementById(`___gatsby`).children.length === 0 ? _reactDom.default.render : _reactDom.default.hydrate)[0];
113
+ focusEl && focusEl.children.length > 0 ? _reactDom.default.hydrate : _reactDom.default.render)[0];
113
114
  let dismissLoadingIndicator;
114
115
 
115
116
  if (process.env.GATSBY_EXPERIMENTAL_QUERY_ON_DEMAND && process.env.GATSBY_QUERY_ON_DEMAND_LOADING_INDICATOR === `true`) {
@@ -46,8 +46,9 @@ function Indicator({
46
46
  }
47
47
 
48
48
  return /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_style.default, null), /*#__PURE__*/_react.default.createElement("div", {
49
- "data-gatsby-loading-indicator": "root",
50
- "data-gatsby-loading-indicator-visible": visible,
49
+ "data-gatsby-loading-indicator": "root" // preact doesn't render data attributes with a literal bool false value to dom
50
+ ,
51
+ "data-gatsby-loading-indicator-visible": visible.toString(),
51
52
  "aria-live": "assertive"
52
53
  }, /*#__PURE__*/_react.default.createElement("div", {
53
54
  "data-gatsby-loading-indicator": "spinner",
@@ -42,7 +42,8 @@ export function Indicator({ visible = true }) {
42
42
  <Style />
43
43
  <div
44
44
  data-gatsby-loading-indicator="root"
45
- data-gatsby-loading-indicator-visible={visible}
45
+ // preact doesn't render data attributes with a literal bool false value to dom
46
+ data-gatsby-loading-indicator-visible={visible.toString()}
46
47
  aria-live="assertive"
47
48
  >
48
49
  <div data-gatsby-loading-indicator="spinner" aria-hidden="true">
@@ -70,7 +70,11 @@ if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {
70
70
  }
71
71
 
72
72
  module.exports = async function build(program) {
73
- _reporter.default.setVerbose((0, _gatsbyCoreUtils.isTruthy)(process.env.VERBOSE) || program.verbose);
73
+ if ((0, _gatsbyCoreUtils.isTruthy)(process.env.VERBOSE)) {
74
+ program.verbose = true;
75
+ }
76
+
77
+ _reporter.default.setVerbose(program.verbose);
74
78
 
75
79
  if (program.profile) {
76
80
  _reporter.default.warn(`React Profiling is enabled. This can have a performance impact. See https://www.gatsbyjs.org/docs/profiling-site-performance-with-react-profiler/#performance-impact`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/build.ts"],"names":["cachedPageData","cachedWebpackCompilationHash","process","env","GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES","pageData","webpackCompilationHash","module","exports","build","program","report","setVerbose","VERBOSE","verbose","profile","warn","name","sitePackageJson","sitePath","directory","lastRun","Date","now","pid","publicDir","path","join","openTracingConfigFile","buildActivity","phantomActivity","start","telemetry","trackCli","exitCode","buildSpan","span","setTag","gatsbyNodeGraphQLFunction","parentSpan","graphqlRunner","GraphQLRunner","store","collectStats","graphqlTracing","queryIds","graphql","buildActivityTimer","activityTimer","stats","err","panic","Stage","BuildJavascript","end","workerPool","WorkerPool","create","hash","getState","appDataUtil","exists","dispatch","type","payload","rewriteActivityTimer","write","pages","forEach","_value","key","has","boundActionCreators","removePageData","id","isTrackingEnabled","bundleSizes","toJson","assets","filter","asset","endsWith","map","size","pageDataSizes","pageDataStats","values","addSiteMeasurement","bundleStats","aggregateStats","queryStats","getStats","setProgramStatus","db","saveState","pagePaths","keys","buildUtils","getChangedPageDataKeys","info","stripIndent","buildSSRBundleActivityProgress","pageRenderer","BuildHTML","pagesCount","length","totalPagesCount","buildHTMLActivityProgress","createProgress","context","errorPath","ref","match","message","error","keepPageRenderer","deletedPageKeys","deletePageDataActivityTimer","collectRemovedPageData","removePageFiles","postBuildActivityTimer","uptime","finish","argv","includes","createdFilesPath","resolve","createdFilesContent","deletedFilesPath","deletedFilesContent","fs","writeFile"],"mappings":";;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAEA;;AAMA;;AAIA;;AAEA,IAAIA,cAAJ;AACA,IAAIC,4BAAJ;;AACA,IAAIC,OAAO,CAACC,GAAR,CAAYC,8CAAhB,EAAgE;AAC9D,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAuC,uBAA7C,CAD8D,CAE9D;;AACAN,EAAAA,cAAc,GAAGK,QAAjB;AACAJ,EAAAA,4BAA4B,GAAGK,sBAA/B;AACD;;AAaDC,MAAM,CAACC,OAAP,GAAiB,eAAeC,KAAf,CAAqBC,OAArB,EAAyD;AACxEC,oBAAOC,UAAP,CAAkB,+BAASV,OAAO,CAACC,GAAR,CAAYU,OAArB,KAAiCH,OAAO,CAACI,OAA3D;;AAEA,MAAIJ,OAAO,CAACK,OAAZ,EAAqB;AACnBJ,sBAAOK,IAAP,CACG,sKADH;AAGD;;AAED,QAAM,yCAAmB;AACv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AgBA,IAAK,EADpB,EAEdC,IAFc,CAER,IAFQ,CAEH,EAHhB;AAKD;;AAED,QAAIyF,eAAe,CAACX,MAApB,EAA4B;AAC1B9F,wBAAOwF,IAAP,CACG,mBAAkBiB,eAAe,CAC/BlC,GADgB,CACZxD,IAAI,IAAK,iBAAgBA,IAAK,EADlB,EAEhBC,IAFgB,CAEV,IAFU,CAEL,EAHhB;AAKD;AACF;;AAED,MACEzB,OAAO,CAACC,GAAR,CAAYC,8CAAZ,IACAF,OAAO,CAACyH,IAAR,CAAaC,QAAb,CAAuB,iBAAvB,CAFF,EAGE;AACA,UAAMC,gBAAgB,GAAGnG,cAAKoG,OAAL,CACtB,GAAEpH,OAAO,CAACU,SAAU,SADE,EAEtB,cAFsB,CAAzB;;AAIA,UAAM2G,mBAAmB,GAAGhC,SAAS,CAACU,MAAV,GACvB,GAAEV,SAAS,CAACpE,IAAV,CAAgB,IAAhB,CAAqB,IADA,GAEvB,EAFL;;AAIA,UAAMqG,gBAAgB,GAAGtG,cAAKoG,OAAL,CACtB,GAAEpH,OAAO,CAACU,SAAU,SADE,EAEtB,kBAFsB,CAAzB;;AAIA,UAAM6G,mBAAmB,GAAGb,eAAe,CAACX,MAAhB,GACvB,GAAEW,eAAe,CAACzF,IAAhB,CAAsB,IAAtB,CAA2B,IADN,GAEvB,EAFL;AAIA,UAAMuG,iBAAGC,SAAH,CAAaN,gBAAb,EAA+BE,mBAA/B,EAAqD,MAArD,CAAN;;AACApH,sBAAOwF,IAAP,CAAa,6BAAb;;AAEA,UAAM+B,iBAAGC,SAAH,CAAaH,gBAAb,EAA+BC,mBAA/B,EAAqD,MAArD,CAAN;;AACAtH,sBAAOwF,IAAP,CAAa,iCAAb;AACD;;AAED,MAAI,MAAM,yCAAV,EAAsC;AACpC;AACD,GAFD,MAEO,IAAI,MAAM,mDAAV,EAAgD;AACrD;AACD;AACF,CA1UD","sourcesContent":["import path from \"path\"\nimport report from \"gatsby-cli/lib/reporter\"\nimport signalExit from \"signal-exit\"\nimport fs from \"fs-extra\"\nimport telemetry from \"gatsby-telemetry\"\n\nimport { doBuildPages, buildRenderer, deleteRenderer } from \"./build-html\"\nimport { buildProductionBundle } from \"./build-javascript\"\nimport { bootstrap } from \"../bootstrap\"\nimport apiRunnerNode from \"../utils/api-runner-node\"\nimport { GraphQLRunner } from \"../query/graphql-runner\"\nimport { copyStaticDirs } from \"../utils/get-static-dir\"\nimport { initTracer, stopTracer } from \"../utils/tracer\"\nimport db from \"../db\"\nimport { store, readState } from \"../redux\"\nimport * as appDataUtil from \"../utils/app-data\"\nimport { flush as flushPendingPageDataWrites } from \"../utils/page-data\"\nimport * as WorkerPool from \"../utils/worker/pool\"\nimport { structureWebpackErrors } from \"../utils/webpack-error-utils\"\nimport {\n userGetsSevenDayFeedback,\n userPassesFeedbackRequestHeuristic,\n showFeedbackRequest,\n showSevenDayFeedbackRequest,\n} from \"../utils/feedback\"\nimport * as buildUtils from \"./build-utils\"\nimport { boundActionCreators } from \"../redux/actions\"\nimport { waitUntilAllJobsComplete } from \"../utils/wait-until-jobs-complete\"\nimport { IProgram, Stage } from \"./types\"\nimport { PackageJson } from \"../..\"\nimport {\n calculateDirtyQueries,\n runStaticQueries,\n runPageQueries,\n writeOutRequires,\n} from \"../services\"\nimport {\n markWebpackStatusAsPending,\n markWebpackStatusAsDone,\n} from \"../utils/webpack-status\"\nimport { updateSiteMetadata, isTruthy } from \"gatsby-core-utils\"\n\nlet cachedPageData\nlet cachedWebpackCompilationHash\nif (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n const { pageData, webpackCompilationHash } = readState()\n // extract only data that we need to reuse and let v8 garbage collect rest of state\n cachedPageData = pageData\n cachedWebpackCompilationHash = webpackCompilationHash\n}\n\ninterface IBuildArgs extends IProgram {\n directory: string\n sitePackageJson: PackageJson\n prefixPaths: boolean\n noUglify: boolean\n profile: boolean\n graphqlTracing: boolean\n openTracingConfigFile: string\n keepPageRenderer: boolean\n}\n\nmodule.exports = async function build(program: IBuildArgs): Promise<void> {\n report.setVerbose(isTruthy(process.env.VERBOSE) || program.verbose)\n\n if (program.profile) {\n report.warn(\n `React Profiling is enabled. This can have a performance impact. See https://www.gatsbyjs.org/docs/profiling-site-performance-with-react-profiler/#performance-impact`\n )\n }\n\n await updateSiteMetadata({\n name: program.sitePackageJson.name,\n sitePath: program.directory,\n lastRun: Date.now(),\n pid: process.pid,\n })\n\n markWebpackStatusAsPending()\n\n const publicDir = path.join(program.directory, `public`)\n initTracer(program.openTracingConfigFile)\n const buildActivity = report.phantomActivity(`build`)\n buildActivity.start()\n\n telemetry.trackCli(`BUILD_START`)\n signalExit(exitCode => {\n telemetry.trackCli(`BUILD_END`, { exitCode })\n })\n\n const buildSpan = buildActivity.span\n buildSpan.setTag(`directory`, program.directory)\n\n const { gatsbyNodeGraphQLFunction } = await bootstrap({\n program,\n parentSpan: buildSpan,\n })\n\n const graphqlRunner = new GraphQLRunner(store, {\n collectStats: true,\n graphqlTracing: program.graphqlTracing,\n })\n\n const { queryIds } = await calculateDirtyQueries({ store })\n\n await runStaticQueries({\n queryIds,\n parentSpan: buildSpan,\n store,\n graphqlRunner,\n })\n\n await runPageQueries({\n queryIds,\n graphqlRunner,\n parentSpan: buildSpan,\n store,\n })\n\n await writeOutRequires({\n store,\n parentSpan: buildSpan,\n })\n\n await apiRunnerNode(`onPreBuild`, {\n graphql: gatsbyNodeGraphQLFunction,\n parentSpan: buildSpan,\n })\n\n // Copy files from the static directory to\n // an equivalent static directory within public.\n copyStaticDirs()\n\n const buildActivityTimer = report.activityTimer(\n `Building production JavaScript and CSS bundles`,\n { parentSpan: buildSpan }\n )\n buildActivityTimer.start()\n let stats\n try {\n stats = await buildProductionBundle(program, buildActivityTimer.span)\n } catch (err) {\n buildActivityTimer.panic(structureWebpackErrors(Stage.BuildJavascript, err))\n } finally {\n buildActivityTimer.end()\n }\n\n const workerPool = WorkerPool.create()\n\n const webpackCompilationHash = stats.hash\n if (\n webpackCompilationHash !== store.getState().webpackCompilationHash ||\n !appDataUtil.exists(publicDir)\n ) {\n store.dispatch({\n type: `SET_WEBPACK_COMPILATION_HASH`,\n payload: webpackCompilationHash,\n })\n\n const rewriteActivityTimer = report.activityTimer(\n `Rewriting compilation hashes`,\n {\n parentSpan: buildSpan,\n }\n )\n rewriteActivityTimer.start()\n\n await appDataUtil.write(publicDir, webpackCompilationHash)\n\n rewriteActivityTimer.end()\n }\n\n await flushPendingPageDataWrites()\n markWebpackStatusAsDone()\n\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n const { pages } = store.getState()\n if (cachedPageData) {\n cachedPageData.forEach((_value, key) => {\n if (!pages.has(key)) {\n boundActionCreators.removePageData({\n id: key,\n })\n }\n })\n }\n }\n\n if (telemetry.isTrackingEnabled()) {\n // transform asset size to kB (from bytes) to fit 64 bit to numbers\n const bundleSizes = stats\n .toJson({ assets: true })\n .assets.filter(asset => asset.name.endsWith(`.js`))\n .map(asset => asset.size / 1000)\n const pageDataSizes = [...store.getState().pageDataStats.values()]\n\n telemetry.addSiteMeasurement(`BUILD_END`, {\n bundleStats: telemetry.aggregateStats(bundleSizes),\n pageDataStats: telemetry.aggregateStats(pageDataSizes),\n queryStats: graphqlRunner.getStats(),\n })\n }\n\n boundActionCreators.setProgramStatus(`BOOTSTRAP_QUERY_RUNNING_FINISHED`)\n\n await db.saveState()\n\n await waitUntilAllJobsComplete()\n\n // we need to save it again to make sure our latest state has been saved\n await db.saveState()\n\n let pagePaths = [...store.getState().pages.keys()]\n\n // Rebuild subset of pages if user opt into GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES\n // if there were no source files (for example components, static queries, etc) changes since last build, otherwise rebuild all pages\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n if (\n cachedWebpackCompilationHash === store.getState().webpackCompilationHash\n ) {\n pagePaths = buildUtils.getChangedPageDataKeys(\n store.getState(),\n cachedPageData\n )\n } else if (cachedWebpackCompilationHash) {\n report.info(\n report.stripIndent(`\n One or more of your source files have changed since the last time you ran Gatsby. All\n pages will be rebuilt.\n `)\n )\n }\n }\n\n const buildSSRBundleActivityProgress = report.activityTimer(\n `Building HTML renderer`,\n { parentSpan: buildSpan }\n )\n buildSSRBundleActivityProgress.start()\n let pageRenderer: string\n try {\n pageRenderer = await buildRenderer(program, Stage.BuildHTML, buildSpan)\n } catch (err) {\n buildActivityTimer.panic(structureWebpackErrors(Stage.BuildHTML, err))\n } finally {\n buildSSRBundleActivityProgress.end()\n }\n\n telemetry.addSiteMeasurement(`BUILD_END`, {\n pagesCount: pagePaths.length, // number of html files that will be written\n totalPagesCount: store.getState().pages.size, // total number of pages\n })\n\n const buildHTMLActivityProgress = report.createProgress(\n `Building static HTML for pages`,\n pagePaths.length,\n 0,\n {\n parentSpan: buildSpan,\n }\n )\n buildHTMLActivityProgress.start()\n try {\n await doBuildPages(\n pageRenderer,\n pagePaths,\n buildHTMLActivityProgress,\n workerPool\n )\n } catch (err) {\n let id = `95313` // TODO: verify error IDs exist\n const context = {\n errorPath: err.context && err.context.path,\n ref: ``,\n }\n\n const match = err.message.match(\n /ReferenceError: (window|document|localStorage|navigator|alert|location) is not defined/i\n )\n if (match && match[1]) {\n id = `95312`\n context.ref = match[1]\n }\n\n buildHTMLActivityProgress.panic({\n id,\n context,\n error: err,\n })\n }\n buildHTMLActivityProgress.end()\n\n if (!program.keepPageRenderer) {\n try {\n await deleteRenderer(pageRenderer)\n } catch (err) {\n // pass through\n }\n }\n\n let deletedPageKeys: Array<string> = []\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n const deletePageDataActivityTimer = report.activityTimer(\n `Delete previous page data`\n )\n deletePageDataActivityTimer.start()\n deletedPageKeys = buildUtils.collectRemovedPageData(\n store.getState(),\n cachedPageData\n )\n await buildUtils.removePageFiles(publicDir, deletedPageKeys)\n\n deletePageDataActivityTimer.end()\n }\n\n const postBuildActivityTimer = report.activityTimer(`onPostBuild`, {\n parentSpan: buildSpan,\n })\n postBuildActivityTimer.start()\n await apiRunnerNode(`onPostBuild`, {\n graphql: gatsbyNodeGraphQLFunction,\n parentSpan: buildSpan,\n })\n postBuildActivityTimer.end()\n\n // Wait for any jobs that were started in onPostBuild\n // This could occur due to queries being run which invoke sharp for instance\n await waitUntilAllJobsComplete()\n\n // Make sure we saved the latest state so we have all jobs cached\n await db.saveState()\n\n report.info(`Done building in ${process.uptime()} sec`)\n\n buildSpan.finish()\n await stopTracer()\n workerPool.end()\n buildActivity.end()\n\n if (\n process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES &&\n process.argv.includes(`--log-pages`)\n ) {\n if (pagePaths.length) {\n report.info(\n `Built pages:\\n${pagePaths\n .map(path => `Updated page: ${path}`)\n .join(`\\n`)}`\n )\n }\n\n if (deletedPageKeys.length) {\n report.info(\n `Deleted pages:\\n${deletedPageKeys\n .map(path => `Deleted page: ${path}`)\n .join(`\\n`)}`\n )\n }\n }\n\n if (\n process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES &&\n process.argv.includes(`--write-to-file`)\n ) {\n const createdFilesPath = path.resolve(\n `${program.directory}/.cache`,\n `newPages.txt`\n )\n const createdFilesContent = pagePaths.length\n ? `${pagePaths.join(`\\n`)}\\n`\n : ``\n\n const deletedFilesPath = path.resolve(\n `${program.directory}/.cache`,\n `deletedPages.txt`\n )\n const deletedFilesContent = deletedPageKeys.length\n ? `${deletedPageKeys.join(`\\n`)}\\n`\n : ``\n\n await fs.writeFile(createdFilesPath, createdFilesContent, `utf8`)\n report.info(`.cache/newPages.txt created`)\n\n await fs.writeFile(deletedFilesPath, deletedFilesContent, `utf8`)\n report.info(`.cache/deletedPages.txt created`)\n }\n\n if (await userGetsSevenDayFeedback()) {\n showSevenDayFeedbackRequest()\n } else if (await userPassesFeedbackRequestHeuristic()) {\n showFeedbackRequest()\n }\n}\n"],"file":"build.js"}
1
+ {"version":3,"sources":["../../src/commands/build.ts"],"names":["cachedPageData","cachedWebpackCompilationHash","process","env","GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES","pageData","webpackCompilationHash","module","exports","build","program","VERBOSE","verbose","report","setVerbose","profile","warn","name","sitePackageJson","sitePath","directory","lastRun","Date","now","pid","publicDir","path","join","openTracingConfigFile","buildActivity","phantomActivity","start","telemetry","trackCli","exitCode","buildSpan","span","setTag","gatsbyNodeGraphQLFunction","parentSpan","graphqlRunner","GraphQLRunner","store","collectStats","graphqlTracing","queryIds","graphql","buildActivityTimer","activityTimer","stats","err","panic","Stage","BuildJavascript","end","workerPool","WorkerPool","create","hash","getState","appDataUtil","exists","dispatch","type","payload","rewriteActivityTimer","write","pages","forEach","_value","key","has","boundActionCreators","removePageData","id","isTrackingEnabled","bundleSizes","toJson","assets","filter","asset","endsWith","map","size","pageDataSizes","pageDataStats","values","addSiteMeasurement","bundleStats","aggregateStats","queryStats","getStats","setProgramStatus","db","saveState","pagePaths","keys","buildUtils","getChangedPageDataKeys","info","stripIndent","buildSSRBundleActivityProgress","pageRenderer","BuildHTML","pagesCount","length","totalPagesCount","buildHTMLActivityProgress","createProgress","context","errorPath","ref","match","message","error","keepPageRenderer","deletedPageKeys","deletePageDataActivityTimer","collectRemovedPageData","removePageFiles","postBuildActivityTimer","uptime","finish","argv","includes","createdFilesPath","resolve","createdFilesContent","deletedFilesPath","deletedFilesContent","fs","writeFile"],"mappings":";;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAEA;;AAMA;;AAIA;;AAEA,IAAIA,cAAJ;AACA,IAAIC,4BAAJ;;AACA,IAAIC,OAAO,CAACC,GAAR,CAAYC,8CAAhB,EAAgE;AAC9D,QAAM;AAAEC,IAAAA,QAAF;AAAYC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eAAe,CAACzF,IAAhB,CAAsB,IAAtB,CAA2B,IADN,GAEvB,EAFL;AAIA,UAAMuG,iBAAGC,SAAH,CAAaN,gBAAb,EAA+BE,mBAA/B,EAAqD,MAArD,CAAN;;AACAlH,sBAAOsF,IAAP,CAAa,6BAAb;;AAEA,UAAM+B,iBAAGC,SAAH,CAAaH,gBAAb,EAA+BC,mBAA/B,EAAqD,MAArD,CAAN;;AACApH,sBAAOsF,IAAP,CAAa,iCAAb;AACD;;AAED,MAAI,MAAM,yCAAV,EAAsC;AACpC;AACD,GAFD,MAEO,IAAI,MAAM,mDAAV,EAAgD;AACrD;AACD;AACF,CA7UD","sourcesContent":["import path from \"path\"\nimport report from \"gatsby-cli/lib/reporter\"\nimport signalExit from \"signal-exit\"\nimport fs from \"fs-extra\"\nimport telemetry from \"gatsby-telemetry\"\n\nimport { doBuildPages, buildRenderer, deleteRenderer } from \"./build-html\"\nimport { buildProductionBundle } from \"./build-javascript\"\nimport { bootstrap } from \"../bootstrap\"\nimport apiRunnerNode from \"../utils/api-runner-node\"\nimport { GraphQLRunner } from \"../query/graphql-runner\"\nimport { copyStaticDirs } from \"../utils/get-static-dir\"\nimport { initTracer, stopTracer } from \"../utils/tracer\"\nimport db from \"../db\"\nimport { store, readState } from \"../redux\"\nimport * as appDataUtil from \"../utils/app-data\"\nimport { flush as flushPendingPageDataWrites } from \"../utils/page-data\"\nimport * as WorkerPool from \"../utils/worker/pool\"\nimport { structureWebpackErrors } from \"../utils/webpack-error-utils\"\nimport {\n userGetsSevenDayFeedback,\n userPassesFeedbackRequestHeuristic,\n showFeedbackRequest,\n showSevenDayFeedbackRequest,\n} from \"../utils/feedback\"\nimport * as buildUtils from \"./build-utils\"\nimport { boundActionCreators } from \"../redux/actions\"\nimport { waitUntilAllJobsComplete } from \"../utils/wait-until-jobs-complete\"\nimport { IProgram, Stage } from \"./types\"\nimport { PackageJson } from \"../..\"\nimport {\n calculateDirtyQueries,\n runStaticQueries,\n runPageQueries,\n writeOutRequires,\n} from \"../services\"\nimport {\n markWebpackStatusAsPending,\n markWebpackStatusAsDone,\n} from \"../utils/webpack-status\"\nimport { updateSiteMetadata, isTruthy } from \"gatsby-core-utils\"\n\nlet cachedPageData\nlet cachedWebpackCompilationHash\nif (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n const { pageData, webpackCompilationHash } = readState()\n // extract only data that we need to reuse and let v8 garbage collect rest of state\n cachedPageData = pageData\n cachedWebpackCompilationHash = webpackCompilationHash\n}\n\ninterface IBuildArgs extends IProgram {\n directory: string\n sitePackageJson: PackageJson\n prefixPaths: boolean\n noUglify: boolean\n profile: boolean\n graphqlTracing: boolean\n openTracingConfigFile: string\n keepPageRenderer: boolean\n}\n\nmodule.exports = async function build(program: IBuildArgs): Promise<void> {\n if (isTruthy(process.env.VERBOSE)) {\n program.verbose = true\n }\n report.setVerbose(program.verbose)\n\n if (program.profile) {\n report.warn(\n `React Profiling is enabled. This can have a performance impact. See https://www.gatsbyjs.org/docs/profiling-site-performance-with-react-profiler/#performance-impact`\n )\n }\n\n await updateSiteMetadata({\n name: program.sitePackageJson.name,\n sitePath: program.directory,\n lastRun: Date.now(),\n pid: process.pid,\n })\n\n markWebpackStatusAsPending()\n\n const publicDir = path.join(program.directory, `public`)\n initTracer(program.openTracingConfigFile)\n const buildActivity = report.phantomActivity(`build`)\n buildActivity.start()\n\n telemetry.trackCli(`BUILD_START`)\n signalExit(exitCode => {\n telemetry.trackCli(`BUILD_END`, { exitCode })\n })\n\n const buildSpan = buildActivity.span\n buildSpan.setTag(`directory`, program.directory)\n\n const { gatsbyNodeGraphQLFunction } = await bootstrap({\n program,\n parentSpan: buildSpan,\n })\n\n const graphqlRunner = new GraphQLRunner(store, {\n collectStats: true,\n graphqlTracing: program.graphqlTracing,\n })\n\n const { queryIds } = await calculateDirtyQueries({ store })\n\n await runStaticQueries({\n queryIds,\n parentSpan: buildSpan,\n store,\n graphqlRunner,\n })\n\n await runPageQueries({\n queryIds,\n graphqlRunner,\n parentSpan: buildSpan,\n store,\n })\n\n await writeOutRequires({\n store,\n parentSpan: buildSpan,\n })\n\n await apiRunnerNode(`onPreBuild`, {\n graphql: gatsbyNodeGraphQLFunction,\n parentSpan: buildSpan,\n })\n\n // Copy files from the static directory to\n // an equivalent static directory within public.\n copyStaticDirs()\n\n const buildActivityTimer = report.activityTimer(\n `Building production JavaScript and CSS bundles`,\n { parentSpan: buildSpan }\n )\n buildActivityTimer.start()\n let stats\n try {\n stats = await buildProductionBundle(program, buildActivityTimer.span)\n } catch (err) {\n buildActivityTimer.panic(structureWebpackErrors(Stage.BuildJavascript, err))\n } finally {\n buildActivityTimer.end()\n }\n\n const workerPool = WorkerPool.create()\n\n const webpackCompilationHash = stats.hash\n if (\n webpackCompilationHash !== store.getState().webpackCompilationHash ||\n !appDataUtil.exists(publicDir)\n ) {\n store.dispatch({\n type: `SET_WEBPACK_COMPILATION_HASH`,\n payload: webpackCompilationHash,\n })\n\n const rewriteActivityTimer = report.activityTimer(\n `Rewriting compilation hashes`,\n {\n parentSpan: buildSpan,\n }\n )\n rewriteActivityTimer.start()\n\n await appDataUtil.write(publicDir, webpackCompilationHash)\n\n rewriteActivityTimer.end()\n }\n\n await flushPendingPageDataWrites()\n markWebpackStatusAsDone()\n\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n const { pages } = store.getState()\n if (cachedPageData) {\n cachedPageData.forEach((_value, key) => {\n if (!pages.has(key)) {\n boundActionCreators.removePageData({\n id: key,\n })\n }\n })\n }\n }\n\n if (telemetry.isTrackingEnabled()) {\n // transform asset size to kB (from bytes) to fit 64 bit to numbers\n const bundleSizes = stats\n .toJson({ assets: true })\n .assets.filter(asset => asset.name.endsWith(`.js`))\n .map(asset => asset.size / 1000)\n const pageDataSizes = [...store.getState().pageDataStats.values()]\n\n telemetry.addSiteMeasurement(`BUILD_END`, {\n bundleStats: telemetry.aggregateStats(bundleSizes),\n pageDataStats: telemetry.aggregateStats(pageDataSizes),\n queryStats: graphqlRunner.getStats(),\n })\n }\n\n boundActionCreators.setProgramStatus(`BOOTSTRAP_QUERY_RUNNING_FINISHED`)\n\n await db.saveState()\n\n await waitUntilAllJobsComplete()\n\n // we need to save it again to make sure our latest state has been saved\n await db.saveState()\n\n let pagePaths = [...store.getState().pages.keys()]\n\n // Rebuild subset of pages if user opt into GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES\n // if there were no source files (for example components, static queries, etc) changes since last build, otherwise rebuild all pages\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n if (\n cachedWebpackCompilationHash === store.getState().webpackCompilationHash\n ) {\n pagePaths = buildUtils.getChangedPageDataKeys(\n store.getState(),\n cachedPageData\n )\n } else if (cachedWebpackCompilationHash) {\n report.info(\n report.stripIndent(`\n One or more of your source files have changed since the last time you ran Gatsby. All\n pages will be rebuilt.\n `)\n )\n }\n }\n\n const buildSSRBundleActivityProgress = report.activityTimer(\n `Building HTML renderer`,\n { parentSpan: buildSpan }\n )\n buildSSRBundleActivityProgress.start()\n let pageRenderer: string\n try {\n pageRenderer = await buildRenderer(program, Stage.BuildHTML, buildSpan)\n } catch (err) {\n buildActivityTimer.panic(structureWebpackErrors(Stage.BuildHTML, err))\n } finally {\n buildSSRBundleActivityProgress.end()\n }\n\n telemetry.addSiteMeasurement(`BUILD_END`, {\n pagesCount: pagePaths.length, // number of html files that will be written\n totalPagesCount: store.getState().pages.size, // total number of pages\n })\n\n const buildHTMLActivityProgress = report.createProgress(\n `Building static HTML for pages`,\n pagePaths.length,\n 0,\n {\n parentSpan: buildSpan,\n }\n )\n buildHTMLActivityProgress.start()\n try {\n await doBuildPages(\n pageRenderer,\n pagePaths,\n buildHTMLActivityProgress,\n workerPool\n )\n } catch (err) {\n let id = `95313` // TODO: verify error IDs exist\n const context = {\n errorPath: err.context && err.context.path,\n ref: ``,\n }\n\n const match = err.message.match(\n /ReferenceError: (window|document|localStorage|navigator|alert|location) is not defined/i\n )\n if (match && match[1]) {\n id = `95312`\n context.ref = match[1]\n }\n\n buildHTMLActivityProgress.panic({\n id,\n context,\n error: err,\n })\n }\n buildHTMLActivityProgress.end()\n\n if (!program.keepPageRenderer) {\n try {\n await deleteRenderer(pageRenderer)\n } catch (err) {\n // pass through\n }\n }\n\n let deletedPageKeys: Array<string> = []\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n const deletePageDataActivityTimer = report.activityTimer(\n `Delete previous page data`\n )\n deletePageDataActivityTimer.start()\n deletedPageKeys = buildUtils.collectRemovedPageData(\n store.getState(),\n cachedPageData\n )\n await buildUtils.removePageFiles(publicDir, deletedPageKeys)\n\n deletePageDataActivityTimer.end()\n }\n\n const postBuildActivityTimer = report.activityTimer(`onPostBuild`, {\n parentSpan: buildSpan,\n })\n postBuildActivityTimer.start()\n await apiRunnerNode(`onPostBuild`, {\n graphql: gatsbyNodeGraphQLFunction,\n parentSpan: buildSpan,\n })\n postBuildActivityTimer.end()\n\n // Wait for any jobs that were started in onPostBuild\n // This could occur due to queries being run which invoke sharp for instance\n await waitUntilAllJobsComplete()\n\n // Make sure we saved the latest state so we have all jobs cached\n await db.saveState()\n\n report.info(`Done building in ${process.uptime()} sec`)\n\n buildSpan.finish()\n await stopTracer()\n workerPool.end()\n buildActivity.end()\n\n if (\n process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES &&\n process.argv.includes(`--log-pages`)\n ) {\n if (pagePaths.length) {\n report.info(\n `Built pages:\\n${pagePaths\n .map(path => `Updated page: ${path}`)\n .join(`\\n`)}`\n )\n }\n\n if (deletedPageKeys.length) {\n report.info(\n `Deleted pages:\\n${deletedPageKeys\n .map(path => `Deleted page: ${path}`)\n .join(`\\n`)}`\n )\n }\n }\n\n if (\n process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES &&\n process.argv.includes(`--write-to-file`)\n ) {\n const createdFilesPath = path.resolve(\n `${program.directory}/.cache`,\n `newPages.txt`\n )\n const createdFilesContent = pagePaths.length\n ? `${pagePaths.join(`\\n`)}\\n`\n : ``\n\n const deletedFilesPath = path.resolve(\n `${program.directory}/.cache`,\n `deletedPages.txt`\n )\n const deletedFilesContent = deletedPageKeys.length\n ? `${deletedPageKeys.join(`\\n`)}\\n`\n : ``\n\n await fs.writeFile(createdFilesPath, createdFilesContent, `utf8`)\n report.info(`.cache/newPages.txt created`)\n\n await fs.writeFile(deletedFilesPath, deletedFilesContent, `utf8`)\n report.info(`.cache/deletedPages.txt created`)\n }\n\n if (await userGetsSevenDayFeedback()) {\n showSevenDayFeedbackRequest()\n } else if (await userPassesFeedbackRequestHeuristic()) {\n showFeedbackRequest()\n }\n}\n"],"file":"build.js"}
@@ -87,7 +87,11 @@ const openDebuggerPort = debugInfo => {
87
87
  };
88
88
 
89
89
  module.exports = async program => {
90
- _reporter.default.setVerbose((0, _gatsbyCoreUtils.isTruthy)(process.env.VERBOSE) || program.verbose);
90
+ if ((0, _gatsbyCoreUtils.isTruthy)(process.env.VERBOSE)) {
91
+ program.verbose = true;
92
+ }
93
+
94
+ _reporter.default.setVerbose(program.verbose);
91
95
 
92
96
  if (program.debugInfo) {
93
97
  openDebuggerPort(program.debugInfo);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/develop-process.ts"],"names":["tracer","setTimeout","process","send","setInterval","type","telemetry","trackCli","siteMeasurements","totalPagesCount","store","getState","pages","size","on","msg","action","exit","payload","openDebuggerPort","debugInfo","inspector","url","undefined","break","open","port","module","exports","program","reporter","setVerbose","env","VERBOSE","verbose","GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES","panic","chalk","yellow","cyan","openTracingConfigFile","pendingActivity","id","startBackgroundUpdate","parseInt","e","message","app","parentSpan","startSpan","machine","developMachine","withContext","pendingQueryRuns","Set","service","start"],"mappings":";;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;A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AZ;AACA,QAAMC,UAAU,GAAGhD,MAAM,CAACiD,SAAP,CAAkB,WAAlB,CAAnB;;AAEA,QAAMC,OAAO,GAAGC,wBAAeC,WAAf,CAA2B;AACzCvB,IAAAA,OADyC;AAEzCmB,IAAAA,UAFyC;AAGzCD,IAAAA,GAHyC;AAIzCM,IAAAA,gBAAgB,EAAE,IAAIC,GAAJ,CAAQ,CAAE,GAAF,CAAR;AAJuB,GAA3B,CAAhB;;AAOA,QAAMC,OAAO,GAAG,uBAAUL,OAAV,CAAhB;;AAEA,MAAIrB,OAAO,CAACK,OAAZ,EAAqB;AACnB,6CAAeqB,OAAf;AACD;;AAEDA,EAAAA,OAAO,CAACC,KAAR;AACD,CAnED","sourcesContent":["import { syncStaticDir } from \"../utils/get-static-dir\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport chalk from \"chalk\"\nimport telemetry from \"gatsby-telemetry\"\nimport { isTruthy } from \"gatsby-core-utils\"\nimport express from \"express\"\nimport inspector from \"inspector\"\nimport { initTracer } from \"../utils/tracer\"\nimport { detectPortInUseAndPrompt } from \"../utils/detect-port-in-use-and-prompt\"\nimport onExit from \"signal-exit\"\nimport {\n userGetsSevenDayFeedback,\n userPassesFeedbackRequestHeuristic,\n showFeedbackRequest,\n showSevenDayFeedbackRequest,\n} from \"../utils/feedback\"\nimport { markWebpackStatusAsPending } from \"../utils/webpack-status\"\nimport { store } from \"../redux\"\n\nimport { IProgram, IDebugInfo } from \"./types\"\nimport { interpret } from \"xstate\"\nimport { globalTracer } from \"opentracing\"\nimport { developMachine } from \"../state-machines/develop\"\nimport { logTransitions } from \"../utils/state-machine-logging\"\n\nconst tracer = globalTracer()\n\n// const isInteractive = process.stdout.isTTY\n\n// Watch the static directory and copy files to public as they're added or\n// changed. Wait 10 seconds so copying doesn't interfere with the regular\n// bootstrap.\nsetTimeout(() => {\n syncStaticDir()\n}, 10000)\n\n// Time for another story...\n// When the parent process is killed by SIGKILL, Node doesm't kill spawned child processes\n// Hence, we peiodically send a heart beat to the parent to check if it is still alive\n// This will crash with Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed\n// and kill the orphaned child process as a result\nif (process.send) {\n setInterval(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n process.send!({\n type: `HEARTBEAT`,\n })\n }, 1000)\n}\n\nonExit(() => {\n telemetry.trackCli(`DEVELOP_STOP`, {\n siteMeasurements: {\n totalPagesCount: store.getState().pages.size,\n },\n })\n})\n\nprocess.on(`message`, msg => {\n if (msg.type === `COMMAND` && msg.action.type === `EXIT`) {\n process.exit(msg.action.payload)\n }\n})\n\ninterface IDevelopArgs extends IProgram {\n debugInfo: IDebugInfo | null\n}\n\nconst openDebuggerPort = (debugInfo: IDebugInfo): void => {\n if (inspector.url() !== undefined) {\n return // fixes #26708\n }\n\n if (debugInfo.break) {\n inspector.open(debugInfo.port, undefined, true)\n // eslint-disable-next-line no-debugger\n debugger\n } else {\n inspector.open(debugInfo.port)\n }\n}\n\nmodule.exports = async (program: IDevelopArgs): Promise<void> => {\n reporter.setVerbose(isTruthy(process.env.VERBOSE) || program.verbose)\n\n if (program.debugInfo) {\n openDebuggerPort(program.debugInfo)\n }\n\n // We want to prompt the feedback request when users quit develop\n // assuming they pass the heuristic check to know they are a user\n // we want to request feedback from, and we're not annoying them.\n process.on(\n `SIGINT`,\n async (): Promise<void> => {\n if (await userGetsSevenDayFeedback()) {\n showSevenDayFeedbackRequest()\n } else if (await userPassesFeedbackRequestHeuristic()) {\n showFeedbackRequest()\n }\n process.exit(0)\n }\n )\n\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n reporter.panic(\n `The flag ${chalk.yellow(\n `GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES`\n )} is not available with ${chalk.cyan(\n `gatsby develop`\n )}, please retry using ${chalk.cyan(`gatsby build`)}`\n )\n }\n initTracer(program.openTracingConfigFile)\n markWebpackStatusAsPending()\n reporter.pendingActivity({ id: `webpack-develop` })\n telemetry.trackCli(`DEVELOP_START`)\n telemetry.startBackgroundUpdate()\n\n const port =\n typeof program.port === `string` ? parseInt(program.port, 10) : program.port\n\n try {\n program.port = await detectPortInUseAndPrompt(port)\n } catch (e) {\n if (e.message === `USER_REJECTED`) {\n process.exit(0)\n }\n\n throw e\n }\n\n const app = express()\n const parentSpan = tracer.startSpan(`bootstrap`)\n\n const machine = developMachine.withContext({\n program,\n parentSpan,\n app,\n pendingQueryRuns: new Set([`/`]),\n })\n\n const service = interpret(machine)\n\n if (program.verbose) {\n logTransitions(service)\n }\n\n service.start()\n}\n"],"file":"develop-process.js"}
1
+ {"version":3,"sources":["../../src/commands/develop-process.ts"],"names":["tracer","setTimeout","process","send","setInterval","type","telemetry","trackCli","siteMeasurements","totalPagesCount","store","getState","pages","size","on","msg","action","exit","payload","openDebuggerPort","debugInfo","inspector","url","undefined","break","open","port","module","exports","program","env","VERBOSE","verbose","reporter","setVerbose","GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES","panic","chalk","yellow","cyan","openTracingConfigFile","pendingActivity","id","startBackgroundUpdate","parseInt","e","message","app","parentSpan","startSpan","machine","developMachine","withContext","pendingQueryRuns","Set","service","start"],"mappings":";;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AAEA,MAAMA,MAAM,GAAG,gCAAf,C,CAEA;AAEA;AACA;AACA;;AACAC,UAAU,CAAC,MAAM;AACf;AACD,CAFS,EAEP,KAFO,CAAV,C,CAIA;AACA;AACA;AACA;AACA;;AACA,IAAIC,OAAO,CAACC,IAAZ,EAAkB;AAChBC,EAAAA,WAAW,CAAC,MAAM;AAChB;AACAF,IAAAA,OAAO,CAACC,IAAR,CAAc;AACZE,MAAAA,IAAI,EAAG;AADK,KAAd;AAGD,GALU,EAKR,IALQ,CAAX;AAMD;;AAED,yBAAO,MAAM;AACXC,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CAACG,OAAZ,EAAqB;AACnB,6CAAeuB,OAAf;AACD;;AAEDA,EAAAA,OAAO,CAACC,KAAR;AACD,CAtED","sourcesContent":["import { syncStaticDir } from \"../utils/get-static-dir\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport chalk from \"chalk\"\nimport telemetry from \"gatsby-telemetry\"\nimport { isTruthy } from \"gatsby-core-utils\"\nimport express from \"express\"\nimport inspector from \"inspector\"\nimport { initTracer } from \"../utils/tracer\"\nimport { detectPortInUseAndPrompt } from \"../utils/detect-port-in-use-and-prompt\"\nimport onExit from \"signal-exit\"\nimport {\n userGetsSevenDayFeedback,\n userPassesFeedbackRequestHeuristic,\n showFeedbackRequest,\n showSevenDayFeedbackRequest,\n} from \"../utils/feedback\"\nimport { markWebpackStatusAsPending } from \"../utils/webpack-status\"\nimport { store } from \"../redux\"\n\nimport { IProgram, IDebugInfo } from \"./types\"\nimport { interpret } from \"xstate\"\nimport { globalTracer } from \"opentracing\"\nimport { developMachine } from \"../state-machines/develop\"\nimport { logTransitions } from \"../utils/state-machine-logging\"\n\nconst tracer = globalTracer()\n\n// const isInteractive = process.stdout.isTTY\n\n// Watch the static directory and copy files to public as they're added or\n// changed. Wait 10 seconds so copying doesn't interfere with the regular\n// bootstrap.\nsetTimeout(() => {\n syncStaticDir()\n}, 10000)\n\n// Time for another story...\n// When the parent process is killed by SIGKILL, Node doesm't kill spawned child processes\n// Hence, we peiodically send a heart beat to the parent to check if it is still alive\n// This will crash with Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed\n// and kill the orphaned child process as a result\nif (process.send) {\n setInterval(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n process.send!({\n type: `HEARTBEAT`,\n })\n }, 1000)\n}\n\nonExit(() => {\n telemetry.trackCli(`DEVELOP_STOP`, {\n siteMeasurements: {\n totalPagesCount: store.getState().pages.size,\n },\n })\n})\n\nprocess.on(`message`, msg => {\n if (msg.type === `COMMAND` && msg.action.type === `EXIT`) {\n process.exit(msg.action.payload)\n }\n})\n\ninterface IDevelopArgs extends IProgram {\n debugInfo: IDebugInfo | null\n}\n\nconst openDebuggerPort = (debugInfo: IDebugInfo): void => {\n if (inspector.url() !== undefined) {\n return // fixes #26708\n }\n\n if (debugInfo.break) {\n inspector.open(debugInfo.port, undefined, true)\n // eslint-disable-next-line no-debugger\n debugger\n } else {\n inspector.open(debugInfo.port)\n }\n}\n\nmodule.exports = async (program: IDevelopArgs): Promise<void> => {\n if (isTruthy(process.env.VERBOSE)) {\n program.verbose = true\n }\n reporter.setVerbose(program.verbose)\n\n if (program.debugInfo) {\n openDebuggerPort(program.debugInfo)\n }\n\n // We want to prompt the feedback request when users quit develop\n // assuming they pass the heuristic check to know they are a user\n // we want to request feedback from, and we're not annoying them.\n process.on(\n `SIGINT`,\n async (): Promise<void> => {\n if (await userGetsSevenDayFeedback()) {\n showSevenDayFeedbackRequest()\n } else if (await userPassesFeedbackRequestHeuristic()) {\n showFeedbackRequest()\n }\n process.exit(0)\n }\n )\n\n if (process.env.GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES) {\n reporter.panic(\n `The flag ${chalk.yellow(\n `GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES`\n )} is not available with ${chalk.cyan(\n `gatsby develop`\n )}, please retry using ${chalk.cyan(`gatsby build`)}`\n )\n }\n initTracer(program.openTracingConfigFile)\n markWebpackStatusAsPending()\n reporter.pendingActivity({ id: `webpack-develop` })\n telemetry.trackCli(`DEVELOP_START`)\n telemetry.startBackgroundUpdate()\n\n const port =\n typeof program.port === `string` ? parseInt(program.port, 10) : program.port\n\n try {\n program.port = await detectPortInUseAndPrompt(port)\n } catch (e) {\n if (e.message === `USER_REJECTED`) {\n process.exit(0)\n }\n\n throw e\n }\n\n const app = express()\n const parentSpan = tracer.startSpan(`bootstrap`)\n\n const machine = developMachine.withContext({\n program,\n parentSpan,\n app,\n pendingQueryRuns: new Set([`/`]),\n })\n\n const service = interpret(machine)\n\n if (program.verbose) {\n logTransitions(service)\n }\n\n service.start()\n}\n"],"file":"develop-process.js"}
@@ -21,7 +21,7 @@ var _detectPort = _interopRequireDefault(require("detect-port"));
21
21
 
22
22
  var _detectPortInUseAndPrompt = require("../utils/detect-port-in-use-and-prompt");
23
23
 
24
- var _socket = _interopRequireDefault(require("socket.io"));
24
+ var _socket = require("socket.io");
25
25
 
26
26
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
27
27
 
@@ -305,7 +305,13 @@ module.exports = async program => {
305
305
 
306
306
  const statusServer = program.ssl ? _https.default.createServer(program.ssl) : _http.default.createServer();
307
307
  statusServer.listen(statusServerPort);
308
- const io = (0, _socket.default)(statusServer);
308
+ const io = new _socket.Server(statusServer, {
309
+ // whitelist all (https://github.com/expressjs/cors#configuration-options)
310
+ cors: {
311
+ origin: true
312
+ },
313
+ cookie: true
314
+ });
309
315
 
310
316
  const handleChildProcessIPC = msg => {
311
317
  if (msg.type === `HEARTBEAT`) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/develop.ts"],"names":["requireUncached","file","require","cache","resolve","e","doesConfigChangeRequireRestart","lastConfig","newConfig","replacer","_","v","RegExp","toString","oldConfigString","JSON","stringify","siteMetadata","newConfigString","getDebugPort","port","getDebugInfo","program","hasOwnProperty","inspect","break","inspectBrk","ControllableScript","constructor","script","debugInfo","start","args","tmpFileName","tmp","tmpNameSync","tmpdir","path","join","process","cwd","fs","outputFileSync","isRunning","push","execa","node","env","stdio","stop","signal","code","Error","kill","send","type","action","payload","Promise","on","removeAllListeners","undefined","onMessage","callback","onExit","msg","isRestarting","REGEX_IP","module","exports","parseInt","developProcessPath","telemetryServerPath","message","exit","proxyPort","rootFile","directory","statusServerPort","developPort","telemetryServerPort","all","INTERNAL_STATUS_PORT","https","reporter","panic","sslHost","host","test","ssl","name","caFile","certFile","keyFile","proxy","targetPort","developProcess","telemetryServerProcess","unlocks","statusUnlock","developUnlock","telemetryUnlock","sitePackageJson","sitePath","pid","lastRun","Date","now","data","console","error","concat","statusServer","createServer","http","listen","io","handleChildProcessIPC","emit","serveSite","socket","respond","serveRestartingScreen","files","watcher","chokidar","watch","filePath","basename","warn","dirtyFile","shutdownServices","_code","services","close","server","forEach","unlock","catch","then"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AAvBA;AA0BA;AACA,MAAMA,eAAe,GAAIC,IAAD,IAAuB;AAC7C,MAAI;AACF,WAAOC,OAAO,CAACC,KAAR,CAAcD,OAAO,CAACE,OAAR,CAAgBH,IAAhB,CAAd,CAAP;AACD,GAFD,CAEE,OAAOI,CAAP,EAAU;AACV,WAAO,IAAP;AACD;;AAED,MAAI;AACF,WAAOH,OAAO,CAACD,IAAD,CAAd;AACD,GAFD,CAEE,OAAOI,CAAP,EAAU;AACV,WAAO,IAAP;AACD;AACF,CAZD,C,CAcA;;;AACA,MAAMC,8BAA8B,GAAG,CACrCC,UADqC,EAErCC,SAFqC,KAGzB;AACZ;AACA,QAAMC,QAAQ,GAAG,CAACC,CAAD,EAAIC,CAAJ,KAAyB;AACxC,QAAI,OAAOA,CAAP,KAAc,UAAd,IAA2BA,CAAC,YAAYC,MAA5C,EAAoD;AAClD,aAAOD,CAAC,CAACE,QAAF,EAAP;AACD,KAFD,MAEO;AACL,aAAOF,CAAP;AACD;AACF,GAND;;AAQA,QAAMG,eAAe,GAAGC,IAAI,CAACC,SAAL,CACtB,EAAE,GAAGT,UAAL;AAAiBU,IAAAA,YAAY,EAAE;AAA/B,GADsB,EAEtBR,QAFsB,CAAxB;AAIA,QAAMS,eAAe,GAAGH,IAAI,CAACC,SAAL,CACtB,EAAE,GAAGR,SAAL;AAAgBS,IAAAA,YAAY,EAAE;AAA9B,GADsB,EAEtBR,QAFsB,CAAxB;AAKA,MAAIK,eAAe,KAAKI,eAAxB,EAAyC,OAAO,KAAP;AAEzC,SAAO,IAAP;AACD,C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I,OAAnB,CAAvB,CAJe,EAKf,IAAIsD,OAAJ,CAAYtD,OAAO,IAAI0F,KAAK,CAACyC,MAAN,CAAaD,KAAb,CAAmBlI,OAAnB,CAAvB,CALe,CAAjB;AAQA8F,EAAAA,OAAO,CAACsC,OAAR,CAAgBC,MAAM,IAAI;AACxBJ,IAAAA,QAAQ,CAACzF,IAAT,CAAc6F,MAAM,EAApB;AACD,GAFD;AAIA,SAAO/E,OAAO,CAACuB,GAAR,CAAYoD,QAAZ,EACJK,KADI,CACE,MAAM,CAAE,CADV,EAEJC,IAFI,CAEC,MAAM,CAAE,CAFT,CAAP;AAGD","sourcesContent":["// NOTE(@mxstbr): Do not use the reporter in this file, as that has side-effects on import which break structured logging\nimport path from \"path\"\nimport http from \"http\"\nimport https from \"https\"\nimport tmp from \"tmp\"\nimport { ChildProcess } from \"child_process\"\nimport execa from \"execa\"\nimport chokidar from \"chokidar\"\nimport getRandomPort from \"detect-port\"\nimport { detectPortInUseAndPrompt } from \"../utils/detect-port-in-use-and-prompt\"\nimport socket from \"socket.io\"\nimport fs from \"fs-extra\"\nimport onExit from \"signal-exit\"\nimport {\n isCI,\n slash,\n createServiceLock,\n getService,\n updateSiteMetadata,\n UnlockFn,\n} from \"gatsby-core-utils\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport { getSslCert } from \"../utils/get-ssl-cert\"\nimport { startDevelopProxy } from \"../utils/develop-proxy\"\nimport { IProgram, IDebugInfo } from \"./types\"\n\n// Adapted from https://stackoverflow.com/a/16060619\nconst requireUncached = (file: string): any => {\n try {\n delete require.cache[require.resolve(file)]\n } catch (e) {\n return null\n }\n\n try {\n return require(file)\n } catch (e) {\n return null\n }\n}\n\n// Heuristics for gatsby-config.js, as not all changes to it require a full restart to take effect\nconst doesConfigChangeRequireRestart = (\n lastConfig: Record<string, any>,\n newConfig: Record<string, any>\n): boolean => {\n // Ignore changes to siteMetadata\n const replacer = (_, v): string | void => {\n if (typeof v === `function` || v instanceof RegExp) {\n return v.toString()\n } else {\n return v\n }\n }\n\n const oldConfigString = JSON.stringify(\n { ...lastConfig, siteMetadata: null },\n replacer\n )\n const newConfigString = JSON.stringify(\n { ...newConfig, siteMetadata: null },\n replacer\n )\n\n if (oldConfigString === newConfigString) return false\n\n return true\n}\n\n// Return a user-supplied port otherwise the default Node.js debugging port\nconst getDebugPort = (port?: number): number => port ?? 9229\n\nexport const getDebugInfo = (program: IProgram): IDebugInfo | null => {\n if (program.hasOwnProperty(`inspect`)) {\n return {\n port: getDebugPort(program.inspect),\n break: false,\n }\n } else if (program.hasOwnProperty(`inspectBrk`)) {\n return {\n port: getDebugPort(program.inspectBrk),\n break: true,\n }\n } else {\n return null\n }\n}\n\nclass ControllableScript {\n private process?: ChildProcess\n private script\n private debugInfo: IDebugInfo | null\n public isRunning\n constructor(script, debugInfo: IDebugInfo | null) {\n this.script = script\n this.debugInfo = debugInfo\n }\n start(): void {\n const args = []\n const tmpFileName = tmp.tmpNameSync({\n tmpdir: path.join(process.cwd(), `.cache`),\n })\n fs.outputFileSync(tmpFileName, this.script)\n this.isRunning = true\n // Passing --inspect isn't necessary for the child process to launch a port but it allows some editors to automatically attach\n if (this.debugInfo) {\n if (this.debugInfo.break) {\n args.push(`--inspect-brk=${this.debugInfo.port}`)\n } else {\n args.push(`--inspect=${this.debugInfo.port}`)\n }\n }\n\n this.process = execa.node(tmpFileName, args, {\n env: process.env,\n stdio: [`inherit`, `inherit`, `inherit`, `ipc`],\n })\n }\n async stop(\n signal: NodeJS.Signals | null = null,\n code?: number\n ): Promise<void> {\n if (!this.process) {\n throw new Error(`Trying to stop the process before starting it`)\n }\n\n this.isRunning = false\n if (signal) {\n this.process.kill(signal)\n } else {\n this.process.send({\n type: `COMMAND`,\n action: {\n type: `EXIT`,\n payload: code,\n },\n })\n }\n\n return new Promise(resolve => {\n if (!this.process) {\n throw new Error(`Trying to stop the process before starting it`)\n }\n\n this.process.on(`exit`, () => {\n if (this.process) {\n this.process.removeAllListeners()\n }\n this.process = undefined\n resolve()\n })\n })\n }\n onMessage(callback: (msg: any) => void): void {\n if (!this.process) {\n throw new Error(`Trying to attach message handler before process started`)\n }\n this.process.on(`message`, callback)\n }\n onExit(\n callback: (code: number | null, signal: NodeJS.Signals | null) => void\n ): void {\n if (!this.process) {\n throw new Error(`Trying to attach exit handler before process started`)\n }\n this.process.on(`exit`, callback)\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n send(msg: any): void {\n if (!this.process) {\n throw new Error(`Trying to send a message before process started`)\n }\n\n this.process.send(msg)\n }\n}\n\nlet isRestarting\n\n// checks if a string is a valid ip\nconst REGEX_IP = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/\n\nmodule.exports = async (program: IProgram): Promise<void> => {\n // In some cases, port can actually be a string. But our codebase is expecting it to be a number.\n // So we want to early just force it to a number to ensure we always act on a correct type.\n program.port = parseInt(program.port + ``, 10)\n const developProcessPath = slash(require.resolve(`./develop-process`))\n const telemetryServerPath = slash(\n require.resolve(`../utils/telemetry-server`)\n )\n\n try {\n program.port = await detectPortInUseAndPrompt(program.port)\n } catch (e) {\n if (e.message === `USER_REJECTED`) {\n process.exit(0)\n }\n\n throw e\n }\n\n // Run the actual develop server on a random port, and the proxy on the program port\n // which users will access\n const proxyPort = program.port\n const debugInfo = getDebugInfo(program)\n\n const rootFile = (file: string): string => path.join(program.directory, file)\n\n // Require gatsby-config.js before accessing process.env, to enable the user to change\n // environment variables from the config file.\n let lastConfig = requireUncached(rootFile(`gatsby-config.js`))\n\n // INTERNAL_STATUS_PORT allows for setting the websocket port used for monitoring\n // when the browser should prompt the user to restart the develop process.\n // This port is randomized by default and in most cases should never be required to configure.\n // It is exposed for environments where port access needs to be explicit, such as with Docker.\n // As the port is meant for internal usage only, any attempt to interface with features\n // it exposes via third-party software is not supported.\n const [\n statusServerPort,\n developPort,\n telemetryServerPort,\n ] = await Promise.all([\n getRandomPort(process.env.INTERNAL_STATUS_PORT),\n getRandomPort(),\n getRandomPort(),\n ])\n\n // In order to enable custom ssl, --cert-file --key-file and -https flags must all be\n // used together\n if ((program[`cert-file`] || program[`key-file`]) && !program.https) {\n reporter.panic(\n `for custom ssl --https, --cert-file, and --key-file must be used together`\n )\n }\n\n // Check if https is enabled, then create or get SSL cert.\n // Certs are named 'devcert' and issued to the host.\n // NOTE(@mxstbr): We mutate program.ssl _after_ passing it\n // to the develop process controllable script above because\n // that would mean we double SSL browser => proxy => server\n if (program.https) {\n const sslHost =\n program.host === `0.0.0.0` || program.host === `::`\n ? `localhost`\n : program.host\n\n if (REGEX_IP.test(sslHost)) {\n reporter.panic(\n `You're trying to generate a ssl certificate for an IP (${sslHost}). Please use a hostname instead.`\n )\n }\n\n const ssl = await getSslCert({\n name: sslHost,\n caFile: program[`ca-file`],\n certFile: program[`cert-file`],\n keyFile: program[`key-file`],\n directory: program.directory,\n })\n\n if (ssl) {\n program.ssl = ssl\n }\n }\n\n // NOTE(@mxstbr): We need to start the develop proxy before the develop process to ensure\n // codesandbox detects the right port to expose by default\n const proxy = startDevelopProxy({\n proxyPort: proxyPort,\n targetPort: developPort,\n program,\n })\n\n const developProcess = new ControllableScript(\n `\n const cmd = require(${JSON.stringify(developProcessPath)});\n const args = ${JSON.stringify({\n ...program,\n port: developPort,\n proxyPort,\n // Don't pass SSL options down to the develop process, it should always use HTTP\n ssl: null,\n debugInfo,\n })};\n cmd(args);\n `,\n debugInfo\n )\n\n const telemetryServerProcess = new ControllableScript(\n `require(${JSON.stringify(telemetryServerPath)}).default(${JSON.stringify(\n telemetryServerPort\n )})`,\n null\n )\n\n let unlocks: Array<UnlockFn> = []\n if (!isCI()) {\n const statusUnlock = await createServiceLock(\n program.directory,\n `developstatusserver`,\n {\n port: statusServerPort,\n }\n )\n const developUnlock = await createServiceLock(\n program.directory,\n `developproxy`,\n {\n port: proxyPort,\n }\n )\n const telemetryUnlock = await createServiceLock(\n program.directory,\n `telemetryserver`,\n {\n port: telemetryServerPort,\n }\n )\n await updateSiteMetadata({\n name: program.sitePackageJson.name,\n sitePath: program.directory,\n pid: process.pid,\n lastRun: Date.now(),\n })\n\n if (!statusUnlock || !developUnlock) {\n const data = await getService(program.directory, `developproxy`)\n const port = data?.port || 8000\n console.error(\n `Looks like develop for this site is already running, can you visit ${\n program.ssl ? `https:` : `http:`\n }//localhost:${port} ? If it is not, try again in five seconds!`\n )\n process.exit(1)\n }\n\n unlocks = unlocks.concat([statusUnlock, developUnlock, telemetryUnlock])\n }\n\n const statusServer = program.ssl\n ? https.createServer(program.ssl)\n : http.createServer()\n statusServer.listen(statusServerPort)\n\n const io = socket(statusServer)\n\n const handleChildProcessIPC = (msg): void => {\n if (msg.type === `HEARTBEAT`) return\n if (process.send) {\n // Forward IPC\n process.send(msg)\n }\n\n io.emit(`structured-log`, msg)\n\n if (\n msg.type === `LOG_ACTION` &&\n msg.action.type === `SET_STATUS` &&\n msg.action.payload === `SUCCESS`\n ) {\n proxy.serveSite()\n }\n }\n\n io.on(`connection`, socket => {\n socket.on(`develop:restart`, async respond => {\n isRestarting = true\n proxy.serveRestartingScreen()\n // respond() responds to the client, which in our case prompts it to reload the page to show the restarting screen\n if (respond) respond(`develop:is-starting`)\n await developProcess.stop()\n developProcess.start()\n developProcess.onMessage(handleChildProcessIPC)\n isRestarting = false\n })\n })\n\n developProcess.start()\n developProcess.onMessage(handleChildProcessIPC)\n\n telemetryServerProcess.start()\n\n // Plugins can call `process.exit` which would be sent to `develop-process` (child process)\n // This needs to be propagated back to the parent process\n developProcess.onExit(\n (code: number | null, signal: NodeJS.Signals | null) => {\n if (isRestarting) return\n if (signal !== null) {\n process.kill(process.pid, signal)\n return\n }\n if (code !== null) {\n process.exit(code)\n }\n\n // This should not happen:\n // https://nodejs.org/api/child_process.html#child_process_event_exit\n // The 'exit' event is emitted after the child process ends. If the process\n // exited, code is the final exit code of the process, otherwise null.\n // If the process terminated due to receipt of a signal, signal is the\n // string name of the signal, otherwise null. One of the two will always be\n // non - null.\n //\n // but just in case let do non-zero exit, because we are in situation\n // we don't expect to be possible\n process.exit(1)\n }\n )\n\n const files = [rootFile(`gatsby-config.js`), rootFile(`gatsby-node.js`)]\n let watcher: chokidar.FSWatcher = null\n\n if (!isCI()) {\n watcher = chokidar.watch(files).on(`change`, filePath => {\n const file = path.basename(filePath)\n\n if (file === `gatsby-config.js`) {\n const newConfig = requireUncached(rootFile(`gatsby-config.js`))\n\n if (!doesConfigChangeRequireRestart(lastConfig, newConfig)) {\n lastConfig = newConfig\n return\n }\n\n lastConfig = newConfig\n }\n\n console.warn(\n `develop process needs to be restarted to apply the changes to ${file}`\n )\n io.emit(`structured-log`, {\n type: `LOG_ACTION`,\n action: {\n type: `DEVELOP`,\n payload: `RESTART_REQUIRED`,\n dirtyFile: file,\n },\n })\n })\n }\n\n // route ipc messaging to the original develop process\n process.on(`message`, msg => {\n developProcess.send(msg)\n })\n\n process.on(`SIGINT`, async () => {\n await shutdownServices(\n {\n developProcess,\n telemetryServerProcess,\n unlocks,\n statusServer,\n proxy,\n watcher,\n },\n `SIGINT`\n )\n\n process.exit(0)\n })\n\n process.on(`SIGTERM`, async () => {\n await shutdownServices(\n {\n developProcess,\n telemetryServerProcess,\n unlocks,\n statusServer,\n proxy,\n watcher,\n },\n `SIGTERM`\n )\n\n process.exit(0)\n })\n\n onExit((_code, signal) => {\n shutdownServices(\n {\n developProcess,\n telemetryServerProcess,\n unlocks,\n statusServer,\n proxy,\n watcher,\n },\n signal as NodeJS.Signals\n )\n })\n}\nfunction shutdownServices(\n {\n statusServer,\n developProcess,\n proxy,\n unlocks,\n watcher,\n telemetryServerProcess,\n },\n signal: NodeJS.Signals\n): Promise<void> {\n const services = [\n developProcess.stop(signal),\n telemetryServerProcess.stop(),\n watcher?.close(),\n new Promise(resolve => statusServer.close(resolve)),\n new Promise(resolve => proxy.server.close(resolve)),\n ]\n\n unlocks.forEach(unlock => {\n services.push(unlock())\n })\n\n return Promise.all(services)\n .catch(() => {})\n .then(() => {})\n}\n"],"file":"develop.js"}
1
+ {"version":3,"sources":["../../src/commands/develop.ts"],"names":["requireUncached","file","require","cache","resolve","e","doesConfigChangeRequireRestart","lastConfig","newConfig","replacer","_","v","RegExp","toString","oldConfigString","JSON","stringify","siteMetadata","newConfigString","getDebugPort","port","getDebugInfo","program","hasOwnProperty","inspect","break","inspectBrk","ControllableScript","constructor","script","debugInfo","start","args","tmpFileName","tmp","tmpNameSync","tmpdir","path","join","process","cwd","fs","outputFileSync","isRunning","push","execa","node","env","stdio","stop","signal","code","Error","kill","send","type","action","payload","Promise","on","removeAllListeners","undefined","onMessage","callback","onExit","msg","isRestarting","REGEX_IP","module","exports","parseInt","developProcessPath","telemetryServerPath","message","exit","proxyPort","rootFile","directory","statusServerPort","developPort","telemetryServerPort","all","INTERNAL_STATUS_PORT","https","reporter","panic","sslHost","host","test","ssl","name","caFile","certFile","keyFile","proxy","targetPort","developProcess","telemetryServerProcess","unlocks","statusUnlock","developUnlock","telemetryUnlock","sitePackageJson","sitePath","pid","lastRun","Date","now","data","console","error","concat","statusServer","createServer","http","listen","io","SocketIO","cors","origin","cookie","handleChildProcessIPC","emit","serveSite","socket","respond","serveRestartingScreen","files","watcher","chokidar","watch","filePath","basename","warn","dirtyFile","shutdownServices","_code","services","close","server","forEach","unlock","catch","then"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AAvBA;AA0BA;AACA,MAAMA,eAAe,GAAIC,IAAD,IAAuB;AAC7C,MAAI;AACF,WAAOC,OAAO,CAACC,KAAR,CAAcD,OAAO,CAACE,OAAR,CAAgBH,IAAhB,CAAd,CAAP;AACD,GAFD,CAEE,OAAOI,CAAP,EAAU;AACV,WAAO,IAAP;AACD;;AAED,MAAI;AACF,WAAOH,OAAO,CAACD,IAAD,CAAd;AACD,GAFD,CAEE,OAA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OTE(@mxstbr): Do not use the reporter in this file, as that has side-effects on import which break structured logging\nimport path from \"path\"\nimport http from \"http\"\nimport https from \"https\"\nimport tmp from \"tmp\"\nimport { ChildProcess } from \"child_process\"\nimport execa from \"execa\"\nimport chokidar from \"chokidar\"\nimport getRandomPort from \"detect-port\"\nimport { detectPortInUseAndPrompt } from \"../utils/detect-port-in-use-and-prompt\"\nimport { Server as SocketIO } from \"socket.io\"\nimport fs from \"fs-extra\"\nimport onExit from \"signal-exit\"\nimport {\n isCI,\n slash,\n createServiceLock,\n getService,\n updateSiteMetadata,\n UnlockFn,\n} from \"gatsby-core-utils\"\nimport reporter from \"gatsby-cli/lib/reporter\"\nimport { getSslCert } from \"../utils/get-ssl-cert\"\nimport { startDevelopProxy } from \"../utils/develop-proxy\"\nimport { IProgram, IDebugInfo } from \"./types\"\n\n// Adapted from https://stackoverflow.com/a/16060619\nconst requireUncached = (file: string): any => {\n try {\n delete require.cache[require.resolve(file)]\n } catch (e) {\n return null\n }\n\n try {\n return require(file)\n } catch (e) {\n return null\n }\n}\n\n// Heuristics for gatsby-config.js, as not all changes to it require a full restart to take effect\nconst doesConfigChangeRequireRestart = (\n lastConfig: Record<string, any>,\n newConfig: Record<string, any>\n): boolean => {\n // Ignore changes to siteMetadata\n const replacer = (_, v): string | void => {\n if (typeof v === `function` || v instanceof RegExp) {\n return v.toString()\n } else {\n return v\n }\n }\n\n const oldConfigString = JSON.stringify(\n { ...lastConfig, siteMetadata: null },\n replacer\n )\n const newConfigString = JSON.stringify(\n { ...newConfig, siteMetadata: null },\n replacer\n )\n\n if (oldConfigString === newConfigString) return false\n\n return true\n}\n\n// Return a user-supplied port otherwise the default Node.js debugging port\nconst getDebugPort = (port?: number): number => port ?? 9229\n\nexport const getDebugInfo = (program: IProgram): IDebugInfo | null => {\n if (program.hasOwnProperty(`inspect`)) {\n return {\n port: getDebugPort(program.inspect),\n break: false,\n }\n } else if (program.hasOwnProperty(`inspectBrk`)) {\n return {\n port: getDebugPort(program.inspectBrk),\n break: true,\n }\n } else {\n return null\n }\n}\n\nclass ControllableScript {\n private process?: ChildProcess\n private script\n private debugInfo: IDebugInfo | null\n public isRunning\n constructor(script, debugInfo: IDebugInfo | null) {\n this.script = script\n this.debugInfo = debugInfo\n }\n start(): void {\n const args = []\n const tmpFileName = tmp.tmpNameSync({\n tmpdir: path.join(process.cwd(), `.cache`),\n })\n fs.outputFileSync(tmpFileName, this.script)\n this.isRunning = true\n // Passing --inspect isn't necessary for the child process to launch a port but it allows some editors to automatically attach\n if (this.debugInfo) {\n if (this.debugInfo.break) {\n args.push(`--inspect-brk=${this.debugInfo.port}`)\n } else {\n args.push(`--inspect=${this.debugInfo.port}`)\n }\n }\n\n this.process = execa.node(tmpFileName, args, {\n env: process.env,\n stdio: [`inherit`, `inherit`, `inherit`, `ipc`],\n })\n }\n async stop(\n signal: NodeJS.Signals | null = null,\n code?: number\n ): Promise<void> {\n if (!this.process) {\n throw new Error(`Trying to stop the process before starting it`)\n }\n\n this.isRunning = false\n if (signal) {\n this.process.kill(signal)\n } else {\n this.process.send({\n type: `COMMAND`,\n action: {\n type: `EXIT`,\n payload: code,\n },\n })\n }\n\n return new Promise(resolve => {\n if (!this.process) {\n throw new Error(`Trying to stop the process before starting it`)\n }\n\n this.process.on(`exit`, () => {\n if (this.process) {\n this.process.removeAllListeners()\n }\n this.process = undefined\n resolve()\n })\n })\n }\n onMessage(callback: (msg: any) => void): void {\n if (!this.process) {\n throw new Error(`Trying to attach message handler before process started`)\n }\n this.process.on(`message`, callback)\n }\n onExit(\n callback: (code: number | null, signal: NodeJS.Signals | null) => void\n ): void {\n if (!this.process) {\n throw new Error(`Trying to attach exit handler before process started`)\n }\n this.process.on(`exit`, callback)\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n send(msg: any): void {\n if (!this.process) {\n throw new Error(`Trying to send a message before process started`)\n }\n\n this.process.send(msg)\n }\n}\n\nlet isRestarting\n\n// checks if a string is a valid ip\nconst REGEX_IP = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/\n\nmodule.exports = async (program: IProgram): Promise<void> => {\n // In some cases, port can actually be a string. But our codebase is expecting it to be a number.\n // So we want to early just force it to a number to ensure we always act on a correct type.\n program.port = parseInt(program.port + ``, 10)\n const developProcessPath = slash(require.resolve(`./develop-process`))\n const telemetryServerPath = slash(\n require.resolve(`../utils/telemetry-server`)\n )\n\n try {\n program.port = await detectPortInUseAndPrompt(program.port)\n } catch (e) {\n if (e.message === `USER_REJECTED`) {\n process.exit(0)\n }\n\n throw e\n }\n\n // Run the actual develop server on a random port, and the proxy on the program port\n // which users will access\n const proxyPort = program.port\n const debugInfo = getDebugInfo(program)\n\n const rootFile = (file: string): string => path.join(program.directory, file)\n\n // Require gatsby-config.js before accessing process.env, to enable the user to change\n // environment variables from the config file.\n let lastConfig = requireUncached(rootFile(`gatsby-config.js`))\n\n // INTERNAL_STATUS_PORT allows for setting the websocket port used for monitoring\n // when the browser should prompt the user to restart the develop process.\n // This port is randomized by default and in most cases should never be required to configure.\n // It is exposed for environments where port access needs to be explicit, such as with Docker.\n // As the port is meant for internal usage only, any attempt to interface with features\n // it exposes via third-party software is not supported.\n const [\n statusServerPort,\n developPort,\n telemetryServerPort,\n ] = await Promise.all([\n getRandomPort(process.env.INTERNAL_STATUS_PORT),\n getRandomPort(),\n getRandomPort(),\n ])\n\n // In order to enable custom ssl, --cert-file --key-file and -https flags must all be\n // used together\n if ((program[`cert-file`] || program[`key-file`]) && !program.https) {\n reporter.panic(\n `for custom ssl --https, --cert-file, and --key-file must be used together`\n )\n }\n\n // Check if https is enabled, then create or get SSL cert.\n // Certs are named 'devcert' and issued to the host.\n // NOTE(@mxstbr): We mutate program.ssl _after_ passing it\n // to the develop process controllable script above because\n // that would mean we double SSL browser => proxy => server\n if (program.https) {\n const sslHost =\n program.host === `0.0.0.0` || program.host === `::`\n ? `localhost`\n : program.host\n\n if (REGEX_IP.test(sslHost)) {\n reporter.panic(\n `You're trying to generate a ssl certificate for an IP (${sslHost}). Please use a hostname instead.`\n )\n }\n\n const ssl = await getSslCert({\n name: sslHost,\n caFile: program[`ca-file`],\n certFile: program[`cert-file`],\n keyFile: program[`key-file`],\n directory: program.directory,\n })\n\n if (ssl) {\n program.ssl = ssl\n }\n }\n\n // NOTE(@mxstbr): We need to start the develop proxy before the develop process to ensure\n // codesandbox detects the right port to expose by default\n const proxy = startDevelopProxy({\n proxyPort: proxyPort,\n targetPort: developPort,\n program,\n })\n\n const developProcess = new ControllableScript(\n `\n const cmd = require(${JSON.stringify(developProcessPath)});\n const args = ${JSON.stringify({\n ...program,\n port: developPort,\n proxyPort,\n // Don't pass SSL options down to the develop process, it should always use HTTP\n ssl: null,\n debugInfo,\n })};\n cmd(args);\n `,\n debugInfo\n )\n\n const telemetryServerProcess = new ControllableScript(\n `require(${JSON.stringify(telemetryServerPath)}).default(${JSON.stringify(\n telemetryServerPort\n )})`,\n null\n )\n\n let unlocks: Array<UnlockFn> = []\n if (!isCI()) {\n const statusUnlock = await createServiceLock(\n program.directory,\n `developstatusserver`,\n {\n port: statusServerPort,\n }\n )\n const developUnlock = await createServiceLock(\n program.directory,\n `developproxy`,\n {\n port: proxyPort,\n }\n )\n const telemetryUnlock = await createServiceLock(\n program.directory,\n `telemetryserver`,\n {\n port: telemetryServerPort,\n }\n )\n await updateSiteMetadata({\n name: program.sitePackageJson.name,\n sitePath: program.directory,\n pid: process.pid,\n lastRun: Date.now(),\n })\n\n if (!statusUnlock || !developUnlock) {\n const data = await getService(program.directory, `developproxy`)\n const port = data?.port || 8000\n console.error(\n `Looks like develop for this site is already running, can you visit ${\n program.ssl ? `https:` : `http:`\n }//localhost:${port} ? If it is not, try again in five seconds!`\n )\n process.exit(1)\n }\n\n unlocks = unlocks.concat([statusUnlock, developUnlock, telemetryUnlock])\n }\n\n const statusServer = program.ssl\n ? https.createServer(program.ssl)\n : http.createServer()\n statusServer.listen(statusServerPort)\n\n const io = new SocketIO(statusServer, {\n // whitelist all (https://github.com/expressjs/cors#configuration-options)\n cors: {\n origin: true,\n },\n cookie: true,\n })\n\n const handleChildProcessIPC = (msg): void => {\n if (msg.type === `HEARTBEAT`) return\n if (process.send) {\n // Forward IPC\n process.send(msg)\n }\n\n io.emit(`structured-log`, msg)\n\n if (\n msg.type === `LOG_ACTION` &&\n msg.action.type === `SET_STATUS` &&\n msg.action.payload === `SUCCESS`\n ) {\n proxy.serveSite()\n }\n }\n\n io.on(`connection`, socket => {\n socket.on(`develop:restart`, async respond => {\n isRestarting = true\n proxy.serveRestartingScreen()\n // respond() responds to the client, which in our case prompts it to reload the page to show the restarting screen\n if (respond) respond(`develop:is-starting`)\n await developProcess.stop()\n developProcess.start()\n developProcess.onMessage(handleChildProcessIPC)\n isRestarting = false\n })\n })\n\n developProcess.start()\n developProcess.onMessage(handleChildProcessIPC)\n\n telemetryServerProcess.start()\n\n // Plugins can call `process.exit` which would be sent to `develop-process` (child process)\n // This needs to be propagated back to the parent process\n developProcess.onExit(\n (code: number | null, signal: NodeJS.Signals | null) => {\n if (isRestarting) return\n if (signal !== null) {\n process.kill(process.pid, signal)\n return\n }\n if (code !== null) {\n process.exit(code)\n }\n\n // This should not happen:\n // https://nodejs.org/api/child_process.html#child_process_event_exit\n // The 'exit' event is emitted after the child process ends. If the process\n // exited, code is the final exit code of the process, otherwise null.\n // If the process terminated due to receipt of a signal, signal is the\n // string name of the signal, otherwise null. One of the two will always be\n // non - null.\n //\n // but just in case let do non-zero exit, because we are in situation\n // we don't expect to be possible\n process.exit(1)\n }\n )\n\n const files = [rootFile(`gatsby-config.js`), rootFile(`gatsby-node.js`)]\n let watcher: chokidar.FSWatcher = null\n\n if (!isCI()) {\n watcher = chokidar.watch(files).on(`change`, filePath => {\n const file = path.basename(filePath)\n\n if (file === `gatsby-config.js`) {\n const newConfig = requireUncached(rootFile(`gatsby-config.js`))\n\n if (!doesConfigChangeRequireRestart(lastConfig, newConfig)) {\n lastConfig = newConfig\n return\n }\n\n lastConfig = newConfig\n }\n\n console.warn(\n `develop process needs to be restarted to apply the changes to ${file}`\n )\n io.emit(`structured-log`, {\n type: `LOG_ACTION`,\n action: {\n type: `DEVELOP`,\n payload: `RESTART_REQUIRED`,\n dirtyFile: file,\n },\n })\n })\n }\n\n // route ipc messaging to the original develop process\n process.on(`message`, msg => {\n developProcess.send(msg)\n })\n\n process.on(`SIGINT`, async () => {\n await shutdownServices(\n {\n developProcess,\n telemetryServerProcess,\n unlocks,\n statusServer,\n proxy,\n watcher,\n },\n `SIGINT`\n )\n\n process.exit(0)\n })\n\n process.on(`SIGTERM`, async () => {\n await shutdownServices(\n {\n developProcess,\n telemetryServerProcess,\n unlocks,\n statusServer,\n proxy,\n watcher,\n },\n `SIGTERM`\n )\n\n process.exit(0)\n })\n\n onExit((_code, signal) => {\n shutdownServices(\n {\n developProcess,\n telemetryServerProcess,\n unlocks,\n statusServer,\n proxy,\n watcher,\n },\n signal as NodeJS.Signals\n )\n })\n}\nfunction shutdownServices(\n {\n statusServer,\n developProcess,\n proxy,\n unlocks,\n watcher,\n telemetryServerProcess,\n },\n signal: NodeJS.Signals\n): Promise<void> {\n const services = [\n developProcess.stop(signal),\n telemetryServerProcess.stop(),\n watcher?.close(),\n new Promise(resolve => statusServer.close(resolve)),\n new Promise(resolve => proxy.server.close(resolve)),\n ]\n\n unlocks.forEach(unlock => {\n services.push(unlock())\n })\n\n return Promise.all(services)\n .catch(() => {})\n .then(() => {})\n}\n"],"file":"develop.js"}
@@ -261,9 +261,7 @@ const developConfig = {
261
261
  // We need to run mutations immediately when in this state
262
262
  ADD_NODE_MUTATION: {
263
263
  actions: `callApi`
264
- },
265
- // Ignore, because we're about to extract them anyway
266
- SOURCE_FILE_CHANGED: undefined
264
+ }
267
265
  },
268
266
  invoke: {
269
267
  src: `reloadData`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state-machines/develop/index.ts"],"names":["RECOMPILE_PANIC_LIMIT","developConfig","id","initial","on","ADD_NODE_MUTATION","actions","SOURCE_FILE_CHANGED","WEBHOOK_RECEIVED","target","QUERY_RUN_REQUESTED","states","initializing","undefined","invoke","src","onDone","onError","initializingData","data","parentSpan","store","webhookBody","deferNodeMutation","runningPostBootstrap","runningQueries","program","gatsbyNodeGraphQLFunction","graphqlRunner","websocketManager","pendingQueryRuns","cond","nodesMutatedDuringQueryRun","nodesMutatedDuringQueryRunRecompileCount","compiler","sourceFilesDirty","recompiling","entry","startingDevServers","waiting","always","size","EXTRACT_QUERIES_NOW","nodeMutationBatch","runningBatch","reloadingData","webhookSourcePluginName","refresh","recreatingPages","developMachine","services","developServices","buildActions"],"mappings":";;;;;AAAA;;AAIA;;AACA;;AAGA,MAAMA,qBAAqB,GAAG,CAA9B;AAEA;AACA;AACA;;AACA,MAAMC,aAAgE,GAAG;AACvEC,EAAAA,EAAE,EAAG,OADkE;AAEvEC,EAAAA,OAAO,EAAG,cAF6D;AAGvE;AACA;AACAC,EAAAA,EAAE,EAAE;AACF;AACAC,IAAAA,iBAAiB,EAAE;AACjBC,MAAAA,OAAO,EAAG;AADO,KAFjB;AAKF;AACAC,IAAAA,mBAAmB,EAAE;AACnBD,MAAAA,OAAO,EAAG;AADS,KANnB;AASF;AACA;AACAE,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,MAAM,EAAG,eADO;AAEhBH,MAAAA,OAAO,EAAG;AAFM,KAXhB;AAeFI,IAAAA,mBAAmB,EAAE;AACnBJ,MAAAA,OAAO,EAAG;AADS;AAfnB,GALmE;AAwBvEK,EAAAA,MAAM,EAAE;AACN;AACAC,IAAAA,YAAY,EAAE;AACZR,MAAAA,EAAE,EAAE;AACF;AACAC,QAAAA,iBAAiB,EAAEQ,SAFjB;AAGFN,QAAAA,mBAAmB,EAAEM,SAHnB;AAIFL,QAAAA,gBAAgB,EAAEK;AAJhB,OADQ;AAOZC,MAAAA,MAAM,EAAE;AACNZ,QAAAA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,CAAzE;AAsUO,MAAMwC,cAAc,GAAG,qBAAQhD,aAAR,EAAuB;AACnDiD,EAAAA,QAAQ,EAAEC,yBADyC;AAEnD7C,EAAAA,OAAO,EAAE8C;AAF0C,CAAvB,CAAvB","sourcesContent":["import { MachineConfig, AnyEventObject, forwardTo, Machine } from \"xstate\"\nimport { IDataLayerContext } from \"../data-layer/types\"\nimport { IQueryRunningContext } from \"../query-running/types\"\nimport { IWaitingContext } from \"../waiting/types\"\nimport { buildActions } from \"./actions\"\nimport { developServices } from \"./services\"\nimport { IBuildContext } from \"../../services\"\n\nconst RECOMPILE_PANIC_LIMIT = 6\n\n/**\n * This is the top-level state machine for the `gatsby develop` command\n */\nconst developConfig: MachineConfig<IBuildContext, any, AnyEventObject> = {\n id: `build`,\n initial: `initializing`,\n // These are mutation events, sent to this machine by the mutation listener\n // in `services/listen-for-mutations.ts`\n on: {\n // These are deferred node mutations, mainly `createNode`\n ADD_NODE_MUTATION: {\n actions: `addNodeMutation`,\n },\n // Sent when webpack or chokidar sees a changed file\n SOURCE_FILE_CHANGED: {\n actions: `markSourceFilesDirty`,\n },\n // These are calls to the refresh endpoint. Also used by Gatsby Preview.\n // Saves the webhook body from the event into context, then reloads data\n WEBHOOK_RECEIVED: {\n target: `reloadingData`,\n actions: `assignWebhookBody`,\n },\n QUERY_RUN_REQUESTED: {\n actions: `trackRequestedQueryRun`,\n },\n },\n states: {\n // Here we handle the initial bootstrap\n initializing: {\n on: {\n // Ignore mutation events because we'll be running everything anyway\n ADD_NODE_MUTATION: undefined,\n SOURCE_FILE_CHANGED: undefined,\n WEBHOOK_RECEIVED: undefined,\n },\n invoke: {\n id: `initialize`,\n src: `initialize`,\n onDone: {\n target: `initializingData`,\n actions: [`assignStoreAndWorkerPool`, `spawnMutationListener`],\n },\n onError: {\n actions: `panic`,\n },\n },\n },\n // Sourcing nodes, customising and inferring schema, then running createPages\n initializingData: {\n on: {\n // We need to run mutations immediately when in this state\n ADD_NODE_MUTATION: {\n actions: `callApi`,\n },\n },\n invoke: {\n id: `initialize-data`,\n src: `initializeData`,\n data: ({\n parentSpan,\n store,\n webhookBody,\n }: IBuildContext): IDataLayerContext => {\n return {\n parentSpan,\n store,\n webhookBody,\n deferNodeMutation: true,\n }\n },\n onDone: {\n actions: [\n `assignServiceResult`,\n `clearWebhookBody`,\n `finishParentSpan`,\n ],\n target: `runningPostBootstrap`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n runningPostBootstrap: {\n invoke: {\n id: `post-bootstrap`,\n src: `postBootstrap`,\n onDone: `runningQueries`,\n },\n },\n // Running page and static queries and generating the SSRed HTML and page data\n runningQueries: {\n on: {\n SOURCE_FILE_CHANGED: {\n actions: [forwardTo(`run-queries`), `markSourceFilesDirty`],\n },\n ADD_NODE_MUTATION: {\n actions: [`markNodesDirty`, `callApi`],\n },\n QUERY_RUN_REQUESTED: {\n actions: forwardTo(`run-queries`),\n },\n },\n invoke: {\n id: `run-queries`,\n src: `runQueries`,\n // This is all the data that we're sending to the child machine\n data: ({\n program,\n store,\n parentSpan,\n gatsbyNodeGraphQLFunction,\n graphqlRunner,\n websocketManager,\n pendingQueryRuns,\n }: IBuildContext): IQueryRunningContext => {\n return {\n program,\n store,\n parentSpan,\n gatsbyNodeGraphQLFunction,\n graphqlRunner,\n websocketManager,\n pendingQueryRuns,\n }\n },\n onDone: [\n {\n // If we're at the recompile limit and nodes were mutated again then panic\n target: `waiting`,\n actions: `panicBecauseOfInfiniteLoop`,\n cond: ({\n nodesMutatedDuringQueryRun = false,\n nodesMutatedDuringQueryRunRecompileCount = 0,\n }: IBuildContext): boolean =>\n nodesMutatedDuringQueryRun &&\n nodesMutatedDuringQueryRunRecompileCount >= RECOMPILE_PANIC_LIMIT,\n },\n {\n // Nodes were mutated while querying, so we need to re-run everything\n target: `recreatingPages`,\n cond: ({ nodesMutatedDuringQueryRun }: IBuildContext): boolean =>\n !!nodesMutatedDuringQueryRun,\n actions: [\n `markNodesClean`,\n `incrementRecompileCount`,\n `clearPendingQueryRuns`,\n ],\n },\n {\n // If we have no compiler (i.e. it's first run), then spin up the\n // webpack and socket.io servers\n target: `startingDevServers`,\n actions: [`setQueryRunningFinished`, `clearPendingQueryRuns`],\n cond: ({ compiler }: IBuildContext): boolean => !compiler,\n },\n {\n // If source files have changed, then recompile the JS bundle\n target: `recompiling`,\n cond: ({ sourceFilesDirty }: IBuildContext): boolean =>\n !!sourceFilesDirty,\n actions: [`clearPendingQueryRuns`],\n },\n {\n // ...otherwise just wait.\n target: `waiting`,\n actions: [`clearPendingQueryRuns`],\n },\n ],\n onError: {\n actions: [`logError`, `clearPendingQueryRuns`],\n target: `waiting`,\n },\n },\n },\n // Recompile the JS bundle\n recompiling: {\n // Important: mark source files as clean when recompiling starts\n // Doing this `onDone` will wipe all file change events that occur **during** recompilation\n // See https://github.com/gatsbyjs/gatsby/issues/27609\n entry: `markSourceFilesClean`,\n invoke: {\n src: `recompile`,\n onDone: {\n target: `waiting`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n // Spin up webpack and socket.io\n startingDevServers: {\n invoke: {\n src: `startWebpackServer`,\n onDone: {\n target: `waiting`,\n actions: [\n `assignServers`,\n `spawnWebpackListener`,\n `markSourceFilesClean`,\n ],\n },\n onError: {\n actions: `panic`,\n target: `waiting`,\n },\n },\n },\n // Idle, waiting for events that make us rebuild\n waiting: {\n always: [\n {\n target: `runningQueries`,\n cond: ({ pendingQueryRuns }: IBuildContext): boolean =>\n !!pendingQueryRuns && pendingQueryRuns.size > 0,\n },\n ],\n entry: [`saveDbState`, `resetRecompileCount`],\n on: {\n // Forward these events to the child machine, so it can handle batching\n ADD_NODE_MUTATION: {\n actions: forwardTo(`waiting`),\n },\n SOURCE_FILE_CHANGED: {\n actions: [forwardTo(`waiting`), `markSourceFilesDirty`],\n },\n // This event is sent from the child\n EXTRACT_QUERIES_NOW: {\n target: `runningQueries`,\n },\n },\n invoke: {\n id: `waiting`,\n src: `waitForMutations`,\n // Send existing queued mutations to the child machine, which will execute them\n data: ({\n store,\n nodeMutationBatch = [],\n sourceFilesDirty,\n }: IBuildContext): IWaitingContext => {\n return {\n store,\n nodeMutationBatch,\n sourceFilesDirty,\n runningBatch: [],\n }\n },\n // \"done\" means we need to rebuild\n onDone: {\n actions: `assignServiceResult`,\n target: `recreatingPages`,\n },\n onError: {\n actions: `panic`,\n },\n },\n },\n // Almost the same as initializing data, but skips various first-run stuff\n reloadingData: {\n on: {\n // We need to run mutations immediately when in this state\n ADD_NODE_MUTATION: {\n actions: `callApi`,\n },\n // Ignore, because we're about to extract them anyway\n SOURCE_FILE_CHANGED: undefined,\n },\n invoke: {\n src: `reloadData`,\n data: ({\n parentSpan,\n store,\n webhookBody,\n webhookSourcePluginName,\n }: IBuildContext): IDataLayerContext => {\n return {\n parentSpan,\n store,\n webhookBody,\n webhookSourcePluginName,\n refresh: true,\n deferNodeMutation: true,\n }\n },\n onDone: {\n actions: [\n `assignServiceResult`,\n `clearWebhookBody`,\n `finishParentSpan`,\n ],\n target: `runningQueries`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n // Rebuild pages if a node has been mutated outside of sourceNodes\n recreatingPages: {\n on: {\n // We need to run mutations immediately when in this state\n ADD_NODE_MUTATION: {\n actions: `callApi`,\n },\n },\n invoke: {\n id: `recreate-pages`,\n src: `recreatePages`,\n data: ({ parentSpan, store }: IBuildContext): IDataLayerContext => {\n return { parentSpan, store, deferNodeMutation: true }\n },\n onDone: {\n actions: `assignServiceResult`,\n target: `runningQueries`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n },\n}\n\nexport const developMachine = Machine(developConfig, {\n services: developServices,\n actions: buildActions,\n})\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/state-machines/develop/index.ts"],"names":["RECOMPILE_PANIC_LIMIT","developConfig","id","initial","on","ADD_NODE_MUTATION","actions","SOURCE_FILE_CHANGED","WEBHOOK_RECEIVED","target","QUERY_RUN_REQUESTED","states","initializing","undefined","invoke","src","onDone","onError","initializingData","data","parentSpan","store","webhookBody","deferNodeMutation","runningPostBootstrap","runningQueries","program","gatsbyNodeGraphQLFunction","graphqlRunner","websocketManager","pendingQueryRuns","cond","nodesMutatedDuringQueryRun","nodesMutatedDuringQueryRunRecompileCount","compiler","sourceFilesDirty","recompiling","entry","startingDevServers","waiting","always","size","EXTRACT_QUERIES_NOW","nodeMutationBatch","runningBatch","reloadingData","webhookSourcePluginName","refresh","recreatingPages","developMachine","services","developServices","buildActions"],"mappings":";;;;;AAAA;;AAIA;;AACA;;AAGA,MAAMA,qBAAqB,GAAG,CAA9B;AAEA;AACA;AACA;;AACA,MAAMC,aAAgE,GAAG;AACvEC,EAAAA,EAAE,EAAG,OADkE;AAEvEC,EAAAA,OAAO,EAAG,cAF6D;AAGvE;AACA;AACAC,EAAAA,EAAE,EAAE;AACF;AACAC,IAAAA,iBAAiB,EAAE;AACjBC,MAAAA,OAAO,EAAG;AADO,KAFjB;AAKF;AACAC,IAAAA,mBAAmB,EAAE;AACnBD,MAAAA,OAAO,EAAG;AADS,KANnB;AASF;AACA;AACAE,IAAAA,gBAAgB,EAAE;AAChBC,MAAAA,MAAM,EAAG,eADO;AAEhBH,MAAAA,OAAO,EAAG;AAFM,KAXhB;AAeFI,IAAAA,mBAAmB,EAAE;AACnBJ,MAAAA,OAAO,EAAG;AADS;AAfnB,GALmE;AAwBvEK,EAAAA,MAAM,EAAE;AACN;AACAC,IAAAA,YAAY,EAAE;AACZR,MAAAA,EAAE,EAAE;AACF;AACAC,QAAAA,iBAAiB,EAAEQ,SAFjB;AAGFN,QAAAA,mBAAmB,EAAEM,SAHnB;AAIFL,QAAAA,gBAAgB,EAAEK;AAJhB,OADQ;AAOZC,MAAAA,MAAM,EAAE;AACNZ,QAAAA,EAAE,EAAG,YADC;AAENa,QAAAA,GAAG,EAAG,YAFA;AAGNC,QAAAA,MAAM,EAAE;AACNP,UAAAA,MAAM,EAAG,kBADH;A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vB","sourcesContent":["import { MachineConfig, AnyEventObject, forwardTo, Machine } from \"xstate\"\nimport { IDataLayerContext } from \"../data-layer/types\"\nimport { IQueryRunningContext } from \"../query-running/types\"\nimport { IWaitingContext } from \"../waiting/types\"\nimport { buildActions } from \"./actions\"\nimport { developServices } from \"./services\"\nimport { IBuildContext } from \"../../services\"\n\nconst RECOMPILE_PANIC_LIMIT = 6\n\n/**\n * This is the top-level state machine for the `gatsby develop` command\n */\nconst developConfig: MachineConfig<IBuildContext, any, AnyEventObject> = {\n id: `build`,\n initial: `initializing`,\n // These are mutation events, sent to this machine by the mutation listener\n // in `services/listen-for-mutations.ts`\n on: {\n // These are deferred node mutations, mainly `createNode`\n ADD_NODE_MUTATION: {\n actions: `addNodeMutation`,\n },\n // Sent when webpack or chokidar sees a changed file\n SOURCE_FILE_CHANGED: {\n actions: `markSourceFilesDirty`,\n },\n // These are calls to the refresh endpoint. Also used by Gatsby Preview.\n // Saves the webhook body from the event into context, then reloads data\n WEBHOOK_RECEIVED: {\n target: `reloadingData`,\n actions: `assignWebhookBody`,\n },\n QUERY_RUN_REQUESTED: {\n actions: `trackRequestedQueryRun`,\n },\n },\n states: {\n // Here we handle the initial bootstrap\n initializing: {\n on: {\n // Ignore mutation events because we'll be running everything anyway\n ADD_NODE_MUTATION: undefined,\n SOURCE_FILE_CHANGED: undefined,\n WEBHOOK_RECEIVED: undefined,\n },\n invoke: {\n id: `initialize`,\n src: `initialize`,\n onDone: {\n target: `initializingData`,\n actions: [`assignStoreAndWorkerPool`, `spawnMutationListener`],\n },\n onError: {\n actions: `panic`,\n },\n },\n },\n // Sourcing nodes, customising and inferring schema, then running createPages\n initializingData: {\n on: {\n // We need to run mutations immediately when in this state\n ADD_NODE_MUTATION: {\n actions: `callApi`,\n },\n },\n invoke: {\n id: `initialize-data`,\n src: `initializeData`,\n data: ({\n parentSpan,\n store,\n webhookBody,\n }: IBuildContext): IDataLayerContext => {\n return {\n parentSpan,\n store,\n webhookBody,\n deferNodeMutation: true,\n }\n },\n onDone: {\n actions: [\n `assignServiceResult`,\n `clearWebhookBody`,\n `finishParentSpan`,\n ],\n target: `runningPostBootstrap`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n runningPostBootstrap: {\n invoke: {\n id: `post-bootstrap`,\n src: `postBootstrap`,\n onDone: `runningQueries`,\n },\n },\n // Running page and static queries and generating the SSRed HTML and page data\n runningQueries: {\n on: {\n SOURCE_FILE_CHANGED: {\n actions: [forwardTo(`run-queries`), `markSourceFilesDirty`],\n },\n ADD_NODE_MUTATION: {\n actions: [`markNodesDirty`, `callApi`],\n },\n QUERY_RUN_REQUESTED: {\n actions: forwardTo(`run-queries`),\n },\n },\n invoke: {\n id: `run-queries`,\n src: `runQueries`,\n // This is all the data that we're sending to the child machine\n data: ({\n program,\n store,\n parentSpan,\n gatsbyNodeGraphQLFunction,\n graphqlRunner,\n websocketManager,\n pendingQueryRuns,\n }: IBuildContext): IQueryRunningContext => {\n return {\n program,\n store,\n parentSpan,\n gatsbyNodeGraphQLFunction,\n graphqlRunner,\n websocketManager,\n pendingQueryRuns,\n }\n },\n onDone: [\n {\n // If we're at the recompile limit and nodes were mutated again then panic\n target: `waiting`,\n actions: `panicBecauseOfInfiniteLoop`,\n cond: ({\n nodesMutatedDuringQueryRun = false,\n nodesMutatedDuringQueryRunRecompileCount = 0,\n }: IBuildContext): boolean =>\n nodesMutatedDuringQueryRun &&\n nodesMutatedDuringQueryRunRecompileCount >= RECOMPILE_PANIC_LIMIT,\n },\n {\n // Nodes were mutated while querying, so we need to re-run everything\n target: `recreatingPages`,\n cond: ({ nodesMutatedDuringQueryRun }: IBuildContext): boolean =>\n !!nodesMutatedDuringQueryRun,\n actions: [\n `markNodesClean`,\n `incrementRecompileCount`,\n `clearPendingQueryRuns`,\n ],\n },\n {\n // If we have no compiler (i.e. it's first run), then spin up the\n // webpack and socket.io servers\n target: `startingDevServers`,\n actions: [`setQueryRunningFinished`, `clearPendingQueryRuns`],\n cond: ({ compiler }: IBuildContext): boolean => !compiler,\n },\n {\n // If source files have changed, then recompile the JS bundle\n target: `recompiling`,\n cond: ({ sourceFilesDirty }: IBuildContext): boolean =>\n !!sourceFilesDirty,\n actions: [`clearPendingQueryRuns`],\n },\n {\n // ...otherwise just wait.\n target: `waiting`,\n actions: [`clearPendingQueryRuns`],\n },\n ],\n onError: {\n actions: [`logError`, `clearPendingQueryRuns`],\n target: `waiting`,\n },\n },\n },\n // Recompile the JS bundle\n recompiling: {\n // Important: mark source files as clean when recompiling starts\n // Doing this `onDone` will wipe all file change events that occur **during** recompilation\n // See https://github.com/gatsbyjs/gatsby/issues/27609\n entry: `markSourceFilesClean`,\n invoke: {\n src: `recompile`,\n onDone: {\n target: `waiting`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n // Spin up webpack and socket.io\n startingDevServers: {\n invoke: {\n src: `startWebpackServer`,\n onDone: {\n target: `waiting`,\n actions: [\n `assignServers`,\n `spawnWebpackListener`,\n `markSourceFilesClean`,\n ],\n },\n onError: {\n actions: `panic`,\n target: `waiting`,\n },\n },\n },\n // Idle, waiting for events that make us rebuild\n waiting: {\n always: [\n {\n target: `runningQueries`,\n cond: ({ pendingQueryRuns }: IBuildContext): boolean =>\n !!pendingQueryRuns && pendingQueryRuns.size > 0,\n },\n ],\n entry: [`saveDbState`, `resetRecompileCount`],\n on: {\n // Forward these events to the child machine, so it can handle batching\n ADD_NODE_MUTATION: {\n actions: forwardTo(`waiting`),\n },\n SOURCE_FILE_CHANGED: {\n actions: [forwardTo(`waiting`), `markSourceFilesDirty`],\n },\n // This event is sent from the child\n EXTRACT_QUERIES_NOW: {\n target: `runningQueries`,\n },\n },\n invoke: {\n id: `waiting`,\n src: `waitForMutations`,\n // Send existing queued mutations to the child machine, which will execute them\n data: ({\n store,\n nodeMutationBatch = [],\n sourceFilesDirty,\n }: IBuildContext): IWaitingContext => {\n return {\n store,\n nodeMutationBatch,\n sourceFilesDirty,\n runningBatch: [],\n }\n },\n // \"done\" means we need to rebuild\n onDone: {\n actions: `assignServiceResult`,\n target: `recreatingPages`,\n },\n onError: {\n actions: `panic`,\n },\n },\n },\n // Almost the same as initializing data, but skips various first-run stuff\n reloadingData: {\n on: {\n // We need to run mutations immediately when in this state\n ADD_NODE_MUTATION: {\n actions: `callApi`,\n },\n },\n invoke: {\n src: `reloadData`,\n data: ({\n parentSpan,\n store,\n webhookBody,\n webhookSourcePluginName,\n }: IBuildContext): IDataLayerContext => {\n return {\n parentSpan,\n store,\n webhookBody,\n webhookSourcePluginName,\n refresh: true,\n deferNodeMutation: true,\n }\n },\n onDone: {\n actions: [\n `assignServiceResult`,\n `clearWebhookBody`,\n `finishParentSpan`,\n ],\n target: `runningQueries`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n // Rebuild pages if a node has been mutated outside of sourceNodes\n recreatingPages: {\n on: {\n // We need to run mutations immediately when in this state\n ADD_NODE_MUTATION: {\n actions: `callApi`,\n },\n },\n invoke: {\n id: `recreate-pages`,\n src: `recreatePages`,\n data: ({ parentSpan, store }: IBuildContext): IDataLayerContext => {\n return { parentSpan, store, deferNodeMutation: true }\n },\n onDone: {\n actions: `assignServiceResult`,\n target: `runningQueries`,\n },\n onError: {\n actions: `logError`,\n target: `waiting`,\n },\n },\n },\n },\n}\n\nexport const developMachine = Machine(developConfig, {\n services: developServices,\n actions: buildActions,\n})\n"],"file":"index.js"}
@@ -22,13 +22,13 @@ const route = ({
22
22
  }) => // Render an HTML page and serve it.
23
23
  app.get(`*`, async (req, res, next) => {
24
24
  (0, _gatsbyTelemetry.trackFeatureIsUsed)(`GATSBY_EXPERIMENTAL_DEV_SSR`);
25
- const pathObj = (0, _findPageByPath.findPageByPath)(store.getState(), req.path);
25
+ const pathObj = (0, _findPageByPath.findPageByPath)(store.getState(), decodeURI(req.path));
26
26
 
27
27
  if (!pathObj) {
28
28
  return next();
29
29
  }
30
30
 
31
- await (0, _developPreloadHeaders.appendPreloadHeaders)(req.path, res);
31
+ await (0, _developPreloadHeaders.appendPreloadHeaders)(pathObj.path, res);
32
32
 
33
33
  const htmlActivity = _reporter.default.phantomActivity(`building HTML for path`, {});
34
34
 
@@ -166,7 +166,7 @@ app.get(`*`, async (req, res, next) => {
166
166
  node.js, it errored.
167
167
  </p>
168
168
  <ul>
169
- <li><strong>URL path:</strong> <code>${req.path}</code></li>
169
+ <li><strong>URL path:</strong> <code>${pathObj.path}</code></li>
170
170
  <li><strong>File path:</strong> <code>${error.filename}</code></li>
171
171
  </ul>
172
172
  <h3>error</h3>