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`
In angular/angular#40559, a new `@angular/platform-server/init`
entry-point was introduced, which can be used to initialize the server
environment by providing shims for APIs normally provided by the browser
(such as DOM globals).
If the project is using a version of Angular (and thus
`@angular/platform-server`) that is known to include this new
entry-point, the newly generated `main.server.ts` file should import it
at the top in order to ensure that the shims will be available as soon
as possible (before other direct or transitive imports that may rely on
them). See also angular/angular#40559 for more details.
NOTE:
This `universal` schematic is the base for `app-shell`,
`@nguniversal/express-engine` and `@nguniversal/hapi-engine`.
Fixesangular/angular#40559
Since the tsconfig for e2e’s is named tsconfig.json there is no reason why it should be included in the solutions typescript configuration file.
Closes#18190
The supported versions of Node.js support up to ES2018, the only reason why we don't use ES2017+ is because native `async` and `await` don't work with zone.js
See: https://github.com/angular/angular/issues/31730
With this change, we also ensure that we don't downlevel the server bundle to ES5 which is unnecessary.
Closes: #17794
With this change, lazy-loading on the server becomes enabled out of the box for new projects. This is because webpack will only split ES6 imports into separate chunks. However when using commonjs all lazy loaded paths will be concatenated into the main.js file.
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
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
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
* test: update tests to work with new stricter tsconfig file inclusions
* fix(@schematics/angular): exclusively list the files in tsconfigs
With the omission of `includes` or `files` in tsconfig files tsc will pick up all the files under the rootDir and make them as part of the compilation. In certain cases, redundant files will be picked up which will cause a slower compilations.
Related to: TOOL-949
The universal tsconfig extends the application tsconfig which by default it's module format is ES2015. While NodeJS 12 does support this, older versions of Node don't
The baseUrl is used for non relative module imports, and we should always use the baseUrl set in the workspace tsconfig. When having path mappings set at workspace level and setting a `baseUrl` in the server tsconfig, this paths will no longer work as paths mapping as relative to the baseUrl.
Fixes#13935