-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update Angular template to version 17
This commits updates the Angular template to use Angular 17.
- Loading branch information
1 parent
e4aff81
commit c6b4755
Showing
11 changed files
with
105 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-cloudflare": minor | ||
--- | ||
|
||
Update Angular template to use version 17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/create-cloudflare/src/frameworks/angular/templates/server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { renderApplication } from '@angular/platform-server'; | ||
import bootstrap from './src/main.server'; | ||
|
||
interface Env { | ||
ASSETS: { fetch: typeof fetch }; | ||
} | ||
|
||
// We attach the Cloudflare `fetch()` handler to the global scope | ||
// so that we can export it when we process the Angular output. | ||
// See tools/bundle.mjs | ||
async function workerFetchHandler(request: Request, env: Env) { | ||
const url = new URL(request.url); | ||
console.log('render SSR', url.href); | ||
|
||
// Get the root `index.html` content. | ||
const indexUrl = new URL('/', url); | ||
const indexResponse = await env.ASSETS.fetch(new Request(indexUrl)); | ||
const document = await indexResponse.text(); | ||
|
||
const content = await renderApplication(bootstrap, { | ||
document, | ||
url: url.pathname, | ||
}); | ||
|
||
// console.log("rendered SSR", content); | ||
return new Response(content, indexResponse); | ||
} | ||
|
||
export default { | ||
fetch: (request: Request, env: Env) => | ||
(globalThis as any)['__zone_symbol__Promise'].resolve( | ||
workerFetchHandler(request, env) | ||
), | ||
}; |
35 changes: 0 additions & 35 deletions
35
packages/create-cloudflare/src/frameworks/angular/templates/src/main.server.ts
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/create-cloudflare/src/frameworks/angular/templates/tools/alter-polyfills.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { EOL } from "node:os"; | ||
import fs from "node:fs"; | ||
import { join } from "node:path"; | ||
import { worker } from "./paths.mjs"; | ||
|
||
/** | ||
* Split by lines and comment the banner | ||
* ``` | ||
* import { createRequire } from 'node:module'; | ||
* globalThis['require'] ??= createRequire(import.meta.url); | ||
* ``` | ||
*/ | ||
const serverPolyfillsFile = join(worker, "polyfills.server.mjs"); | ||
const serverPolyfillsData = fs | ||
.readFileSync(serverPolyfillsFile, "utf8") | ||
.split(EOL); | ||
|
||
for (let index = 0; index < 2; index++) { | ||
if (serverPolyfillsData[index].includes("createRequire")) { | ||
serverPolyfillsData[index] = "// " + serverPolyfillsData[index]; | ||
} | ||
} | ||
|
||
// Add needed polyfills | ||
serverPolyfillsData.unshift( | ||
`globalThis['process'] = {};`, | ||
`globalThis['global'] = globalThis;`, | ||
// Needed as performance.mark is not a function in worker. | ||
`performance.mark = () => {};`, | ||
); | ||
|
||
fs.writeFileSync(serverPolyfillsFile, serverPolyfillsData.join(EOL)); |
77 changes: 0 additions & 77 deletions
77
packages/create-cloudflare/src/frameworks/angular/templates/tools/bundle.mjs
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
packages/create-cloudflare/src/frameworks/angular/templates/tools/copy-client-files.mjs
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
packages/create-cloudflare/src/frameworks/angular/templates/tools/copy-files.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copy the files over so that they can be uploaded by the pages publish command. | ||
import fs from "node:fs"; | ||
import { join } from "node:path"; | ||
import { client, cloudflare, worker, ssr } from "./paths.mjs"; | ||
|
||
fs.cpSync(client, cloudflare, { recursive: true }); | ||
fs.cpSync(ssr, worker, { recursive: true }); | ||
|
||
fs.renameSync(join(worker, "server.mjs"), join(worker, "index.js")); |
10 changes: 0 additions & 10 deletions
10
packages/create-cloudflare/src/frameworks/angular/templates/tools/copy-worker-files.mjs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
packages/create-cloudflare/src/frameworks/angular/templates/tsconfig.server.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters