@torpor/adapter-cloudflare 0.0.13 → 0.0.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @torpor/adapter-cloudflare
2
2
 
3
+ ## 0.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e395c9e]
8
+ - @torpor/build@0.1.14
9
+
10
+ ## 0.0.14
11
+
12
+ ### Patch Changes
13
+
14
+ - 2272579: Feat: allow passing extra inputs to build
15
+
3
16
  ## 0.0.13
4
17
 
5
18
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -95,7 +95,7 @@ async function postbuild(site) {
95
95
  build: {
96
96
  outDir: cloudflareFolder,
97
97
  rollupOptions: {
98
- input: [workerFile],
98
+ input: [workerFile, ...site.inputs],
99
99
  output: {
100
100
  entryFileNames: `[name].js`,
101
101
  chunkFileNames: `[name].js`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/adapter.ts","../src/prepareTemplate.ts"],"sourcesContent":["import cloudflare from \"./adapter\";\n\nexport { cloudflare };\n","import { type Adapter, Site } from \"@torpor/build\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { build, defineConfig } from \"vite\";\nimport prepareTemplate from \"./prepareTemplate\";\n\nexport default {\n\tpostbuild,\n\tserve: (/* server: Server, site: Site*/) => {\n\t\tconsole.log(\"TODO\");\n\t},\n} satisfies Adapter as Adapter;\n\nasync function postbuild(site: Site): Promise<void> {\n\t// Build _worker.js as per\n\t// https://developers.cloudflare.com/pages/functions/advanced-mode/\n\n\tconst distFolder = path.resolve(site.root, \"dist\");\n\tconst clientFolder = path.join(distFolder, \"client\");\n\tconst serverFolder = path.join(distFolder, \"server\");\n\tconst tempFolder = path.join(distFolder, \"temp\");\n\tconst cloudflareFolder = path.join(distFolder, \"cloudflare\");\n\n\t// TODO: Is this going to be the correct path after installing from npm?\n\tconst buildSrcFolder = path.resolve(site.root, \"./node_modules/@torpor/build/src/\");\n\tconst adapterSrcFolder = path.resolve(\n\t\tsite.root,\n\t\t\"./node_modules/@torpor/adapter-cloudflare/src/\",\n\t);\n\n\t// Compile _worker.ts\n\tlet workerFile = path.join(adapterSrcFolder, \"_worker.ts\");\n\tlet workerSource = await fs.readFile(workerFile, \"utf-8\");\n\n\t// Find the client script file in /assets\n\tlet clientScript = (await fs.readdir(path.join(clientFolder, \"assets\"))).find((f) =>\n\t\tf.startsWith(\"clientEntry-\"),\n\t);\n\tif (!clientScript) {\n\t\tthrow new Error(\"clientEntry.js not found\");\n\t}\n\tclientScript = `/assets/${clientScript}`;\n\n\t// Read and prepare site.html so that we can just splice components into it\n\tlet siteHtml = path.join(clientFolder, \"site.html\");\n\tlet template = await fs.readFile(siteHtml, \"utf-8\");\n\ttemplate = prepareTemplate(template, clientScript);\n\n\tconst serverClass = path.join(buildSrcFolder, \"server\", \"Server.ts\");\n\tconst serverScript = path.join(serverFolder, \"serverEntry.js\");\n\n\t// Splice file names into _worker.ts\n\tworkerSource = workerSource\n\t\t.replace(\"%SERVER_CLASS%\", serverClass)\n\t\t.replace(\"%SERVER_SCRIPT%\", serverScript)\n\t\t.replace(\"%HTML_TEMPLATE%\", template);\n\n\tworkerFile = path.join(tempFolder, \"_worker.ts\");\n\tawait fs.mkdir(tempFolder);\n\tawait fs.writeFile(workerFile, workerSource);\n\n\tawait build(\n\t\tdefineConfig({\n\t\t\tbuild: {\n\t\t\t\toutDir: cloudflareFolder,\n\t\t\t\trollupOptions: {\n\t\t\t\t\tinput: [workerFile],\n\t\t\t\t\toutput: {\n\t\t\t\t\t\tentryFileNames: `[name].js`,\n\t\t\t\t\t\tchunkFileNames: `[name].js`,\n\t\t\t\t\t\tassetFileNames: `[name].[ext]`,\n\t\t\t\t\t},\n\t\t\t\t\tpreserveEntrySignatures: \"strict\",\n\t\t\t\t},\n\t\t\t\t// HACK: We don't need to minify as the worker isn't downloaded?\n\t\t\t\t// And it makes debugging easier\n\t\t\t\tminify: false,\n\t\t\t\t// HACK: Build for SSR so we don't get document and window references\n\t\t\t\tssr: true,\n\t\t\t},\n\t\t}),\n\t);\n\n\t// Copy the client assets into the Cloudflare folder\n\tawait fs.mkdir(path.join(cloudflareFolder, \"assets\"));\n\tfor (let file of await fs.readdir(path.join(clientFolder, \"assets\"))) {\n\t\tawait fs.copyFile(\n\t\t\tpath.join(clientFolder, \"assets\", file),\n\t\t\tpath.join(cloudflareFolder, \"assets\", file),\n\t\t);\n\t}\n\n\t// Build a wrangler.toml file for running with `wrangler dev`\n\tconst wranglerConfig = `\nname = \"torpor-miniflare\"\nmain = \"./cloudflare/_worker.js\"\ncompatibility_date = \"2025-01-01\"\n\n[assets]\ndirectory = \"./cloudflare\"\nbinding = \"ASSETS\"\n\t`;\n\tconst wranglerFile = path.join(distFolder, \"wrangler.toml\");\n\tawait fs.writeFile(wranglerFile, wranglerConfig);\n\n\tawait fs.rm(tempFolder, { recursive: true });\n}\n","export default function prepareTemplate(template: string, clientScript: string): string {\n\tlet contentStart = regexIndexOf(template, /\\<div\\s+id=(\"app\"|'app'|app)\\s+/);\n\tcontentStart = template.indexOf(\">\", contentStart) + 1;\n\tlet contentEnd = template.indexOf(\"</div>\", contentStart);\n\tif (contentStart === -1 || contentEnd === -1) {\n\t\tthrow new Error(`Couldn't find <div id=\"app\"></div>`);\n\t}\n\treturn (\n\t\ttemplate.substring(0, contentStart) +\n\t\t\"%COMPONENT_HTML%\" +\n\t\ttemplate.substring(contentEnd) +\n\t\t`<script type=\"module\" src=\"${clientScript}\"></script>`\n\t);\n}\n\n// From https://stackoverflow.com/a/274094\nfunction regexIndexOf(string: string, regex: RegExp, position?: number) {\n\tvar indexOf = string.substring(position || 0).search(regex);\n\treturn indexOf >= 0 ? indexOf + (position || 0) : indexOf;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,qBAA+B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BAAAA,QAAK,KAAK,kBAAkB,UAAU,IAAI;AAAA,IAC3C;AAAA,EACD;AAGA,QAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASvB,QAAM,eAAe,iBAAAA,QAAK,KAAK,YAAY,eAAe;AAC1D,QAAM,eAAAC,SAAG,UAAU,cAAc,cAAc;AAE/C,QAAM,eAAAA,SAAG,GAAG,YAAY,EAAE,WAAW,KAAK,CAAC;AAC5C;","names":["path","fs"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/adapter.ts","../src/prepareTemplate.ts"],"sourcesContent":["import cloudflare from \"./adapter\";\n\nexport { cloudflare };\n","import { type Adapter, Site } from \"@torpor/build\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { build, defineConfig } from \"vite\";\nimport prepareTemplate from \"./prepareTemplate\";\n\nexport default {\n\tpostbuild,\n\tserve: (/* server: Server, site: Site*/) => {\n\t\tconsole.log(\"TODO\");\n\t},\n} satisfies Adapter as Adapter;\n\nasync function postbuild(site: Site): Promise<void> {\n\t// Build _worker.js as per\n\t// https://developers.cloudflare.com/pages/functions/advanced-mode/\n\n\tconst distFolder = path.resolve(site.root, \"dist\");\n\tconst clientFolder = path.join(distFolder, \"client\");\n\tconst serverFolder = path.join(distFolder, \"server\");\n\tconst tempFolder = path.join(distFolder, \"temp\");\n\tconst cloudflareFolder = path.join(distFolder, \"cloudflare\");\n\n\t// TODO: Is this going to be the correct path after installing from npm?\n\tconst buildSrcFolder = path.resolve(site.root, \"./node_modules/@torpor/build/src/\");\n\tconst adapterSrcFolder = path.resolve(\n\t\tsite.root,\n\t\t\"./node_modules/@torpor/adapter-cloudflare/src/\",\n\t);\n\n\t// Compile _worker.ts\n\tlet workerFile = path.join(adapterSrcFolder, \"_worker.ts\");\n\tlet workerSource = await fs.readFile(workerFile, \"utf-8\");\n\n\t// Find the client script file in /assets\n\tlet clientScript = (await fs.readdir(path.join(clientFolder, \"assets\"))).find((f) =>\n\t\tf.startsWith(\"clientEntry-\"),\n\t);\n\tif (!clientScript) {\n\t\tthrow new Error(\"clientEntry.js not found\");\n\t}\n\tclientScript = `/assets/${clientScript}`;\n\n\t// Read and prepare site.html so that we can just splice components into it\n\tlet siteHtml = path.join(clientFolder, \"site.html\");\n\tlet template = await fs.readFile(siteHtml, \"utf-8\");\n\ttemplate = prepareTemplate(template, clientScript);\n\n\tconst serverClass = path.join(buildSrcFolder, \"server\", \"Server.ts\");\n\tconst serverScript = path.join(serverFolder, \"serverEntry.js\");\n\n\t// Splice file names into _worker.ts\n\tworkerSource = workerSource\n\t\t.replace(\"%SERVER_CLASS%\", serverClass)\n\t\t.replace(\"%SERVER_SCRIPT%\", serverScript)\n\t\t.replace(\"%HTML_TEMPLATE%\", template);\n\n\tworkerFile = path.join(tempFolder, \"_worker.ts\");\n\tawait fs.mkdir(tempFolder);\n\tawait fs.writeFile(workerFile, workerSource);\n\n\tawait build(\n\t\tdefineConfig({\n\t\t\tbuild: {\n\t\t\t\toutDir: cloudflareFolder,\n\t\t\t\trollupOptions: {\n\t\t\t\t\tinput: [workerFile, ...site.inputs],\n\t\t\t\t\toutput: {\n\t\t\t\t\t\tentryFileNames: `[name].js`,\n\t\t\t\t\t\tchunkFileNames: `[name].js`,\n\t\t\t\t\t\tassetFileNames: `[name].[ext]`,\n\t\t\t\t\t},\n\t\t\t\t\tpreserveEntrySignatures: \"strict\",\n\t\t\t\t},\n\t\t\t\t// HACK: We don't need to minify as the worker isn't downloaded?\n\t\t\t\t// And it makes debugging easier\n\t\t\t\tminify: false,\n\t\t\t\t// HACK: Build for SSR so we don't get document and window references\n\t\t\t\tssr: true,\n\t\t\t},\n\t\t}),\n\t);\n\n\t// Copy the client assets into the Cloudflare folder\n\tawait fs.mkdir(path.join(cloudflareFolder, \"assets\"));\n\tfor (let file of await fs.readdir(path.join(clientFolder, \"assets\"))) {\n\t\tawait fs.copyFile(\n\t\t\tpath.join(clientFolder, \"assets\", file),\n\t\t\tpath.join(cloudflareFolder, \"assets\", file),\n\t\t);\n\t}\n\n\t// Build a wrangler.toml file for running with `wrangler dev`\n\tconst wranglerConfig = `\nname = \"torpor-miniflare\"\nmain = \"./cloudflare/_worker.js\"\ncompatibility_date = \"2025-01-01\"\n\n[assets]\ndirectory = \"./cloudflare\"\nbinding = \"ASSETS\"\n\t`;\n\tconst wranglerFile = path.join(distFolder, \"wrangler.toml\");\n\tawait fs.writeFile(wranglerFile, wranglerConfig);\n\n\tawait fs.rm(tempFolder, { recursive: true });\n}\n","export default function prepareTemplate(template: string, clientScript: string): string {\n\tlet contentStart = regexIndexOf(template, /\\<div\\s+id=(\"app\"|'app'|app)\\s+/);\n\tcontentStart = template.indexOf(\">\", contentStart) + 1;\n\tlet contentEnd = template.indexOf(\"</div>\", contentStart);\n\tif (contentStart === -1 || contentEnd === -1) {\n\t\tthrow new Error(`Couldn't find <div id=\"app\"></div>`);\n\t}\n\treturn (\n\t\ttemplate.substring(0, contentStart) +\n\t\t\"%COMPONENT_HTML%\" +\n\t\ttemplate.substring(contentEnd) +\n\t\t`<script type=\"module\" src=\"${clientScript}\"></script>`\n\t);\n}\n\n// From https://stackoverflow.com/a/274094\nfunction regexIndexOf(string: string, regex: RegExp, position?: number) {\n\tvar indexOf = string.substring(position || 0).search(regex);\n\treturn indexOf >= 0 ? indexOf + (position || 0) : indexOf;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,qBAA+B;AAC/B,uBAAiB;AACjB,kBAAoC;;;ACHrB,SAAR,gBAAiC,UAAkB,cAA8B;AACvF,MAAI,eAAe,aAAa,UAAU,iCAAiC;AAC3E,iBAAe,SAAS,QAAQ,KAAK,YAAY,IAAI;AACrD,MAAI,aAAa,SAAS,QAAQ,UAAU,YAAY;AACxD,MAAI,iBAAiB,MAAM,eAAe,IAAI;AAC7C,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACrD;AACA,SACC,SA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W,KAAK,CAAC;AAC5C;","names":["path","fs"]}
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ async function postbuild(site) {
59
59
  build: {
60
60
  outDir: cloudflareFolder,
61
61
  rollupOptions: {
62
- input: [workerFile],
62
+ input: [workerFile, ...site.inputs],
63
63
  output: {
64
64
  entryFileNames: `[name].js`,
65
65
  chunkFileNames: `[name].js`,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/adapter.ts","../src/prepareTemplate.ts"],"sourcesContent":["import { type Adapter, Site } from \"@torpor/build\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { build, defineConfig } from \"vite\";\nimport prepareTemplate from \"./prepareTemplate\";\n\nexport default {\n\tpostbuild,\n\tserve: (/* server: Server, site: Site*/) => {\n\t\tconsole.log(\"TODO\");\n\t},\n} satisfies Adapter as Adapter;\n\nasync function postbuild(site: Site): Promise<void> {\n\t// Build _worker.js as per\n\t// https://developers.cloudflare.com/pages/functions/advanced-mode/\n\n\tconst distFolder = path.resolve(site.root, \"dist\");\n\tconst clientFolder = path.join(distFolder, \"client\");\n\tconst serverFolder = path.join(distFolder, \"server\");\n\tconst tempFolder = path.join(distFolder, \"temp\");\n\tconst cloudflareFolder = path.join(distFolder, \"cloudflare\");\n\n\t// TODO: Is this going to be the correct path after installing from npm?\n\tconst buildSrcFolder = path.resolve(site.root, \"./node_modules/@torpor/build/src/\");\n\tconst adapterSrcFolder = path.resolve(\n\t\tsite.root,\n\t\t\"./node_modules/@torpor/adapter-cloudflare/src/\",\n\t);\n\n\t// Compile _worker.ts\n\tlet workerFile = path.join(adapterSrcFolder, \"_worker.ts\");\n\tlet workerSource = await fs.readFile(workerFile, \"utf-8\");\n\n\t// Find the client script file in /assets\n\tlet clientScript = (await fs.readdir(path.join(clientFolder, \"assets\"))).find((f) =>\n\t\tf.startsWith(\"clientEntry-\"),\n\t);\n\tif (!clientScript) {\n\t\tthrow new Error(\"clientEntry.js not found\");\n\t}\n\tclientScript = `/assets/${clientScript}`;\n\n\t// Read and prepare site.html so that we can just splice components into it\n\tlet siteHtml = path.join(clientFolder, \"site.html\");\n\tlet template = await fs.readFile(siteHtml, \"utf-8\");\n\ttemplate = prepareTemplate(template, clientScript);\n\n\tconst serverClass = path.join(buildSrcFolder, \"server\", \"Server.ts\");\n\tconst serverScript = path.join(serverFolder, \"serverEntry.js\");\n\n\t// Splice file names into _worker.ts\n\tworkerSource = workerSource\n\t\t.replace(\"%SERVER_CLASS%\", serverClass)\n\t\t.replace(\"%SERVER_SCRIPT%\", serverScript)\n\t\t.replace(\"%HTML_TEMPLATE%\", template);\n\n\tworkerFile = path.join(tempFolder, \"_worker.ts\");\n\tawait fs.mkdir(tempFolder);\n\tawait fs.writeFile(workerFile, workerSource);\n\n\tawait build(\n\t\tdefineConfig({\n\t\t\tbuild: {\n\t\t\t\toutDir: cloudflareFolder,\n\t\t\t\trollupOptions: {\n\t\t\t\t\tinput: [workerFile],\n\t\t\t\t\toutput: {\n\t\t\t\t\t\tentryFileNames: `[name].js`,\n\t\t\t\t\t\tchunkFileNames: `[name].js`,\n\t\t\t\t\t\tassetFileNames: `[name].[ext]`,\n\t\t\t\t\t},\n\t\t\t\t\tpreserveEntrySignatures: \"strict\",\n\t\t\t\t},\n\t\t\t\t// HACK: We don't need to minify as the worker isn't downloaded?\n\t\t\t\t// And it makes debugging easier\n\t\t\t\tminify: false,\n\t\t\t\t// HACK: Build for SSR so we don't get document and window references\n\t\t\t\tssr: true,\n\t\t\t},\n\t\t}),\n\t);\n\n\t// Copy the client assets into the Cloudflare folder\n\tawait fs.mkdir(path.join(cloudflareFolder, \"assets\"));\n\tfor (let file of await fs.readdir(path.join(clientFolder, \"assets\"))) {\n\t\tawait fs.copyFile(\n\t\t\tpath.join(clientFolder, \"assets\", file),\n\t\t\tpath.join(cloudflareFolder, \"assets\", file),\n\t\t);\n\t}\n\n\t// Build a wrangler.toml file for running with `wrangler dev`\n\tconst wranglerConfig = `\nname = \"torpor-miniflare\"\nmain = \"./cloudflare/_worker.js\"\ncompatibility_date = \"2025-01-01\"\n\n[assets]\ndirectory = \"./cloudflare\"\nbinding = \"ASSETS\"\n\t`;\n\tconst wranglerFile = path.join(distFolder, \"wrangler.toml\");\n\tawait fs.writeFile(wranglerFile, wranglerConfig);\n\n\tawait fs.rm(tempFolder, { recursive: true });\n}\n","export default function prepareTemplate(template: string, clientScript: string): string {\n\tlet contentStart = regexIndexOf(template, /\\<div\\s+id=(\"app\"|'app'|app)\\s+/);\n\tcontentStart = template.indexOf(\">\", contentStart) + 1;\n\tlet contentEnd = template.indexOf(\"</div>\", contentStart);\n\tif (contentStart === -1 || contentEnd === -1) {\n\t\tthrow new Error(`Couldn't find <div id=\"app\"></div>`);\n\t}\n\treturn (\n\t\ttemplate.substring(0, contentStart) +\n\t\t\"%COMPONENT_HTML%\" +\n\t\ttemplate.substring(contentEnd) +\n\t\t`<script type=\"module\" src=\"${clientScript}\"></script>`\n\t);\n}\n\n// From https://stackoverflow.com/a/274094\nfunction regexIndexOf(string: string, regex: RegExp, position?: number) {\n\tvar indexOf = string.substring(position || 0).search(regex);\n\treturn indexOf >= 0 ? indexOf + (position || 0) : indexOf;\n}\n"],"mappings":";AACA,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AACjB,SAAS,OAAO,oBAAoB;;;ACHrB,SAAR,gBAAiC,UAAkB,cAA8B;AACvF,MAAI,eAAe,aAAa,UAAU,iCAAiC;AAC3E,iBAAe,SAAS,QAAQ,KAAK,YAAY,IAAI;AACrD,MAAI,aAAa,SAAS,QAAQ,UAAU,YAAY;AACxD,MAAI,iBAAiB,MAAM,eAAe,IAAI;AAC7C,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACrD;AACA,SACC,SAAS,UAAU,GAAG,YAAY,IAClC,qBACA,SAAS,UAAU,UAAU,IAC7B,8BAA8B,YAAY;AAE5C;AAGA,SAAS,aAAa,QAAgB,OAAe,UAAmB;AACvE,MAAI,UAAU,OAAO,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AAC/C,QAAM,GAAG,MAAM,UAAU;AACzB,QAAM,GAAG,UAAU,YAAY,YAAY;AAE3C,QAAM;AAAA,IACL,aAAa;AAAA,MACZ,OAAO;AAAA,QACN,QAAQ;AAAA,QACR,eAAe;AAAA,UACd,OAAO,CAAC,UAAU;AAAA,UAClB,QAAQ;AAAA,YACP,gBAAgB;AAAA,YAChB,gBAAgB;AAAA,YAChB,gBAAgB;AAAA,UACjB;AAAA,UACA,yBAAyB;AAAA,QAC1B;AAAA;AAAA;AAAA,QAGA,QAAQ;AAAA;AAAA,QAER,KAAK;AAAA,MACN;AAAA,IACD,CAAC;AAAA,EACF;AAGA,QAAM,GAAG,MAAM,KAAK,KAAK,kBAAkB,QAAQ,CAAC;AACpD,WAAS,QAAQ,MAAM,GAAG,QAAQ,KAAK,KAAK,cAAc,QAAQ,CAAC,GAAG;AACrE,UAAM,GAAG;AAAA,MACR,KAAK,KAAK,cAAc,UAAU,IAAI;AAAA,MACtC,KAAK,KAAK,kBAAkB,UAAU,IAAI;AAAA,IAC3C;AAAA,EACD;AAGA,QAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASvB,QAAM,eAAe,KAAK,KAAK,YAAY,eAAe;AAC1D,QAAM,GAAG,UAAU,cAAc,cAAc;AAE/C,QAAM,GAAG,GAAG,YAAY,EAAE,WAAW,KAAK,CAAC;AAC5C;","names":[]}
1
+ {"version":3,"sources":["../src/adapter.ts","../src/prepareTemplate.ts"],"sourcesContent":["import { type Adapter, Site } from \"@torpor/build\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { build, defineConfig } from \"vite\";\nimport prepareTemplate from \"./prepareTemplate\";\n\nexport default {\n\tpostbuild,\n\tserve: (/* server: Server, site: Site*/) => {\n\t\tconsole.log(\"TODO\");\n\t},\n} satisfies Adapter as Adapter;\n\nasync function postbuild(site: Site): Promise<void> {\n\t// Build _worker.js as per\n\t// https://developers.cloudflare.com/pages/functions/advanced-mode/\n\n\tconst distFolder = path.resolve(site.root, \"dist\");\n\tconst clientFolder = path.join(distFolder, \"client\");\n\tconst serverFolder = path.join(distFolder, \"server\");\n\tconst tempFolder = path.join(distFolder, \"temp\");\n\tconst cloudflareFolder = path.join(distFolder, \"cloudflare\");\n\n\t// TODO: Is this going to be the correct path after installing from npm?\n\tconst buildSrcFolder = path.resolve(site.root, \"./node_modules/@torpor/build/src/\");\n\tconst adapterSrcFolder = path.resolve(\n\t\tsite.root,\n\t\t\"./node_modules/@torpor/adapter-cloudflare/src/\",\n\t);\n\n\t// Compile _worker.ts\n\tlet workerFile = path.join(adapterSrcFolder, \"_worker.ts\");\n\tlet workerSource = await fs.readFile(workerFile, \"utf-8\");\n\n\t// Find the client script file in /assets\n\tlet clientScript = (await fs.readdir(path.join(clientFolder, \"assets\"))).find((f) =>\n\t\tf.startsWith(\"clientEntry-\"),\n\t);\n\tif (!clientScript) {\n\t\tthrow new Error(\"clientEntry.js not found\");\n\t}\n\tclientScript = `/assets/${clientScript}`;\n\n\t// Read and prepare site.html so that we can just splice components into it\n\tlet siteHtml = path.join(clientFolder, \"site.html\");\n\tlet template = await fs.readFile(siteHtml, \"utf-8\");\n\ttemplate = prepareTemplate(template, clientScript);\n\n\tconst serverClass = path.join(buildSrcFolder, \"server\", \"Server.ts\");\n\tconst serverScript = path.join(serverFolder, \"serverEntry.js\");\n\n\t// Splice file names into _worker.ts\n\tworkerSource = workerSource\n\t\t.replace(\"%SERVER_CLASS%\", serverClass)\n\t\t.replace(\"%SERVER_SCRIPT%\", serverScript)\n\t\t.replace(\"%HTML_TEMPLATE%\", template);\n\n\tworkerFile = path.join(tempFolder, \"_worker.ts\");\n\tawait fs.mkdir(tempFolder);\n\tawait fs.writeFile(workerFile, workerSource);\n\n\tawait build(\n\t\tdefineConfig({\n\t\t\tbuild: {\n\t\t\t\toutDir: cloudflareFolder,\n\t\t\t\trollupOptions: {\n\t\t\t\t\tinput: [workerFile, ...site.inputs],\n\t\t\t\t\toutput: {\n\t\t\t\t\t\tentryFileNames: `[name].js`,\n\t\t\t\t\t\tchunkFileNames: `[name].js`,\n\t\t\t\t\t\tassetFileNames: `[name].[ext]`,\n\t\t\t\t\t},\n\t\t\t\t\tpreserveEntrySignatures: \"strict\",\n\t\t\t\t},\n\t\t\t\t// HACK: We don't need to minify as the worker isn't downloaded?\n\t\t\t\t// And it makes debugging easier\n\t\t\t\tminify: false,\n\t\t\t\t// HACK: Build for SSR so we don't get document and window references\n\t\t\t\tssr: true,\n\t\t\t},\n\t\t}),\n\t);\n\n\t// Copy the client assets into the Cloudflare folder\n\tawait fs.mkdir(path.join(cloudflareFolder, \"assets\"));\n\tfor (let file of await fs.readdir(path.join(clientFolder, \"assets\"))) {\n\t\tawait fs.copyFile(\n\t\t\tpath.join(clientFolder, \"assets\", file),\n\t\t\tpath.join(cloudflareFolder, \"assets\", file),\n\t\t);\n\t}\n\n\t// Build a wrangler.toml file for running with `wrangler dev`\n\tconst wranglerConfig = `\nname = \"torpor-miniflare\"\nmain = \"./cloudflare/_worker.js\"\ncompatibility_date = \"2025-01-01\"\n\n[assets]\ndirectory = \"./cloudflare\"\nbinding = \"ASSETS\"\n\t`;\n\tconst wranglerFile = path.join(distFolder, \"wrangler.toml\");\n\tawait fs.writeFile(wranglerFile, wranglerConfig);\n\n\tawait fs.rm(tempFolder, { recursive: true });\n}\n","export default function prepareTemplate(template: string, clientScript: string): string {\n\tlet contentStart = regexIndexOf(template, /\\<div\\s+id=(\"app\"|'app'|app)\\s+/);\n\tcontentStart = template.indexOf(\">\", contentStart) + 1;\n\tlet contentEnd = template.indexOf(\"</div>\", contentStart);\n\tif (contentStart === -1 || contentEnd === -1) {\n\t\tthrow new Error(`Couldn't find <div id=\"app\"></div>`);\n\t}\n\treturn (\n\t\ttemplate.substring(0, contentStart) +\n\t\t\"%COMPONENT_HTML%\" +\n\t\ttemplate.substring(contentEnd) +\n\t\t`<script type=\"module\" src=\"${clientScript}\"></script>`\n\t);\n}\n\n// From https://stackoverflow.com/a/274094\nfunction regexIndexOf(string: string, regex: RegExp, position?: number) {\n\tvar indexOf = string.substring(position || 0).search(regex);\n\treturn indexOf >= 0 ? indexOf + (position || 0) : indexOf;\n}\n"],"mappings":";AACA,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AACjB,SAAS,OAAO,oBAAoB;;;ACHrB,SAAR,gBAAiC,UAAkB,cAA8B;AACvF,MAAI,eAAe,aAAa,UAAU,iCAAiC;AAC3E,iBAAe,SAAS,QAAQ,KAAK,YAAY,IAAI;AACrD,MAAI,aAAa,SAAS,QAAQ,UAAU,YAAY;AACxD,MAAI,iBAAiB,MAAM,eAAe,IAAI;AAC7C,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACrD;AACA,SACC,SAAS,UAAU,GAAG,YAAY,IAClC,qBACA,SAAS,UAAU,UAAU,IAC7B,8BAA8B,YAAY;AAE5C;AAGA,SAAS,aAAa,QAAgB,OAAe,UAAmB;AACvE,MAAI,UAAU,OAAO,UAAU,YAAY,CAAC,EAAE,OAAO,KAAK;AAC1D,SAAO,WAAW,IAAI,WAAW,YAAY,KAAK;AACnD;;;ADbA,IAAO,kBAAQ;AAAA,EACd;AAAA,EACA,OAAO,MAAqC;AAC3C,YAAQ,IAAI,MAAM;AAAA,EACnB;AACD;AAEA,eAAe,UAAU,MAA2B;AAInD,QAAM,aAAa,KAAK,QAAQ,KAAK,MAAM,MAAM;AACjD,QAAM,eAAe,KAAK,KAAK,YAAY,QAAQ;AACnD,QAAM,eAAe,KAAK,KAAK,YAAY,QAAQ;AACnD,QAAM,aAAa,KAAK,KAAK,YAAY,MAAM;AAC/C,QAAM,mBAAmB,KAAK,KAAK,YAAY,YAAY;AAG3D,QAAM,iBAAiB,KAAK,QAAQ,KAAK,MAAM,mCAAmC;AAClF,QAAM,mBAAmB,KAAK;AAAA,IAC7B,KAAK;AAAA,IACL;AAAA,EACD;AAGA,MAAI,aAAa,KAAK,KAAK,kBAAkB,YAAY;AACzD,MAAI,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tC,KAAK,KAAK,kBAAkB,UAAU,IAAI;AAAA,IAC3C;AAAA,EACD;AAGA,QAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASvB,QAAM,eAAe,KAAK,KAAK,YAAY,eAAe;AAC1D,QAAM,GAAG,UAAU,cAAc,cAAc;AAE/C,QAAM,GAAG,GAAG,YAAY,EAAE,WAAW,KAAK,CAAC;AAC5C;","names":[]}
@@ -1 +1 @@
1
- {"inputs":{"src/prepareTemplate.ts":{"bytes":809,"imports":[],"format":"esm"},"src/adapter.ts":{"bytes":3418,"imports":[{"path":"@torpor/build","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"src/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate"}],"format":"esm"},"src/index.ts":{"bytes":60,"imports":[{"path":"src/adapter.ts","kind":"import-statement","original":"./adapter"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7261},"dist/index.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":136},"src/adapter.ts":{"bytesInOutput":3490},"src/prepareTemplate.ts":{"bytesInOutput":698}},"bytes":5906}}}
1
+ {"inputs":{"src/prepareTemplate.ts":{"bytes":809,"imports":[],"format":"esm"},"src/adapter.ts":{"bytes":3434,"imports":[{"path":"@torpor/build","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"src/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate"}],"format":"esm"},"src/index.ts":{"bytes":60,"imports":[{"path":"src/adapter.ts","kind":"import-statement","original":"./adapter"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7292},"dist/index.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":136},"src/adapter.ts":{"bytesInOutput":3506},"src/prepareTemplate.ts":{"bytesInOutput":698}},"bytes":5922}}}
@@ -1 +1 @@
1
- {"inputs":{"src/prepareTemplate.ts":{"bytes":809,"imports":[],"format":"esm"},"src/adapter.ts":{"bytes":3418,"imports":[{"path":"@torpor/build","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"src/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate"}],"format":"esm"},"src/index.ts":{"bytes":60,"imports":[{"path":"src/adapter.ts","kind":"import-statement","original":"./adapter"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6939},"dist/index.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true}],"exports":["cloudflare"],"entryPoint":"src/index.ts","inputs":{"src/adapter.ts":{"bytesInOutput":2879},"src/prepareTemplate.ts":{"bytesInOutput":698},"src/index.ts":{"bytesInOutput":0}},"bytes":3685}}}
1
+ {"inputs":{"src/prepareTemplate.ts":{"bytes":809,"imports":[],"format":"esm"},"src/adapter.ts":{"bytes":3434,"imports":[{"path":"@torpor/build","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"src/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate"}],"format":"esm"},"src/index.ts":{"bytes":60,"imports":[{"path":"src/adapter.ts","kind":"import-statement","original":"./adapter"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6970},"dist/index.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true}],"exports":["cloudflare"],"entryPoint":"src/index.ts","inputs":{"src/adapter.ts":{"bytesInOutput":2895},"src/prepareTemplate.ts":{"bytesInOutput":698},"src/index.ts":{"bytesInOutput":0}},"bytes":3701}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torpor/adapter-cloudflare",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A @torpor/build adapter for deploying to Cloudflare Pages",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -18,20 +18,18 @@
18
18
  "author": "",
19
19
  "license": "ISC",
20
20
  "dependencies": {
21
- "vite": "^6.3.3",
22
- "@torpor/build": "^0.1.13"
21
+ "vite": "^6.3.5",
22
+ "@torpor/build": "^0.1.14"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@trivago/prettier-plugin-sort-imports": "^5.2.2",
26
26
  "tsup": "^8.4.0",
27
27
  "tsx": "^4.19.4",
28
- "typescript": "^5.8.3",
29
- "vitest": "^3.1.2"
28
+ "typescript": "^5.8.3"
30
29
  },
31
30
  "scripts": {
32
31
  "build": "tsc --noEmit && tsup",
33
32
  "build:watch": "tsup --watch",
34
- "check": "tsc --noEmit",
35
- "test": "vitest"
33
+ "check": "tsc --noEmit"
36
34
  }
37
35
  }
package/src/adapter.ts CHANGED
@@ -64,7 +64,7 @@ async function postbuild(site: Site): Promise<void> {
64
64
  build: {
65
65
  outDir: cloudflareFolder,
66
66
  rollupOptions: {
67
- input: [workerFile],
67
+ input: [workerFile, ...site.inputs],
68
68
  output: {
69
69
  entryFileNames: `[name].js`,
70
70
  chunkFileNames: `[name].js`,
package/vitest.config.ts DELETED
@@ -1,3 +0,0 @@
1
- import { type UserConfigFnObject, defineConfig } from "vitest/config";
2
-
3
- export default defineConfig(() => ({})) satisfies UserConfigFnObject as UserConfigFnObject;