Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f2154a

Browse files
wardpeetGatsbyJS Bot
authored and
GatsbyJS Bot
committed
fix(gatsby): add ./ prefix to paths in async-requires (gatsbyjs#20169)
* fix(gatsby): add ./ prefix to paths in async-requires * add test to e2e-tests
1 parent 2e27d97 commit 4f2154a

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

e2e-tests/production-runtime/cypress/integration/1-production.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ describe(`Production build tests`, () => {
9898
cy.getTestElement(`process.env.NOT_EXISTING_VAR`).should(`be.empty`)
9999
})
100100

101+
it(`should be able to create a page from component located in .cache directory`, () => {
102+
cy.visit(`/page-from-cache/`).waitForRouteChange()
103+
104+
// `bar` is set in gatsby-node createPages
105+
cy.getTestElement(`dom-marker`).contains(`[static-page-from-cache]`)
106+
})
107+
101108
describe(`Supports unicode characters in urls`, () => {
102109
it(`Can navigate directly`, () => {
103110
cy.visit(`/안녕/`, {

e2e-tests/production-runtime/gatsby-node.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
const path = require(`path`)
2+
const fs = require(`fs-extra`)
3+
4+
exports.onPreBootstrap = () => {
5+
fs.copyFileSync(
6+
`./src/templates/static-page-from-cache.js`,
7+
`./.cache/static-page-from-cache.js`
8+
)
9+
}
210

311
exports.createPages = ({ actions: { createPage } }) => {
412
createPage({
@@ -83,6 +91,11 @@ exports.createPages = ({ actions: { createPage } }) => {
8391
domMarker: `dynamic-and-wildcard`,
8492
},
8593
})
94+
95+
createPage({
96+
path: `/page-from-cache/`,
97+
component: path.resolve(`./.cache/static-page-from-cache.js`),
98+
})
8699
}
87100

88101
exports.onCreatePage = ({ page, actions }) => {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react'
2+
3+
const StaticPage = () => (
4+
<pre data-testid="dom-marker">[static-page-from-cache] static-sibling</pre>
5+
)
6+
7+
export default StaticPage

packages/gatsby/src/bootstrap/requires-writer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const preferDefault = m => m && m.default || m
173173
)
174174
175175
return ` "${c.componentChunkName}": () => import("${slash(
176-
relativeComponentPath
176+
`./${relativeComponentPath}`
177177
)}" /* webpackChunkName: "${c.componentChunkName}" */)`
178178
})
179179
.join(`,\n`)}

0 commit comments

Comments
 (0)