1371 Commits

Author SHA1 Message Date
Alan Agius
cae068be37 fix(@schematics/angular): update library schematic to use @angular-devkit/build-angular:ng-packagr
The library schematic currently relies on Karma, which requires `@angular-devkit/build-angular` to be installed. To address this, we now use the `ng-packagr` builder provided in this package.

Closes #29494
2025-01-29 08:15:46 +01:00
Alan Agius
ec05c814ee fix(@angular/ssr): rename provideServerRoutesConfig to provideServerRouting
This commit renames `provideServerRoutesConfig` to `provideServerRouting` and updates the second parameter to use the `ServerRoutes` features.

This change improves alignment with the framework's API conventions and the way features are integrated.

### Example Usage:
Before:
```typescript
provideServerRoutesConfig(serverRoutes, { appShellRoute: 'shell' })
```

After:
```typescript
provideServerRouting(serverRoutes, withAppShell(AppShellComponent))
```
2025-01-28 09:25:42 +01:00
Paul Gschwendtner
34367874da build: migrate @schematics/angular tests to rules_js
Migrates the @schematics/angular tests to `rules_js`.
2025-01-21 18:19:11 +01:00
Paul Gschwendtner
1a4157d88c build: migrate @angular/cli tests to use rules_js
Integrates `@angular/cli` into the pnpm workspace and wires up the
native `rules_js` rules.

One nice benefits that highlight here:

- `resolve` runtime dependency is only installed in the CLI folder, and
  we can pull it from there. --> Locally managed deps! :yay:
2025-01-17 16:29:45 +01:00
Alan Agius
31cbf5f9ad build: replace hardcoded Angular and ng-packagr peer dependencies with Bazel stamping
Refactor the build configuration to use Bazel stamping for Angular and ng-packagr dependencies, eliminating the need for hardcoded peer dependencies.
2025-01-16 19:06:30 +01:00
Paul Gschwendtner
4fee94a96c build: rename //:root_modules to //:node_modules.
This is necessary as `rules_js` requires this "common name" when dealing
with Yarn workspaces, linking first party dependencies automatically.

In the future, we may be able to send a PR to `rules_js` to support a
custom name somehow.
2025-01-15 19:20:40 +01:00
Alan Agius
8ba6b28b43 docs: enhance descriptions for schematics options
Refined and clarified the descriptions for various schematics options to improve their readability and accuracy. These changes aim to make the documentation more user-friendly and accessible for developers.

Closes #25571
2025-01-15 17:31:06 +01:00
Joey Perrott
cdfdc68ff9 build: migrate @schematics/angular to npm_package
This allows us to use the package in the RJS pnpm workspace.
2025-01-15 10:09:17 +01:00
Paul Gschwendtner
a8335cf950 build: never use interop targets for ts compilations
* Removes `interop_deps` from the `ts_project` interop macro.
* Keeps `_rjs` suffix for now as we still need the interop targets for
  e.g. `jasmine_node_test` and the `rules_nodejs` linker.

In follow-ups we can remove the suffix, and interop layer.
2025-01-09 09:42:06 +01:00
Charles Lyding
88431b7564 fix(@schematics/angular): application migration should migrate ng-packagr builder package
The `use-application-builder` update migration will now attempt to migrate
the `ng-packagr` builder to use the `@angular/build` package if no other
`@angular-devkit/build-angular` usage is present.
2025-01-08 12:21:48 -05:00
Charles Lyding
02825eec53 feat(@schematics/angular): use @angular/build package in library generation schematic
The newly introduced `ng-packagr` builder within the `@angular/build` package
is now used when generating a new library with `ng generate library`. This
builder provides the same functionality as the `ng-packagr` builder found
within the `@angular-devkit/build-angular` package but removes the need for
projects to install `@angular-devkit/build-angular` if using the `application`
builder from `@angular/build`.
2025-01-08 12:21:48 -05:00
Charles Lyding
d4a4bc859a build: migrate @schematics/angular to ts_project
The `@schematics/angular` package has been migrated to the `rules_js` ts_project rule.
2024-12-23 12:05:29 -05:00
Alan Agius
0a570c0c2e feat(@angular/build): add support for customizing URL segments with i18n
Previously, the `baseHref` option under each locale allowed for generating a unique base href for specific locales. However, users were still required to handle file organization manually, and `baseHref` appeared to be primarily designed for this purpose.

This commit introduces a new `subPath` option, which simplifies the i18n process, particularly in static site generation (SSG) and server-side rendering (SSR). When the `subPath` option is used, the `baseHref` is ignored. Instead, the `subPath` serves as both the base href and the name of the directory containing the localized version of the app.

Below is an example configuration showcasing the use of `subPath`:

```json
"i18n": {
  "sourceLocale": {
    "code": "en-US",
    "subPath": ""
  },
  "locales": {
    "fr-BE": {
      "subPath": "fr",
      "translation": "src/i18n/messages.fr-BE.xlf"
    },
    "de-BE": {
      "subPath": "de",
      "translation": "src/i18n/messages.de-BE.xlf"
    }
  }
}
```

The following tree structure demonstrates how the `subPath` organizes localized build output:
```
dist/
├── app/
│   └── browser/  # Default locale, accessible at `/`
│       ├── fr/  # Locale for `fr-BE`, accessible at `/fr`
│       └── de/  # Locale for `de-BE`, accessible at `/de`
```

DEPRECATED: The `baseHref` option under `i18n.locales` and `i18n.sourceLocale` in `angular.json` is deprecated in favor of `subPath`.

The `subPath` defines the URL segment for the locale, serving as both the HTML base HREF and the directory name for output. By default, if not specified, `subPath` will use the locale code.

Closes #16997 and closes #28967
2024-12-07 19:00:32 +01:00
Angular Robot
d095498622 build: update schematics dependencies to ~5.5.0 2024-12-03 08:34:23 +01:00
Kristiyan Kostadinov
4d466bfa6a build: update to TypeScript 5.7
Updates the repo to use TypeScript 5.7.
2024-12-02 14:15:18 +01:00
Alan Agius
4e5585a27f build: update Angular packages to version 19.1.x 2024-12-02 13:12:00 +01:00
Guilherme Siquinelli
af8778091e
fix(@schematics/angular): add required type to CanDeactivate guard (#29004)
Add missing required generic type in spec file template.
2024-12-02 10:19:05 +01:00
Doug Parker
173dc0eeac fix(@schematics/angular): skip SSR routing prompt in webcontainer
Apparently `inquirer` requires `async_hooks` which isn't supported in webcontainers, therefore prompting the user fails. Instead we always fall back to the default option.

See: https://github.com/SBoudrias/Inquirer.js/issues/1426
2024-11-25 15:02:55 -05:00
Charles Lyding
23dac18def build: update Angular packages to v19 stable 2024-11-19 10:01:19 -05:00
Doug Parker
160dee33d7 fix(@schematics/angular): don't show server routing prompt when using browser builder
The new routing APIs don't support `browser` builder, but calling `ng add @angular/ssr` with a `browser` builder would still prompt the user to add them. If the user said "Yes", it would actually ignore that answer and not enable the new APIs.

With this change, `ng add @angular/ssr` when using `browser` builder does not show the prompt and assumes the answer is "No". It also throws an error if the user runs `ng add @angular/ssr --server-routing`.

I'm not aware of a built-in prompting mechanism in schematics beyond `x-prompt`, which can't be used here, so instead I just called Inquirer directly. Unfortunately testing the prompt is a little awkward, as Inquirier does not provide useful APIs in this space. I evaluated `@inquirer/testing`, but ultimately decided that was more intended for testing custom Inquirer prompts, not mocking usage of standard prompts. Schematics APIs do not provide a useful way to inject additional data like a mock, so instead I had to do this through a `setPrompterForTestOnly` function. I'm not a huge fan of it, but I don't see a more straightforward way of solving the problem.
2024-11-18 10:37:31 -08:00
Doug Parker
2e43ec6654 fix(@schematics/angular): use default import for express
Now that we're using `esModuleInterop`, a default import is required.
2024-11-15 17:24:20 -08:00
Alan Agius
b2e2be052f refactor(@angular/ssr): remove RenderMode.AppShell in favor of new configuration option
This commit removes the `RenderMode.AppShell` option. Instead, a new configuration parameter, `{ appShellRoute: 'shell' }`, is introduced to the `provideServerRoutesConfig` method.

```ts
provideServerRoutesConfig(serverRoutes, { appShellRoute: 'shell' })
```
2024-11-08 19:51:35 +01:00
Charles Lyding
7c6cb9593a fix(@angular/cli): recommend optional application update migration during v19 update
The optional application builder migration will now default to enabled and
recommended during the update process (`ng update`) for v19. The migration
is still optional and can be unselected if preferred when updating.
2024-11-01 11:29:14 -04:00
cexbrayat
51fd98018e fix(@schematics/angular): component spec with export default
The generated spec was using the same import when it should be adapted if `exportDefault` is used:

```ts
import { UserComponent } from './user.component.ts`
```

It now produces:

```ts
import UserComponent from './user.component.ts`
```
2024-11-01 08:24:21 -04:00
Alan Agius
481ccdbc5a fix(@angular/ssr): enable serving of prerendered pages in the App Engine
This commit implements the capability for the App Engine to serve prerendered pages directly. Previously, we relied on frameworks like Express for this functionality, which resulted in inconsistent redirects for directories where in some cases a trailing slash was added to the route.

**Note:** This change applies only when using the new SSR APIs. When using the `CommonEngine`, a 3rd party static serve middleware is still required.
2024-11-01 10:45:05 +01:00
Alan Agius
43cd4584f5 fix(@schematics/angular): enable opt-in for new @angular/ssr feature
This commit updates several schematics to make the new `@angular/ssr` feature opt-in. Users can opt in by using the `--server-routing` option or by responding with `yes` to the prompt.
2024-10-25 19:51:12 +02:00
Alan Agius
8567267603 refactor(@schematics/angular): remove redundant standalone: true from templates
This is no longer needed.
2024-10-24 16:23:02 +02:00
Doug Parker
c79afde0f3 test: update ng generate e2e calls to ng generate private-e2e. 2024-10-21 14:50:18 -07:00
Doug Parker
62877bdf2b refactor(@angular-devkit/build-angular): remove Protractor builder and schematics
BREAKING CHANGE: Protractor is no longer supported.

Protractor was marked end-of-life in August 2023 (see https://protractortest.org/). Projects still relying on Protractor should consider migrating to another E2E testing framework, several support solid migration paths from Protractor.

* https://angular.dev/tools/cli/end-to-end
* https://blog.angular.dev/the-state-of-end-to-end-testing-with-angular-d175f751cb9c
2024-10-21 14:50:18 -07:00
cexbrayat
8ce57fea5f refactor(@schematics/angular): spacing fixes after experimental zoneless introduction 2024-10-17 14:16:15 +00:00
Jan Martin
fcf7443d62 fix(@schematics/angular): explicitly set standalone:false 2024-10-16 07:56:23 -07:00
Alan Agius
3db1d81397 refactor(@schematics/angular): minor formatting fixes
Some minor formatting fixes.
2024-10-15 19:42:39 +02:00
aparziale
755f3a07f5 feat(@schematics/angular): add option to setup new workspace or application as zoneless mode 2024-10-15 09:28:18 -07:00
Alan Agius
29855bf54e docs: improve README files generated by Angular schematics 2024-10-14 19:32:26 +02:00
Jithil P Ponnan
a68e832aef fix(@schematics/angular): update browserslist config to include last 2 Android major versions 2024-10-14 09:35:06 -07:00
Angular Robot
d4c17520b1 build: update schematics dependencies to ~5.4.0 2024-10-14 09:33:51 -07:00
Jithil P Ponnan
67d153242f docs(@schematics/angular): update code scaffolding doc to with ng generate --help 2024-10-14 10:31:27 +02:00
Alan Agius
bfa8fec9b1 fix(@angular/build): use named export reqHandler for server.ts request handling
Some cloud providers, such as Cloudflare, expect the default export to follow a specific structure (e.g., an object with a `fetch` property). To prevent the need for creating a separate `server.ts` file for production builds, the request handler is now exported as `reqHandler` instead of a default export.
2024-10-10 22:20:56 +02:00
Alan Agius
292a4b7c2f feat(@schematics/angular): update app-shell and ssr schematics to adopt new Server Rendering API
This commit revises the app-shell and ssr schematics to incorporate the new Server Rendering API, along with the integration of server-side routes.

BREAKING CHANGE: The app-shell schematic is no longer compatible with Webpack-based builders.
2024-10-09 18:07:33 +02:00
Alan Agius
7de93e593a fix(@schematics/angular): include index.csr.html in resources asset group
Ensure `index.csr.html` is available for the service worker when using SSR/SSG.

Closes #28574
2024-10-07 09:43:37 -07:00
harshlakhara
6dbfc770b2 fix(@schematics/angular): add validation for component and directive class name 2024-10-04 10:23:01 +02:00
Jan-Niklas W.
4179bf2e6b fix(@schematics/angular): support single quote setting in JetBrains IDEs 2024-09-26 12:24:14 -04:00
Alan Agius
cfca5442ec feat(@schematics/angular): integrate withEventReplay() in provideClientHydration for new SSR apps
Event Replay is now stable (see https://github.com/angular/angular/pull/57895). This commit adds `withEventReplay()` to the `provideClientHydration()` call in newly created Angular applications with SSR.
2024-09-23 17:20:07 +02:00
Alan Agius
743188ba62 refactor: Add lines-around-comment rule
I often struggle with spacing around block comments, so I've decided to add the `lines-around-comment` lint rule to help manage this.

For more details, see the https://eslint.style/rules/js/lines-around-comment
2024-09-11 12:10:54 +02:00
Kristiyan Kostadinov
8f051a49e6 build: update all remaining places to TypeScript 5.6
Updates a few leftover places to the TypeScript 5.6 final version.
2024-09-10 09:25:11 +02:00
Angular Robot
eb97c4354f build: update schematics dependencies to ~5.3.0 2024-09-09 16:44:12 +02:00
Charles Lyding
85f75aa6ba refactor(@schematics/angular): remove explicit TypeScript lib option for new projects
Newly generated projects will now no longer have an explicit `lib` option defined
within the TypeScript configuration for the workspace (`tsconfig.json`). This
option will default to the `target` option value plus `DOM`. This combination is
the same as the explicit value set in a new project. Removing the explicit option
value will result in equivalent behavior without the need to duplicate the ES
version in two places.
2024-08-29 19:23:43 -04:00
Doug Parker
3ee21631f4 fix(@angular-devkit/build-angular): clear context in Karma by default for single run executions
This works around https://github.com/angular/angular-cli/issues/28271.
2024-08-29 12:00:31 -07:00
Kristiyan Kostadinov
7f570c5685 build: update to TypeScript 5.6 RC
Updates the repo to the TypeScript 5.6 RC and narrows down the version to drop support for 5.4, in line with the compiler.
2024-08-29 10:40:28 +02:00
Alan Agius
d8b8364d35 refactor(@schematics/angular): move @angular/ssr dependency to server schematic
This change is necessary as the `@angular/ssr` package is now required for all types of server-side rendering, including SSG and app-shell.
2024-08-27 09:34:04 -07:00