Skip to content

Commit

Permalink
Fix Routes.X is not a function when inside a monorepo
Browse files Browse the repository at this point in the history
(patch)
  • Loading branch information
Skn0tt authored May 17, 2021
1 parent 1034b01 commit 79ca87e
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ export function parseParametersFromRoute(
}
}

/**
* Will resolve the real node_modules root.
* We're not fooled by you, `yarn workspace`!
*/
function findNodeModulesRoot(src: string) {
const nodeModules = join(src, "node_modules")
const includesBlitzPackage = fs.existsSync(join(nodeModules, "blitz"))
return includesBlitzPackage ? nodeModules : join(nodeModules, "../../../node_modules")
}

export const createStageRouteImportManifest: Stage & {overrideTriage: OverrideTriage} = ({
getRouteCache,
config,
Expand All @@ -156,7 +166,7 @@ export const createStageRouteImportManifest: Stage & {overrideTriage: OverrideTr

const routes: Record<string, Route> = {}

const dotBlitz = join(config.src, "node_modules", ".blitz")
const dotBlitz = join(findNodeModulesRoot(config.src), ".blitz")

const writeManifestImplementation = makeDebouncedWriter(join(dotBlitz, "index.js"))
const writeManifestBrowserImplementation = makeDebouncedWriter(join(dotBlitz, "index-browser.js"))
Expand Down

0 comments on commit 79ca87e

Please sign in to comment.