Skip to content

Commit

Permalink
fix: experimental Angular template using Workers with Assets was brok…
Browse files Browse the repository at this point in the history
…en (#6815)
  • Loading branch information
petebacondarwin authored Sep 24, 2024
1 parent 0792fa0 commit ffe8d10
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-shoes-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

fix: experimental Angular template using Workers with Assets was broken
16 changes: 6 additions & 10 deletions packages/create-cloudflare/templates-experimental/angular/c3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ const configure = async (ctx: C3Context) => {
};

async function installCFWorker() {
await installPackages(
["@cloudflare/workers-types", "@miniflare/tre@next", "wrangler@beta"],
{
dev: true,
startText: "Installing adapter dependencies",
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
},
);
await installPackages(["@cloudflare/workers-types", "wrangler"], {
dev: true,
startText: "Installing adapter dependencies",
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
});
}
async function updateAppCode() {
const s = spinner();
Expand Down Expand Up @@ -93,8 +90,7 @@ const config: TemplateConfig = {
scripts: {
start: `${npm} run build && wrangler dev`,
build: `ng build && ${npm} run process`,
process:
"node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
process: "node ./tools/alter-polyfills.mjs",
deploy: `${npm} run build && wrangler deploy`,
},
}),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import fs from "node:fs";
import { EOL } from "node:os";
import { join } from "node:path";
import { worker } from "./paths.mjs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const dirname = path.dirname(fileURLToPath(import.meta.url));

/**
* Split by lines and comment the banner
Expand All @@ -10,15 +12,18 @@ import { worker } from "./paths.mjs";
* globalThis['require'] ??= createRequire(import.meta.url);
* ```
*/
const serverPolyfillsFile = join(worker, "polyfills.server.mjs");
const serverPolyfillsFile = join(
dirname,
"../dist/server/polyfills.server.mjs"
);
const serverPolyfillsData = fs
.readFileSync(serverPolyfillsFile, "utf8")
.split(/\r?\n/);
.readFileSync(serverPolyfillsFile, "utf8")
.split(/\r?\n/);

for (let index = 0; index < 2; index++) {
if (serverPolyfillsData[index].includes("createRequire")) {
serverPolyfillsData[index] = "// " + serverPolyfillsData[index];
}
if (serverPolyfillsData[index].includes("createRequire")) {
serverPolyfillsData[index] = "// " + serverPolyfillsData[index];
}
}

// Add needed polyfills
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#:schema node_modules/wrangler/config-schema.json
name = "<TBD>"
compatibility_date = "<TBD>"
main = "./dist/cloudflare/_worker.js"
assets = { directory = "./dist/cloudflare", binding = "ASSETS" }
main = "./dist/server/server.mjs"
assets = { directory = "./dist/browser", binding = "ASSETS" }

0 comments on commit ffe8d10

Please sign in to comment.