Skip to content

Commit 073a876

Browse files
committed
feat: support new monorepo setup
1 parent 112bb9f commit 073a876

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

demos/default/netlify.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[build]
2-
command = "next build"
3-
publish = ".next"
4-
ignore = "if [ $CACHED_COMMIT_REF == $COMMIT_REF ]; then (exit 1); else git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../..; fi;"
2+
command = "npm --workspace default-demo run build"
3+
publish = "/demos/default/.next"
54

5+
# ignore = "if [ $CACHED_COMMIT_REF == $COMMIT_REF ]; then (exit 1); else git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../..; fi;"
66
[build.environment]
77
# cache Cypress binary in local "node_modules" folder
88
# so Netlify caches it
99
CYPRESS_CACHE_FOLDER = "../node_modules/.CypressBinary"
1010
# set TERM variable for terminal output
11-
TERM = "xterm"
12-
NODE_VERSION = "16.15.1"
13-
NEXT_SPLIT_API_ROUTES = "true"
1411
NEXT_BUNDLE_BASED_ON_NFT_FILES = "true"
12+
NEXT_SPLIT_API_ROUTES = "true"
13+
NODE_VERSION = "16.15.1"
14+
TERM = "xterm"
1515

1616
[[headers]]
1717
for = "/_next/image/*"
@@ -28,4 +28,4 @@ package = "@netlify/plugin-nextjs"
2828
package = "@netlify/plugin-local-install-core"
2929

3030
[[plugins]]
31-
package = "../plugin-wrapper"
31+
package = "/demos/plugin-wrapper"

packages/runtime/src/helpers/functions.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const generateFunctions = async (
6464
ssrLambdas: SSRLambda[],
6565
): Promise<void> => {
6666
const publish = resolve(PUBLISH_DIR)
67-
const functionsDir = resolve(INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC)
67+
const functionsDir = resolve(appDir, INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC)
6868
const functionDir = join(functionsDir, HANDLER_FUNCTION_NAME)
6969
const publishDir = relative(functionDir, publish)
7070

@@ -173,13 +173,16 @@ export const generatePagesResolver = async ({
173173
INTERNAL_FUNCTIONS_SRC,
174174
FUNCTIONS_SRC = DEFAULT_FUNCTIONS_SRC,
175175
PUBLISH_DIR,
176+
// @ts-expect-error TODO: The types need to be updated:
177+
// https://github.com/netlify/build/blob/ad77b62e524381a5952535dacdda76b28f77cd43/packages/build/types/netlify_plugin_constants.d.ts#L1
178+
PACKAGE_PATH = '',
176179
}: NetlifyPluginConstants): Promise<void> => {
177180
const functionsPath = INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC
178181

179-
const jsSource = await getResolverForPages(PUBLISH_DIR)
182+
const jsSource = await getResolverForPages(PUBLISH_DIR, PACKAGE_PATH)
180183

181-
await writeFile(join(functionsPath, ODB_FUNCTION_NAME, 'pages.js'), jsSource)
182-
await writeFile(join(functionsPath, HANDLER_FUNCTION_NAME, 'pages.js'), jsSource)
184+
await writeFile(join(PACKAGE_PATH, functionsPath, ODB_FUNCTION_NAME, 'pages.js'), jsSource)
185+
await writeFile(join(PACKAGE_PATH, functionsPath, HANDLER_FUNCTION_NAME, 'pages.js'), jsSource)
183186
}
184187

185188
// Move our next/image function into the correct functions directory

packages/runtime/src/templates/getPageResolver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export const getResolverForDependencies = ({
4343
`
4444
}
4545

46-
export const getResolverForPages = async (publish: string) => {
47-
const functionDir = resolve('.netlify', 'functions', HANDLER_FUNCTION_NAME)
46+
export const getResolverForPages = async (publish: string, packagePath: string) => {
47+
const functionDir = resolve(packagePath, '.netlify', 'functions', HANDLER_FUNCTION_NAME)
4848
const dependencies = await getAllPageDependencies(publish)
4949
return getResolverForDependencies({ dependencies, functionDir })
5050
}

0 commit comments

Comments
 (0)