Skip to content

feat: support @19 #216

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

Merged
merged 51 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
29bb85d
chore: add angular@19 test fixture without prerendering and ssr
pieh Nov 6, 2024
9916cfe
chore: add angular@19 test fixture with prerendering and ssr using st…
pieh Nov 6, 2024
2626142
chore: add angular@19 test fixture with prerendering and ssr using De…
pieh Nov 6, 2024
f70172e
chore: add scripts for installing new fixture dependencies
pieh Nov 6, 2024
3ca0d57
test: add test for version validation when angular@19 is used
pieh Nov 6, 2024
400f82b
test: add test for version validation when angular deps are missing
pieh Nov 6, 2024
3ac2776
chore: add entire .netlify dirs to .gitignore
pieh Nov 6, 2024
210de56
test: add initial (failing) build tests for Angular 19 fixtures
pieh Nov 6, 2024
59ad25e
refactor: split reading angular version out to separate helper function
pieh Nov 6, 2024
314f3cb
fix: handle prerendered-routes.json shape in Angular 19
pieh Nov 6, 2024
ae959d4
chore: add runtime to new fixture dependencies
pieh Nov 6, 2024
d1d3df3
chore: upgrade demo to Angular 19
pieh Nov 7, 2024
97b690b
fix: hopefully initial working demo deployment using CommonEngine
pieh Nov 7, 2024
8a7a7cb
test: check if process import is result of using default server.ts
pieh Nov 7, 2024
cf8a3d4
test: fix used fixture dir in one of tests
pieh Nov 7, 2024
394eff2
fix: only patch deno method in Deno env
pieh Nov 7, 2024
83de2ed
fix: try/catch deno.readFile patching to avoid potential fatal errors
pieh Nov 7, 2024
5efa761
chore: upgrade @netlify/build
pieh Nov 7, 2024
ce65227
test: update assertion for changed hashes after update
pieh Nov 7, 2024
b887b5f
Revert "test: check if process import is result of using default serv…
pieh Nov 7, 2024
df8d0df
fix: add engine name to 'not supported' error message
pieh Nov 7, 2024
4cdf8a5
refactor: simplify user code
pieh Nov 8, 2024
05460df
test: remove dashboard from expected excluded paths as it's now serve…
pieh Nov 8, 2024
6187dfd
test: adjust test setup to not be impacted by angular-runtime devDeps
pieh Nov 8, 2024
d6b104d
chore: adjust eslint directive after adding @angular/ssr dev dep
pieh Nov 8, 2024
bd9994b
chore: upgrade node types (for before/after from node:test)
pieh Nov 8, 2024
47971ad
fix: workaround type problem for now
pieh Nov 8, 2024
8f24b90
fix: automatically set Netlify compatible request handler using Commo…
pieh Nov 8, 2024
7ffb649
fix: support AppEngine
pieh Nov 8, 2024
c64b969
test: update new test fixtures to rc.1
pieh Nov 8, 2024
09be6f9
fix: apply headers for prerendered routes
pieh Nov 8, 2024
ed3105e
fix: swap original server.ts back after build or failure
pieh Nov 12, 2024
0d1759d
fix: remove @android/ssr from dev and peerDeps
pieh Nov 12, 2024
c5d7911
chore(demo): migrate default server.ts to angular@19
pieh Nov 12, 2024
b51ec1c
fix: update disabled rule after removing @angular/ssr devDep
pieh Nov 12, 2024
65e9a63
fix: lint
pieh Nov 12, 2024
7eade18
Merge remote-tracking branch 'origin/main' into feat/support-v19
pieh Nov 12, 2024
2c1d198
chore: sync lock files
pieh Nov 12, 2024
f0b8146
docs: update readme for angular@19
pieh Nov 12, 2024
3c0c2f3
docs: update readme toc
pieh Nov 12, 2024
da1bc66
fix: re-add @ts-expect-error for app engine until angular types are a…
pieh Nov 12, 2024
945e676
chore: remove outdated TODOs
pieh Nov 12, 2024
deef2e4
chore: update jsdocs
pieh Nov 12, 2024
d91b1d4
Merge remote-tracking branch 'origin/main' into feat/support-v19
pieh Nov 18, 2024
57cd3f4
chore: upgrade to most recent RCs
pieh Nov 18, 2024
66b9ccc
test: update assertion after package bump
pieh Nov 18, 2024
e5036fd
feat: initial boilerplate and tooling to start matching server.ts to …
pieh Nov 18, 2024
69dbcdf
feat: only autoswap for known module content, otherwise fail build wi…
pieh Nov 18, 2024
d1f0d1f
fix: now that we require default or netlify compatible server.ts - up…
pieh Nov 18, 2024
5d222f9
chore: drop unuseful comment
pieh Nov 18, 2024
76dae2b
fix: attempt to normalize content for signature so crlf endlines are …
pieh Nov 18, 2024
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
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,5 @@ Temporary Items

# End of https://www.toptal.com/developers/gitignore/api/osx,node

.netlify/functions
.netlify/functions-serve
.netlify/functions-internal
.angular
.netlify
.angular
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ node_modules

# Tests
test
tests/fixtures
tests/fixtures
tools/known-server-ts-signatures
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ This build plugin implements Angular Support on Netlify.

- [Installation and Configuration](#installation-and-configuration)
- [Accessing `Request` and `Context` during Server-Side Rendering](#accessing-request-and-context-during-server-side-rendering)
- [Customizing request handling](#customizing-request-handling)
- [Limitations](#limitations)
- [CLI Usage](#cli-usage)
- [Getting Help](#getting-help)
- [Contributing](#contributing)
Expand Down Expand Up @@ -76,10 +78,71 @@ To test this in local development, run your Angular project using `netlify serve
```sh
netlify serve
```
### App Engine Developer Preview usage with Angular@19

## Limitations
If you opt into the App Engine Developer Preview accessing `Request` and `Context` objects is streamlined. Instead of custom Netlify prefixed providers, you should use the standardized injection tokens for those provided by `@angular/ssr` instead:

- The [`server.ts` file](https://angular.dev/guide/ssr#configure-server-side-rendering) that's part of the Angular scaffolding is meant for deploying to a VM, and is not compatible with this Netlify build plugin. If you applied changes to that file, you'll need to replicate them in an Edge Function. See (#135)[https://github.com/netlify/angular-runtime/issues/135] for an example.
```diff
+import { REQUEST, REQUEST_CONTEXT } from '@angular/ssr/tokens'
import type { Context } from "@netlify/edge-functions"

export class FooComponent {

constructor(
// ...
- @Inject('netlify.request') @Optional() request?: Request,
- @Inject('netlify.context') @Optional() context?: Context,
+ @Inject(REQUEST) @Optional() request?: Request,
+ @Inject(REQUEST_CONTEXT) @Optional() context?: Context,
) {
console.log(`Rendering Foo for path ${request?.url} from location ${context?.geo?.city}`)
// ...
}

}
```

## Customizing request handling

Starting with Angular@19. The build plugin makes use of `server.ts` file to handle requests. The default Angular scaffolding does generate incompatible code for Netlify so build plugin will swap it for compatible `server.ts` file for you automatically if it detects default one being used. If you need to customize the request handling, you can do so by copying one of code snippets below to your `server.ts` file.

If you did not opt into the App Engine Developer Preview:

```ts
import { CommonEngine } from '@angular/ssr/node'
import { render } from '@netlify/angular-runtime/common-engine'

const commonEngine = new CommonEngine()

export async function netlifyCommonEngineHandler(request: Request, context: any): Promise<Response> {
return await render(commonEngine)
}
```

If you opted into the App Engine Developer Preview:

```ts
import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
import { getContext } from '@netlify/angular-runtime/context'

const angularAppEngine = new AngularAppEngine()

export async function netlifyAppEngineHandler(request: Request): Promise<Response> {
const context = getContext()

const result = await angularAppEngine.handle(request, context)
return result || new Response('Not found', { status: 404 })
}

/**
* The request handler used by the Angular CLI (dev-server and during build).
*/
export const reqHandler = createRequestHandler(netlifyAppEngineHandler)
```

### Limitations

The [`server.ts` file](https://angular.dev/guide/ssr#configure-server-side-rendering) that's part of the Angular scaffolding is meant for deploying to a VM, and is not compatible with this Netlify build plugin for Angular@17 and Angular@18. If you applied changes to that file, you'll need to replicate them in an Edge Function. See (#135)[https://github.com/netlify/angular-runtime/issues/135] for an example.

## CLI Usage

Expand Down
6 changes: 2 additions & 4 deletions demo.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ test('edge function config', async () => {

assert.deepEqual(config.excludedPath, [
'/.netlify/*',
'/dashboard/index.html',
'/favicon.ico',
'/heroes/index.html',
'/index.csr.html',
'/main-QDJU6U55.js',
'/polyfills-RX4V3J3S.js',
'/main-UP4QHVAQ.js',
'/polyfills-FFHMD2TL.js',
'/styles-5INURTSO.css',
'/dashboard',
'/heroes',
])
})
2 changes: 1 addition & 1 deletion demo/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
"scripts": [],
"server": "src/main.server.ts",
"prerender": true,
"outputMode": "server",
"ssr": {
"entry": "server.ts"
}
Expand Down
Loading