@@ -2,6 +2,7 @@ import { logRaw, updateStatus } from "@cloudflare/cli";
22import { blue , brandColor , dim } from "@cloudflare/cli/colors" ;
33import { runFrameworkGenerator } from "frameworks/index" ;
44import { mergeObjectProperties , transformFile } from "helpers/codemod" ;
5+ import { getWorkerdCompatibilityDate } from "helpers/compatDate" ;
56import { usesTypescript } from "helpers/files" ;
67import { detectPackageManager } from "helpers/packageManagers" ;
78import { installPackages } from "helpers/packages" ;
@@ -30,6 +31,8 @@ const configure = async (ctx: C3Context) => {
3031 usesTypescript ( ctx ) ;
3132 const filePath = `app.config.${ usesTypescript ( ctx ) ? "ts" : "js" } ` ;
3233
34+ const compatDate = await getWorkerdCompatibilityDate ( ) ;
35+
3336 updateStatus ( `Updating configuration in ${ blue ( filePath ) } ` ) ;
3437
3538 transformFile ( filePath , {
@@ -46,60 +49,14 @@ const configure = async (ctx: C3Context) => {
4649 b . objectProperty (
4750 b . identifier ( "server" ) ,
4851 b . objectExpression ( [
49- // preset: "cloudflare-pages "
52+ // preset: "cloudflare_module "
5053 b . objectProperty (
5154 b . identifier ( "preset" ) ,
52- b . stringLiteral ( "cloudflare-pages" ) ,
53- ) ,
54- // output: {
55- // dir: "{{ rootDir }}/dist",
56- // publicDir: "{{ output.dir }}/public",
57- // serverDir: "{{ output.dir }}/worker",
58- // },
59- b . objectProperty (
60- b . identifier ( "output" ) ,
61- b . objectExpression ( [
62- b . objectProperty (
63- b . identifier ( "dir" ) ,
64- b . stringLiteral ( "{{ rootDir }}/dist" ) ,
65- ) ,
66- b . objectProperty (
67- b . identifier ( "publicDir" ) ,
68- b . stringLiteral ( "{{ output.dir }}/public" ) ,
69- ) ,
70- b . objectProperty (
71- b . identifier ( "serverDir" ) ,
72- b . stringLiteral ( "{{ output.dir }}/worker" ) ,
73- ) ,
74- ] ) ,
75- ) ,
76- // rollupConfig: {
77- // external: ["node:async_hooks"],
78- // },
79- b . objectProperty (
80- b . identifier ( "rollupConfig" ) ,
81- b . objectExpression ( [
82- b . objectProperty (
83- b . identifier ( "external" ) ,
84- b . arrayExpression ( [ b . stringLiteral ( "node:async_hooks" ) ] ) ,
85- ) ,
86- ] ) ,
55+ b . stringLiteral ( "cloudflare_module" ) ,
8756 ) ,
88- // hooks: {
89- // // Prevent the Pages preset from writing the _routes.json etc.
90- // compiled() {},
91- // },
9257 b . objectProperty (
93- b . identifier ( "hooks" ) ,
94- b . objectExpression ( [
95- b . objectMethod (
96- "method" ,
97- b . identifier ( "compiled" ) ,
98- [ ] ,
99- b . blockStatement ( [ ] ) ,
100- false ,
101- ) ,
102- ] ) ,
58+ b . identifier ( "compatibilityDate" ) ,
59+ b . stringLiteral ( compatDate ) ,
10360 ) ,
10461 ] ) ,
10562 ) ,
0 commit comments