Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: experimental Angular template using Workers with Assets was broken #6815

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/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"
experimental_assets = { directory = "./dist/browser", binding = "ASSETS" }
edmundhung marked this conversation as resolved.
Show resolved Hide resolved
Loading