File tree Expand file tree Collapse file tree 4 files changed +24
-29
lines changed
Expand file tree Collapse file tree 4 files changed +24
-29
lines changed Original file line number Diff line number Diff line change 1- import type { IncrementalCache } from "types/overrides.js" ;
2-
31import fs from "node:fs/promises" ;
42import path from "node:path" ;
53
4+ import type { IncrementalCache } from "types/overrides.js" ;
5+ import { getOutputDir } from "utils/normalize-path" ;
6+
67const buildId = process . env . NEXT_BUILD_ID ;
7- const basePath = path . join (
8- globalThis . monorepoPackagePath
9- . split ( "/" )
10- . filter ( Boolean )
11- . map ( ( ) => "../" )
12- . join ( "" ) ,
13- `../../cache/${ buildId } ` ,
14- ) ;
8+ const basePath = path . join ( getOutputDir ( ) , `../../cache/${ buildId } ` ) ;
159
1610const getCacheKey = ( key : string ) => {
1711 return path . join ( basePath , `${ key } .cache` ) ;
Original file line number Diff line number Diff line change 1- import type { TagCache } from "types/overrides" ;
2-
31import fs from "node:fs" ;
42import path from "node:path" ;
53
4+ import type { TagCache } from "types/overrides" ;
5+ import { getOutputDir } from "utils/normalize-path" ;
6+
67const tagFile = path . join (
7- globalThis . monorepoPackagePath
8- . split ( "/" )
9- . filter ( Boolean )
10- . map ( ( ) => "../" )
11- . join ( "" ) ,
8+ getOutputDir ( ) ,
129 "../../dynamodb-provider/dynamodb-cache.json" ,
1310) ;
1411const tagContent = fs . readFileSync ( tagFile , "utf-8" ) ;
Original file line number Diff line number Diff line change @@ -3,24 +3,16 @@ import express from "express";
33
44import type { StreamCreator } from "types/open-next.js" ;
55import type { WrapperHandler } from "types/overrides.js" ;
6-
7- const outputDir = path . join (
8- globalThis . monorepoPackagePath
9- . split ( "/" )
10- . filter ( Boolean )
11- . map ( ( ) => "../" )
12- . join ( "" ) ,
13- "../../" ,
14- ) ;
6+ import { getOutputDir } from "utils/normalize-path" ;
157
168const wrapper : WrapperHandler = async ( handler , converter ) => {
179 const app = express ( ) ;
1810 // To serve static assets
19- app . use ( express . static ( path . join ( outputDir , "assets" ) ) ) ;
11+ app . use ( express . static ( path . join ( getOutputDir ( ) , "../../ assets" ) ) ) ;
2012
2113 const imageHandlerPath = path . join (
22- outputDir ,
23- "image-optimization-function/index.mjs" ,
14+ getOutputDir ( ) ,
15+ "../../ image-optimization-function/index.mjs" ,
2416 ) ;
2517
2618 const imageHandler = await import ( imageHandlerPath ) . then ( ( m ) => m . handler ) ;
Original file line number Diff line number Diff line change 1+ import path from "node:path" ;
2+
13export function normalizePath ( path : string ) {
24 return path . replace ( / \\ / g, "/" ) ;
35}
6+
7+ export function getOutputDir ( ) {
8+ return path . join (
9+ globalThis . monorepoPackagePath
10+ . split ( "/" )
11+ . filter ( Boolean )
12+ . map ( ( ) => ".." )
13+ . join ( "/" ) ,
14+ ) ;
15+ }
You can’t perform that action at this time.
0 commit comments