Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/gold-mirrors-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

TODO: add a proper changeset
20 changes: 18 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,29 @@ jobs:
strategy:
fail-fast: false
matrix:
script: ["prettier:check", "lint:check", "ts:check", "test"]
script: ["prettier:check", "lint:check", "ts:check"]
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/install-dependencies

- name: ${{ matrix.script }}
- name: run "${{ matrix.script }}" script
run: pnpm run ${{ matrix.script }}
tests:
name: tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, windows-2022, ubuntu-22.04]
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Dependencies
uses: ./.github/actions/install-dependencies

- name: run "test" script
run: pnpm run test
7 changes: 6 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ on:
jobs:
test:
timeout-minutes: 30
runs-on: ubuntu-latest
name: e2e tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, windows-2022, ubuntu-22.04]
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion examples/vercel-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"start": "next start",
"prettier": "prettier --write --ignore-unknown .",
"prettier:check": "prettier --check --ignore-unknown .",
"test": "pnpm prettier:check",
"tofix-build:worker": "opennextjs-cloudflare",
"tofix-dev:worker": "wrangler dev --port 8772",
"tofix-preview:worker": "pnpm build:worker && pnpm dev:worker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import path from "node:path";

import type { BuildOptions } from "@opennextjs/aws/build/helper.js";

import { normalizePath } from "../../utils/normalize-path.js";

/**
* Sets up the OpenNext cache handler in a Next.js build.
*
Expand All @@ -19,12 +21,12 @@ export async function patchCache(code: string, openNextOptions: BuildOptions): P
// TODO: switch to cache.mjs
const outputPath = path.join(outputDir, "server-functions", "default");
const packagePath = path.relative(monorepoRoot, appBuildOutputPath);
const cacheFile = path.join(outputPath, packagePath, "cache.cjs");
const cacheFilePath = path.join(outputPath, packagePath, "cache.cjs");

return code.replace(
"const { cacheHandler } = this.nextConfig;",
`const cacheHandler = null;
CacheHandler = require('${cacheFile}').default;
CacheHandler = require('${normalizePath(cacheFilePath)}').default;
`
);
}
22 changes: 22 additions & 0 deletions packages/cloudflare/src/cli/build/utils/normalize-path.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import path from "node:path";

import { describe, expect, it } from "vitest";

import { normalizePath } from "./normalize-path";

describe("normalizePath", () => {
it("should produce an absolute path ready to be embedded in inlined code", () => {
const joined = path.join("/", "Users", "me", "projects", "cloudflare", "index.mjs");
const result = normalizePath(joined);
// Note: the result is the same both on linux/mac and windows
expect(result).toEqual("/Users/me/projects/cloudflare/index.mjs");
});

it("should produce a relative path ready to be embedded in inlined code", () => {
const joined = path.join("..", "..", "tmp", "index.mjs");
const result = normalizePath(joined);

// Note: the result is the same both on linux/mac and windows
expect(result).toEqual("../../tmp/index.mjs");
});
});
Loading