42 Commits

Author SHA1 Message Date
Alan Agius
a416b4eff5 fix(@angular-devkit/build-angular): provide option to run build-optimizer on server bundles
This commit adds the option to run build-optimizer on the server bundles.

This is needed as in some cases, there can be restrictions on the size of
server bundles that can be executed. One of these cases is CloudFlare workers
 which by default does not work with an `ng-new` application due to the size of the
 bundle mainly due to the retention of the `@angular/compiler`.
2023-04-26 15:58:53 +00:00
Mike Brocchi
dc5cc893d6 feat(@schematics/angular): Update universal schematic to support standalone applications 2023-03-28 14:45:21 +00:00
Alan Agius
c9e84d0243 feat(@schematics/angular): remove generation of BrowserModule.withServerTransition
This commit removes generation of `.withServerTransition` in the universal schematic as is deprecated.

 DEPRECATED: the `app-id` option in the app-shell and universal schematics has been deprecated without replacement. See: https://github.com/angular/angular/pull/49422 for more information about the rational of this change.
2023-03-24 20:37:32 +00:00
Alan Agius
88fddc0503 fix(@schematics/angular): remove bootstrapping wrapping in universal schematic
The bootstrapping wrapping is no longer necessary as of 15.1.3. See: https://github.com/angular/angular/pull/48868
2023-02-07 01:00:50 +00:00
Alan Agius
c8a3b30000 fix(@schematics/angular): replace existing BrowserModule.withServerTransition calls when running universal schematic
This change fixes an issue where calling the universal schematic on an application with existing `BrowserModule.withServerTransition` will cause an additional `.withServerTransition` call to be added.

With this change we now remove the previous `withServerTransition` call to avoid misconfiguration.

Closes #24563
2023-01-18 17:13:23 +00:00
Alan Agius
11bb8ce26f perf(@angular-devkit/build-angular): add vendor chunking to server builder
With this change we add the `vendorChunk` option in the server builder. This option should only be used in development as it is intended to be used to improve the incremental re-build time.

This improves the rebuild time as Webpack will have less modules to analyse during a change in the application. Below, we can see the impact this change has in a `ng new` application.

Without vendor chunking
```
$ ng run ssr-vendor:server:development --watch --no-vendor-chunk
Build at: 2022-11-14T08:42:27.089Z - Hash: 0325905b63e43ddb - Time: 15357ms
Build at: 2022-11-14T08:42:37.565Z - Hash: 05cb180a02524656 - Time: 2498ms
Build at: 2022-11-14T08:42:40.325Z - Hash: c5a6996ed1924088 - Time: 1862ms
Build at: 2022-11-14T08:42:43.043Z - Hash: 92ce99f38a769c19 - Time: 1516ms
```

With vendor chunking
```
$ ng run ssr-vendor:server:development --watch --vendor-chunk
Build at: 2022-11-14T08:43:13.631Z - Hash: 28bdfea879d01a31 - Time: 15561ms
Build at: 2022-11-14T08:43:19.396Z - Hash: cc95e2b6cb403111 - Time: 1705ms
Build at: 2022-11-14T08:43:21.296Z - Hash: 204138490668a16c - Time: 848ms
Build at: 2022-11-14T08:43:23.835Z - Hash: 4fa294b261917944 - Time: 824ms
```
2022-11-15 10:14:02 -08:00
Alan Agius
a95d130ef4 feat(@angular-devkit/build-angular): auto include @angular/localize/init when found in types
With this change we remove the need to include the `@angular/localize/init` package as polyfills in `polyfills.ts`, `angular.json` and `main.server.ts`.

Instead when `@angular/localize/init` is included in the TypeScript `types` we add this as entry-point. The `@angular/localize/init` will be added as a parts of the `types` array in a seperate PR to address https://github.com/angular/angular/issues/47677 which is caused by the fact that `@angular/localize/init` types are no longer imported when `@angular/localize/init` is added as a polyfill in `angular.json`.
2022-10-12 08:57:29 +02:00
Alan Agius
ab8ab30c87 fix(@schematics/angular): use sourceRoot instead of src in universal schematic
With this change we remove the usage of hard coded `src` directory and instead infer this from the `sourceRoot` project option.

We also remove the `angularCompilerOptions.entryModule` property in the server tsconfig as this is no longer needed with Ivy.

Closes #12104
2022-06-29 08:56:11 -04:00
Charles Lyding
a0e3de2b5f refactor(@schematics/angular): use Tree's newly introduced readText and readJSON functionality
Code related to decoding buffers into strings and parsing content into JSON can now be removed by using the
support provided directly from the Tree instance for the executing schematic.
2022-04-26 19:24:55 -04:00
Charles Lyding
291bbffcc9 refactor(@schematics/angular): use string helper re-export from @angular-devkit/schematics
By using the `strings` re-export from `@angular-devkit/schematics` instead of from `@angular-devkit/core`,
the number of imports from `@angular-devkit/core` has been reduced and lowers the direct dependency count
for many of the individual schematics.
2022-04-22 11:31:53 -04:00
Charles Lyding
c927c038ba fix(@schematics/angular): remove @types/node from new projects
The `@types/node` package is now only added if E2E tests (`ng generate e2e`) or universal are added to a project.
2022-03-16 10:09:51 -04:00
Alan Agius
08687d1475 fix(@schematics/angular): wrap bootstrapping code in an HMR compatible manner
With this change we update the universal schematic bootstrap code to handle HMR properly. Previously, the bootstrapping code was called only on `DOMContentLoaded` which is not triggered when running in HMR.

Closes #21932
2021-10-13 17:43:24 +02:00
Alan Agius
4ed1c4f42d fix(@schematics/angular): replace clientProject with project 2021-05-05 11:49:22 -04:00
Charles Lyding
37a06a7c37 build: format all files
All files are now formatted using the ng-dev tools via prettier.
2021-04-28 16:05:49 -07:00
Joey Perrott
003854257c build: migrate all file header to use Google LLC rather than Google Inc 2021-04-27 08:35:22 +02:00
Charles Lyding
18c8adf0dc fix(@schematics/angular): set inlineStyleLanguage for universal if present in build options
The `inlineStyleLanguage` option should be set for an application's server target if also present in the application's build target. The setting is needed to ensure the server target properly builds the applica
tion's styles.
2021-04-19 20:30:35 +02:00
Alan Agius
226a8d274d feat(@schematics/angular): remove tslint and codelyzer from new projects
Both of these projects and the tslint builder are deprecated.

Closes #20105 and closes #18465
2021-03-16 15:49:46 +01:00
Alan Agius
1de6d71edd feat(@schematics/angular): production builds by default
With this change we do several changes to the `angular.json` configuration for `build` , `server` and `app-shell` targets so that these are `production` by default.

- build, server and app-shell targets are configured to run production by default.
- We add a new configuration named `development` to run the mentioned builder targets in development. Ex: `ng build --configuration development`.
- When adding `universal` or `app-shell`, we generate the full set of configurations as per the `buiid` target. Previously, we only generated the `production` configuration.
- We added a helper script in `package.json` to run build in watch mode. `npm run watch` which is a shortcut for `ng build --watch --configuration development`
2021-03-10 08:16:38 -06:00
Alan Agius
8b96e52d83 fix(@schematics/angular): remove solution style tsconfig from new projects
Following the issues highlighted in https://docs.google.com/document/d/1eB6cGCG_2ircfS5GzpDC9dBgikeYYcMxghVH5sDESHw/edit?usp=sharing and discussions held with the TypeScript team. The best course of action is to rollback this feature.

In future, it is not excluded that solution style tsconfigs are re-introduced..

Closes #18040 and closes #18170
2020-08-12 19:26:12 +01:00
Alan Agius
bede23226a feat(@schematics/angular): add solutions style tsconfig structure
In version 3.9, TypeScript introduced the concept of "Solutions Style" tsconfig to improve developer experience.

More info: https://devblogs.microsoft.com/typescript/announcing-typescript-3-9-rc/#solution-style-tsconfig

Closes #17493 and closes #8138
2020-05-20 12:12:33 -07:00
Alan Agius
aa6aee1ac1 fix(@schematics/angular): universal add outputHashing to media
In case the browser builder hashes the assets we need to add this setting to the server builder as otherwise when assets it will be requested twice. One for the server which will be unhashed, and other on the client which will be hashed.

Closes #15953
2019-10-29 20:21:24 -07:00
Alan Agius
fca9cbe6fd feat(@schematics/angular): update browser output path when adding universal
Currently, in the CLI universal schematic we are setting the server output path to `dist/project-server` and not amending the build outputPath

Ex:
```
dist/project
dist/project-server
```

However, the above paths are being update when adding `nguniversal` to the below:

```
dist/project/browser
dist/project/server
```

With this change it is proposed to move that logic to upstream.

Related PR to clean up nguniversal schematics https://github.com/angular/universal/pull/1265
2019-09-30 13:56:46 -07:00
Alan
640ae2fdf8 feat(@schematics/angular): augment universal/app-shell addition for @angular/localize
If i18n support is already present within an application, the newly generated `main.server.ts` file should also contain the `@angular/localize` polyfill to allow the universal application to function.

This universal schematic here, is the base for app-shell, @nguniversal/express-engine, and @nguniversal/hapi-engine
2019-09-25 09:46:41 -07:00
Alan Agius
8ea892cb7e feat(@schematics/angular): enable scripts optimization for server bundle
The optimizations are suggested to;
1) disables ngDevMode via terser
2) helps with cold server starts the same way as client by lowering JS parse times
2019-09-23 10:38:48 -07:00
Alan Agius
87d2223c49 Merge pull request #15559 from alan-agius4/main-server-file-option
fix(@schematics/angular): infer main server file name from main option
2019-09-10 10:10:03 -07:00
Alan Agius
ac23dc0913 fix(@schematics/angular): tsconfig with comments breaks universal schematic
Fixes #14371
2019-05-09 10:09:21 -07:00
Alan Agius
a464c001c3 fix(@schematics/angular): fix paths when newProjectRoot is an empty string
When `newProjectRoot` the paths are prefixed with an `/` example `/project-name/tsconfig.lib.json` which results in these being marked as absolute paths, which causes build failures.

Fixes #14108
2019-04-22 16:17:39 -07:00
Charles Lyding
e075edf8b4 refactor(@schematics/angular): update universal to use new workspace rules 2019-04-15 11:02:46 -07:00
Alan Agius
64c993aebb feat(@schematics/angular): stop adding @angular/http dependency when running universal schematic
`@angular/platform-server` is no longer dependent on
`@angular/http`

More info: https://github.com/angular/angular/commit/9745f55
2019-04-04 09:27:35 -07:00
Alan
a7d095d916 feat(@schematics/angular): change layout for root applications
This change aligns the file layout of applications generated with `ng new` and `ng generate`

Ref: TOOL-686
2019-03-06 11:28:26 -08:00
Alex Eagle
bf1c069f73 refactor(@schematics/angular): drop dependency on TypeScript package
instead, vendor in the two files we actually need.
This reduces our install footprint by 5MB
2019-03-06 11:27:48 -08:00
Alan Agius
36eba0c9fc refactor: use .template suffix for all schematic files
Currently when using `ivy-ngcc` it will print out a warning

```
Failed to read entry point info from //node_modules/@schematics/angular/workspace/files/package.json with error SyntaxError: Unexpected token < in JSON at position 1121.
```

Fixes #13378
2019-01-16 10:29:56 -08:00
Moritz Benzenhöfer
506401264b fix(@schematics/angular): fix syntax error in main.ts after generating universal
Add missing curly brace for application boostrap wrapper and test
Fixes #13392
2019-01-11 14:07:25 -08:00
Alan
a875b61b71 fix(@schematics/angular): wrapping bootstrap code in a DOMContentLoaded in variable declaration
Fixes #13042
2018-12-26 12:29:41 -08:00
Alan Agius
17ba2bc450 fix(@schematics/angular): set optimization and sourceMap in universal production config
- When using Universal sourceMaps should not be enabled or at least `styles` sourceMaps should be disabled as these will otherwise be inlined and will be set as apart of the server side rendered page.

- While there is no benefit to optimize the scripts at server level, styles should always be minified so that the server side rendered page is smaller.

Fixes #12541 and Fixes #12940
2018-12-14 10:54:30 -08:00
Suguru Inatomi
3cd6a33bd2 feat(@schematics/angular): add @angular/http as a dependency in universal 2018-10-15 14:34:49 -07:00
Alan Agius
82f2bda2f5 refactor(@schematics/angular): make interaction with architect targets type safe 2018-09-12 12:37:24 -07:00
Bram Borggreve
a94c826661 feat(@schematics/angular): let Universal schematic use configurations from build architect 2018-09-06 08:45:22 -07:00
Charles Lyding
d202480a17 build: update/cleanup tslint rules & fix errors 2018-08-23 11:35:34 -07:00
Filipe Silva
38fda3ea60 fix(@schematics/angular): support updating projects that use the targets property 2018-07-25 20:17:33 +01:00
Mike Brocchi
d3b49a5590 refactor: Consolidate adding dependencies 2018-06-08 19:59:53 +01:00
Hans Larsen
44086c60ff build: move devkit repo back to angular-cli 2018-06-05 18:50:06 -07:00