Skip to content

Commit

Permalink
refactor: join join arguments (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored Jan 23, 2025
1 parent e472c6b commit 6e58093
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { normalizePath } from "../../utils/index.js";
*/
export function inlineEvalManifest(code: string, config: Config): string {
const manifestJss = globSync(
normalizePath(join(config.paths.output.standaloneAppDotNext, "**", "*_client-reference-manifest.js"))
normalizePath(join(config.paths.output.standaloneAppDotNext, "**/*_client-reference-manifest.js"))
).map((file) =>
normalizePath(file).replace(normalizePath(config.paths.output.standaloneApp) + posix.sep, "")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function patchLoadManifest(code: string, config: Config): string {
// (source: https://github.com/vercel/next.js/blob/15aeb92e/packages/next/src/server/load-manifest.ts#L34-L56)
// Note: we could/should probably just patch readFileSync here or something!
const manifestJsons = globSync(
normalizePath(join(config.paths.output.standaloneAppDotNext, "**", "*-manifest.json"))
normalizePath(join(config.paths.output.standaloneAppDotNext, "**/*-manifest.json"))
).map((file) =>
normalizePath(file).replace(normalizePath(config.paths.output.standaloneApp) + posix.sep, "")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function patchWranglerDeps(config: Config) {
// [alias]
// # critters is `require`d from `pages.runtime.prod.js` when running wrangler dev, so we need to stub it out
// "critters" = "./.next/standalone/node_modules/cf/templates/shims/empty.ts"
const pagesRuntimeFile = join(distPath, "compiled", "next-server", "pages.runtime.prod.js");
const pagesRuntimeFile = join(distPath, "compiled/next-server/pages.runtime.prod.js");

const patchedPagesRuntime = readFileSync(pagesRuntimeFile, "utf-8").replace(
`e.exports=require("critters")`,
Expand All @@ -38,7 +38,7 @@ export function patchWranglerDeps(config: Config) {
// # try block here: https://github.com/vercel/next.js/blob/9e8266a7/packages/next/src/server/lib/trace/tracer.ts#L27-L31
// # causing the code to require the 'next/dist/compiled/@opentelemetry/api' module instead (which properly works)
// #"@opentelemetry/api" = "./.next/standalone/node_modules/cf/templates/shims/throw.ts"
const tracerFile = join(distPath, "server", "lib", "trace", "tracer.js");
const tracerFile = join(distPath, "server/lib/trace/tracer.js");

const patchedTracer = readFileSync(tracerFile, "utf-8").replaceAll(
/\w+\s*=\s*require\([^/]*opentelemetry.*\)/g,
Expand All @@ -63,7 +63,7 @@ export function patchWranglerDeps(config: Config) {
function getDistPath(config: Config): string {
for (const root of [config.paths.output.standaloneApp, config.paths.output.standaloneRoot]) {
try {
const distPath = join(root, "node_modules", "next", "dist");
const distPath = join(root, "node_modules/next/dist");
if (statSync(distPath).isDirectory()) return distPath;
} catch {
/* empty */
Expand Down Expand Up @@ -92,7 +92,7 @@ function patchRequireReactDomServerEdge(config: Config) {
const distPath = getDistPath(config);

// Patch .next/standalone/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js
const pagesRuntimeFile = join(distPath, "compiled", "next-server", "pages.runtime.prod.js");
const pagesRuntimeFile = join(distPath, "compiled/next-server/pages.runtime.prod.js");

const code = readFileSync(pagesRuntimeFile, "utf-8");
const file = tsParseFile(code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function createWranglerConfigIfNotExistent(projectOpts: ProjectOpti
return;
}

let wranglerConfig = readFileSync(join(getPackageTemplatesDirPath(), "defaults", "wrangler.json"), "utf8");
let wranglerConfig = readFileSync(join(getPackageTemplatesDirPath(), "defaults/wrangler.json"), "utf8");

const appName = getAppNameFromPackageJson(projectOpts.sourceDir) ?? "app-name";
if (appName) {
Expand Down Expand Up @@ -111,6 +111,6 @@ export async function createOpenNextConfigIfNotExistent(projectOpts: ProjectOpti
throw new Error("The `open-next.config.ts` file is required, aborting!");
}

cpSync(join(getPackageTemplatesDirPath(), "defaults", "open-next.config.ts"), openNextConfigPath);
cpSync(join(getPackageTemplatesDirPath(), "defaults/open-next.config.ts"), openNextConfigPath);
}
}
4 changes: 2 additions & 2 deletions packages/cloudflare/src/cli/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function getConfig(projectOpts: ProjectOptions): Config {

const nodeModules = join(standaloneApp, "node_modules");
const internalPackage = join(nodeModules, ...PACKAGE_NAME.split("/"));
const internalTemplates = join(internalPackage, "cli", "templates");
const internalTemplates = join(internalPackage, "cli/templates");

return {
build: {
Expand Down Expand Up @@ -141,7 +141,7 @@ function getNextjsApplicationPath(dotNextDir: string): string {

function findServerParentPath(parentPath: string): string | undefined {
try {
if (statSync(join(parentPath, ".next", "server")).isDirectory()) {
if (statSync(join(parentPath, ".next/server")).isDirectory()) {
return parentPath;
}
} catch {
Expand Down

0 comments on commit 6e58093

Please sign in to comment.