Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): rename env var for lazy dev bundling to make consistent with other experiments #28150

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/gatsby/cache-dir/__tests__/dev-loader-lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ describe(`Dev loader`, () => {
global.__BASE_PATH__ = ``
global.__PATH_PREFIX__ = ``
process.env = Object.assign(process.env, {
GATSBY_EXPERIMENT_LAZY_DEVJS: true,
GATSBY_EXPERIMENTAL_LAZY_DEVJS: true,
})
})

afterEach(() => {
global.__BASE_PATH__ = originalBasePath
global.__PATH_PREFIX__ = originalPathPrefix
process.env = Object.assign(process.env, {
GATSBY_EXPERIMENT_LAZY_DEVJS: false,
GATSBY_EXPERIMENTAL_LAZY_DEVJS: false,
})
})

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import matchPaths from "$virtual/match-paths.json"
window.___emitter = emitter

let pageComponentRequires
if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
pageComponentRequires = require(`$virtual/lazy-client-sync-requires`)
} else {
pageComponentRequires = require(`$virtual/sync-requires`)
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/dev-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function mergePageEntry(cachedPage, newPageData) {
class DevLoader extends BaseLoader {
constructor(syncRequires, matchPaths) {
let loadComponent
if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
const ensureComponentInBundle = require(`./ensure-page-component-in-bundle`)
loadComponent = chunkName => ensureComponentInBundle.default(chunkName)
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/cache-dir/gatsby-browser-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const StaticQueryContext = React.createContext({})
function StaticQueryDataRenderer({ staticQueryData, data, query, render }) {
let combinedStaticQueryData = staticQueryData

if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
// when we remove the flag, we don't need to combine them
// w/ changes @pieh made.
combinedStaticQueryData = {
Expand Down Expand Up @@ -83,7 +83,7 @@ useStaticQuery(graphql\`${query}\`);
}

let queryNotFound = false
if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
// Merge data loaded via socket.io & xhr
// when we remove the flag, we don't need to combine them
// w/ changes @pieh made.
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class BaseLoader {
// In development, check if the page is in the bundle yet.
if (
process.env.NODE_ENV === `development` &&
process.env.GATSBY_EXPERIMENT_LAZY_DEVJS
process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS
) {
const ensureComponentInBundle = require(`./ensure-page-component-in-bundle`)
.default
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/src/bootstrap/requires-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const writeAll = async (state: IGatsbyState): Promise<boolean> => {

let cleanedClientVisitedPageComponents: Array<IGatsbyPageComponent> = components
let notVisitedPageComponents: Array<IGatsbyPageComponent> = components
if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
const clientVisitedPageComponents = [...state.clientVisitedPages.values()]
// Remove any page components that no longer exist.
cleanedClientVisitedPageComponents = components.filter(component =>
Expand Down Expand Up @@ -249,7 +249,7 @@ const preferDefault = m => (m && m.default) || m
// file so we need a seperate one for each webpack instance.
writeModule(`$virtual/ssr-sync-requires`, syncRequires)

if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
// Create file with sync requires of visited page components files.
let lazyClientSyncRequires = `${hotImport}
// prefer default export if available
Expand Down Expand Up @@ -331,7 +331,7 @@ const preferDefault = m => (m && m.default) || m
return true
}

if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
/**
* Start listening to CREATE_CLIENT_VISITED_PAGE events so we can rewrite
* files as required
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/src/utils/start-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function startServer(
let cancelDevJSNotice: CancelExperimentNoticeCallbackOrUndefined
if (
process.env.gatsby_executing_command === `develop` &&
!process.env.GATSBY_EXPERIMENT_DEVJS_LAZY &&
!process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS &&
!isCI()
) {
cancelDevJSNotice = showExperimentNoticeAfterTimeout(
Expand All @@ -139,7 +139,7 @@ Your friendly Gatsby maintainers detected your site takes longer than ideal to b

If you're interested in trialing out one of these future improvements *today* which should make your local development experience faster, go ahead and run your site with LAZY_DEVJS enabled.

GATSBY_EXPERIMENT_DEVJS_LAZY=true gatsby develop
GATSBY_EXPERIMENTAL_LAZY_DEVJS=true gatsby develop

Please do let us know how it goes (good, bad, or otherwise) at https://gatsby.dev/lazy-devjs-umbrella
`),
Expand All @@ -157,7 +157,7 @@ Please do let us know how it goes (good, bad, or otherwise) at https://gatsby.de

const compiler = webpack(devConfig)

if (process.env.GATSBY_EXPERIMENT_LAZY_DEVJS) {
if (process.env.GATSBY_EXPERIMENTAL_LAZY_DEVJS) {
const bodyParser = require(`body-parser`)
const { boundActionCreators } = require(`../redux/actions`)
const { createClientVisitedPage } = boundActionCreators
Expand Down