@bascik/adapter-cloudflare 1.0.0-rc.10 → 1.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -4
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -24,13 +24,21 @@ See it live: [cloudflare-adapter.bascik.dev](https://cloudflare-adapter.bascik.d
|
|
|
24
24
|
|
|
25
25
|
## Quickstart
|
|
26
26
|
|
|
27
|
+
Develop in Cloudflare's local runtime (workerd), with source watching and browser live reload:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
bascik --target cloudflare
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Open `http://127.0.0.1:8787`; use `--port` and `--host` to override the public address. Bascik runs full production adapter builds, starts Wrangler, and proxies the runtime over local HTTP. Source edits rebuild the bundle and reload connected browsers. Requests can receive 503 while rebuilding or after a failed build; the watcher stays alive and retries after the next edit. The proxy is HTTP only, regardless of the Node server's TLS configuration. Live reload is injected by the local proxy, never written into production artifacts. Bare `bascik` remains the Node development server.
|
|
34
|
+
|
|
27
35
|
Build for Cloudflare Workers with Static Assets:
|
|
28
36
|
|
|
29
37
|
```sh
|
|
30
38
|
bascik --build --target cloudflare
|
|
31
39
|
```
|
|
32
40
|
|
|
33
|
-
Preview locally with Wrangler from the emitted target directory:
|
|
41
|
+
Preview a production build locally with Wrangler from the emitted target directory (without Bascik's source watcher or live reload):
|
|
34
42
|
|
|
35
43
|
```sh
|
|
36
44
|
cd dist/.bascik/cloudflare
|
|
@@ -67,12 +75,15 @@ From the repo root:
|
|
|
67
75
|
|
|
68
76
|
```sh
|
|
69
77
|
yarn adapter:cf:demo:build # build pkg, the adapter, then the fixture with --target cloudflare
|
|
70
|
-
yarn adapter:cf:demo:dev #
|
|
78
|
+
yarn adapter:cf:demo:dev # watched adapter dev in local workerd on port 8787
|
|
71
79
|
yarn adapter:cf:demo:preview # build, then wrangler preview (a Preview named after the git branch)
|
|
72
80
|
yarn adapter:cf:demo:deploy # build, then wrangler deploy to production
|
|
73
81
|
```
|
|
74
82
|
|
|
75
|
-
The workspace
|
|
83
|
+
The workspace script `demo:dev` runs `bascik --target cloudflare` from the fixture root. `demo:build`, `demo:preview`, and `demo:deploy` remain separate production steps for CI.
|
|
84
|
+
|
|
85
|
+
Watched development launches Wrangler from the project root, pointing it at the generated Worker config or Pages public directory by absolute path. Its working directory stays valid even when another build replaces the generated output.
|
|
86
|
+
Local bindings persist under the project's `.wrangler/state/`, outside generated output, so source rebuilds do not delete KV, D1, R2, or Durable Object data.
|
|
76
87
|
|
|
77
88
|
## Development
|
|
78
89
|
|
|
@@ -84,8 +95,20 @@ yarn adapter:cf:typecheck # TypeScript type check
|
|
|
84
95
|
yarn adapter:cf:unit # unit tests
|
|
85
96
|
yarn adapter:cf:coverage # unit tests with coverage, written to test-coverage.json
|
|
86
97
|
yarn adapter:cf:e2e # build the fixture and run Playwright against it in local workerd
|
|
98
|
+
yarn adapter:cf:e2e:dev # real watched platform runtime and browser reload tests
|
|
87
99
|
```
|
|
88
100
|
|
|
89
|
-
The E2E
|
|
101
|
+
The E2E lanes use the built compiler and adapter, so run `yarn pkg:build && yarn adapter:cf:build` first. The watched lane runs `adapters/e2e/playwright.dev.config.ts` against the real Wrangler runtime; CI runs it separately from production acceptance. `yarn adapter:e2e:dev` runs both platforms after building both adapters.
|
|
102
|
+
|
|
103
|
+
Cloudflare and Netlify run the same [demo browser contract](../e2e/demo-contract.test.ts)
|
|
104
|
+
against their real runtimes. Both demos expose `/`, `/server?name=collin`,
|
|
105
|
+
`/stream`, `/stream-append`, `/mixed`, `/catalog`, `/catalog-stream`, `/api-demo`,
|
|
106
|
+
`/errors`, and `/static` with matching titles and navigation. The `/static`
|
|
107
|
+
page demonstrates scoped client scripts and independent counters; the overview
|
|
108
|
+
only links to the demos. The contract checks static
|
|
109
|
+
client scripts, escaped input, product rendering and filtering, API dispatch,
|
|
110
|
+
no-JavaScript stream ordering, and safe failures. Platform-specific context and
|
|
111
|
+
routing assertions remain in this adapter's own suite. Error-demo requests
|
|
112
|
+
intentionally generate diagnostics.
|
|
90
113
|
|
|
91
114
|
CI deploys the demo Worker after every other stage passes, and posts a preview URL on pull requests. [DEPLOYMENT.md](../../DEPLOYMENT.md) is the runbook.
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,42 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Default export of @bascik/adapter-cloudflare.
|
|
5
5
|
*/
|
|
6
|
-
import { defineAdapter } from "@bascik/bascik/adapter";
|
|
6
|
+
import { defineAdapter, resolvePlatformCli, availableDevPort, } from "@bascik/bascik/adapter";
|
|
7
7
|
import { build } from "./build.js";
|
|
8
|
+
import { join } from "node:path";
|
|
8
9
|
export { CLOUDFLARE_COMPATIBILITY_DATE, CLOUDFLARE_COMPATIBILITY_FLAGS, } from "./compat.js";
|
|
9
10
|
export { buildInvocationRoutes } from "./build.js";
|
|
10
11
|
export default defineAdapter({
|
|
11
12
|
name: "cloudflare",
|
|
12
13
|
build,
|
|
14
|
+
async dev({ projectRoot, outDir, variant, port }) {
|
|
15
|
+
const cli = await resolvePlatformCli(projectRoot, "wrangler", "wrangler");
|
|
16
|
+
const inspectorPort = await availableDevPort();
|
|
17
|
+
return {
|
|
18
|
+
command: process.execPath,
|
|
19
|
+
args: [
|
|
20
|
+
cli,
|
|
21
|
+
...(variant === "pages"
|
|
22
|
+
? [
|
|
23
|
+
"pages",
|
|
24
|
+
"dev",
|
|
25
|
+
join(outDir, "public"),
|
|
26
|
+
"--compatibility-flag",
|
|
27
|
+
"nodejs_compat",
|
|
28
|
+
]
|
|
29
|
+
: ["dev", "--config", join(outDir, "wrangler.jsonc")]),
|
|
30
|
+
"--ip",
|
|
31
|
+
"127.0.0.1",
|
|
32
|
+
"--port",
|
|
33
|
+
String(port),
|
|
34
|
+
"--inspector-port",
|
|
35
|
+
String(inspectorPort),
|
|
36
|
+
"--persist-to",
|
|
37
|
+
join(projectRoot, ".wrangler", "state"),
|
|
38
|
+
],
|
|
39
|
+
cwd: projectRoot,
|
|
40
|
+
env: { WRANGLER_SEND_METRICS: "false" },
|
|
41
|
+
};
|
|
42
|
+
},
|
|
13
43
|
});
|
|
14
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,eAAe,aAAa,CAAC;IAC3B,IAAI,EAAE,YAAY;IAClB,KAAK;IACL,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;QAC9C,MAAM,GAAG,GAAG,MAAM,kBAAkB,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAC1E,MAAM,aAAa,GAAG,MAAM,gBAAgB,EAAE,CAAC;QAC/C,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,QAAQ;YACzB,IAAI,EAAE;gBACJ,GAAG;gBACH,GAAG,CAAC,OAAO,KAAK,OAAO;oBACrB,CAAC,CAAC;wBACE,OAAO;wBACP,KAAK;wBACL,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC;wBACtB,sBAAsB;wBACtB,eAAe;qBAChB;oBACH,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;gBACxD,MAAM;gBACN,WAAW;gBACX,QAAQ;gBACR,MAAM,CAAC,IAAI,CAAC;gBACZ,kBAAkB;gBAClB,MAAM,CAAC,aAAa,CAAC;gBACrB,cAAc;gBACd,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC;aACxC;YACD,GAAG,EAAE,WAAW;YAChB,GAAG,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE;SACxC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bascik/adapter-cloudflare",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/bascikdev/bascik.git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"demo:build": "cd e2e/fixture && bascik --build --target cloudflare",
|
|
35
35
|
"demo:deploy": "cd e2e/fixture/dist/.bascik/cloudflare && wrangler deploy",
|
|
36
36
|
"demo:preview": "cd e2e/fixture/dist/.bascik/cloudflare && wrangler preview",
|
|
37
|
-
"demo:dev": "cd e2e/fixture
|
|
37
|
+
"demo:dev": "cd e2e/fixture && bascik --target cloudflare --port 8787"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"esbuild": "^0.28.2",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"smol-toml": "^1.9.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@bascik/bascik": "^1.0.0-rc.
|
|
45
|
+
"@bascik/bascik": "^1.0.0-rc.11"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@bascik/bascik": "^1.0.0-rc.
|
|
48
|
+
"@bascik/bascik": "^1.0.0-rc.11",
|
|
49
49
|
"@playwright/test": "^1.63.0",
|
|
50
50
|
"@types/node": "^24.19.1",
|
|
51
51
|
"@vitest/coverage-v8": "^5.0.3",
|