3599 Commits

Author SHA1 Message Date
Alan Agius
603d24f966 fix(@schematics/angular): rename app.server.module.ts to app.module.server.ts
This fixes an issue were we generated files using inconsistent names example `app.server.module.ts` and `app.config.server.ts`.
2023-04-25 15:19:36 +00:00
Charles Lyding
480eb3eeff fix(@angular-devkit/build-angular): use preserveSymlinks option for tsconfigs in esbuild builder
When using the esbuild-based browser application builder, the tsconfig path will now be properly
converted to the realpath when the `preserveSymlinks` option is disabled (the default). This ensures
that TypeScript source files will be properly matched with the bundler's resolved paths when symlinks
are used and the `preserveSymlinks` option is not enabled. This is needed to properly support the use
of bazel with rules_js.
2023-04-25 15:19:20 +00:00
Angular Robot
7a7ad7fe85 build: update all non-major dependencies 2023-04-25 15:18:20 +00:00
Doug Parker
c045c99667 refactor: add outExtension to browser-esbuild as an internal option
The `outExtension` option allows users to generate `*.mjs` files, which is useful for forcing ESM execution in Node under certain use cases. The option is limited to `*.js` and `*.mjs` files to constrain it to expected values. `*.cjs` could theoretically be useful in some specific situations, but `browser-esbuild` does not support that output format anyways, so it is not included in the type.

I also updated `index.html` generation, which will correctly insert a `<script />` tag with the `*.mjs` extension. I opted to explicitly ban a "non-module" `*.mjs` file, since that would be very counterintuitive and I can't think of a valid use case for it.
2023-04-24 22:43:32 +00:00
Doug Parker
0d4a40fd6e refactor: make index option nullable for browser-esbuild
For testing use cases, we don't need an `index.html` file in the same capacity as a typical application. The builder already omits an `index.html` page when not set, this just updates the schema to reflect that.

The parameter could be left optional, rather than required but allowing `false`. However doing it this way prevents users from accidentally forgetting to provide an index while still allowing users to explicitly disable index generation. We use `false` instead of `null` so users can write `--no-index` on the command line and get the same behavior, which would not be possible with `null`.
2023-04-24 22:43:32 +00:00
Doug Parker
e22352ba09 refactor: add absolute entry point support to browser-esbuild
This allows `browser-esbuild` to consume absolute file paths and `entryPoints`. Absolute paths will always output in the root of the output directory with the same basename, since they are not within the workspace root and cannot exist at any guaranteed unique relative path. No attempt is made to check if the absolute path is actually within the workspace root, since this would require a call to `fs.realpath()` and make this logic dependent on the actual file system structure which introduces a lot of complexity we'd rather avoid.

Longer term, the ideal approach is probably to leverage virtual files in some capacity, but this should be sufficient for now.

`main` functionality is left alone, and absolute paths like `/main.ts` are treated as relative to the workspace root. This is to preserve existing functionality and discourage public API usage of file paths outside the workspace.
2023-04-24 22:43:32 +00:00
Doug Parker
71e87fc332 refactor: add entryPoints to browser-esbuild as an internal option
This makes the `main` parameter optional and allows multiple entry points instead. `main` is still technically required by the schema, since it should almost always be set when invoked by a user. However, it now supports `null` as a value so it can be explicitly omitted.

Longer term, we may choose to remove `main` and fold it into `entryPoints`, but for now we want to keep compatibility with the existing `browser` builder.

Since `entryPoints` is an internal-only options (cannot be set in `angular.json` and isn't exposed in the schema), I made a new `buildEsbuildBrowserInternal()` function which adds the extra private option. This way direct invocations of the builder can provide this extra information without compromising the public API surface defined in the schema.
2023-04-24 22:43:32 +00:00
Doug Parker
2d0943d73b refactor: loosen experimental warnings types
As is, the `browser` and `browser-esbuild` schemas needed to be identical to check for unsupported properties. This loosens it slightly by casting the `browser-esbuild` schema into the `browser` schema and looking for invalid properties. This makes the module more flexible as the `browser-esbuild` schema evolves _and_ more closely aligns with the actual mistake of users who incorrectly think of `browser-esbuild` as supporting all the options of `browser`, which it does not yet do so.
2023-04-24 22:43:32 +00:00
Alan Agius
688bb2db7b fix(@angular-devkit/build-angular): display warning when preserveWhitespaces is set in the tsconfig provided to the server builder
This commits add a check to display a warning when `preserveWhitespaces` is configured in `tsconfig.server.json`, as potentially this could cause issue with hydration.
2023-04-19 22:28:09 +00:00
Angular Robot
bda7e68848 build: update all non-major dependencies 2023-04-19 14:45:55 +00:00
Charles Lyding
694b1ead0d fix(@angular-devkit/build-angular): correctly filter lazy global styles in esbuild builder
Due to a typo in a conditional for the filtering of lazily defined global styles, global
styles were unintentionally always initial if no global scripts were present in the
application.
2023-04-19 14:42:49 +00:00
Charles Lyding
1f34e449eb refactor(@angular-devkit/build-angular): use helper to bundle all elements of esbuild builder
The code to execute the individual bundling elements of the esbuild-based browser application
builder has been consolidated within a bundler context helper method. This moves the execution
and result merging code into a single location and allows for more flexibility to control which
elements should be executed per build. The global styles and global scripts bundling is now fully
skipped if the options are not present in the build configuration.
2023-04-19 13:59:31 +00:00
Alan Agius
758b0695f3 fix(@angular-devkit/build-angular): update list of known tailwind configuration files
With this change we added `tailwind.config.mjs` and `tailwind.config.ts` to known tailwind config files.

Closes #24943
2023-04-18 16:28:00 +00:00
Charles Lyding
d5fed32096 refactor(@angular-devkit/build-angular): move TS/NG configuration reading into compiler classes
The TypeScript and Angular configuration reading (`tsconfig.json`) has now been moved into the
Angular compilation classes (AOT/JIT) directly. This removes compilation specific functionality
from the esbuild plugin and allows the plugin to focus primarily on integration with esbuild.
2023-04-18 10:56:36 +00:00
Angular Robot
8c4a84dc63 build: update all non-major dependencies 2023-04-17 19:39:13 +00:00
Charles Lyding
0c94254ad0 fix(@angular-devkit/build-angular): fully remove third-party sourcemaps when disabled in esbuild builder
When using the esbuild-based browser application builder, third-party sourcemaps will now be fully removed
when the `sourcemap` option's `vendor` sub-option is disabled. The `vendor` sub-option is disabled by default
and is only enabled if explicitly enabled within the project's configuration. Sourcemaps are considered
third-party if their referencing code is contained within a `node_modules` directory.
Previously, sourcemap URL comments may have been unintentionally left intact when processing third-party code
via the Babel-based JavaScript transformer. These sourcemap URL comments are now removed correctly when
code is both transformed and return directly when no transformation is required.
2023-04-14 21:53:47 +00:00
Charles Lyding
571f8947ce fix(@angular-devkit/build-angular): correctly show initial files in stat table with esbuild builder
When using the esbuild-based browser application builder, only actual initial files will be displayed
in the initial files section. Previously, certain dynamically imported files could unintentionally be
displayed in the stats output table as initial files. This was a display only error and had no effect
on the files added to the index HTML file.
2023-04-14 21:53:17 +00:00
Doug Parker
f50234f72c Revert "ci: bump Angular dependencies to 16.0.0-rc.0"
This reverts commit 290e06018d3934cf27a5734a60947dcd7b45fa58.

Release checks don't like being in an RC state and it's not strictly necessary since installing a `-next` package will install `-rc` because it alphabetically follows. This means generating applications with `-next` in the `package.json` will still pull the latest RC releases of Angular packages.
2023-04-13 16:54:22 +00:00
Charles Lyding
1e78cf99c1 perf(@angular-devkit/build-angular): cache Sass in memory with esbuild watch mode
To improve rebuild performance when using Sass stylesheets with the esbuild-based
browser application builder in watch mode, Sass stylesheets that are not affected
by any file changes will now be cached and directly reused. This avoids performing
potentially expensive Sass preprocessing on stylesheets that will not change within
a rebuild.
2023-04-13 16:14:22 +00:00
Doug Parker
290e06018d ci: bump Angular dependencies to 16.0.0-rc.0 2023-04-12 20:30:02 +00:00
Angular Robot
083ab8067c build: update all non-major dependencies 2023-04-12 20:00:35 +00:00
Charles Lyding
4d8d489aae fix(@angular-devkit/build-angular): normalize long-form asset option output to relative path
The output option for the long-form of the assets build option should be a relative path based
from the output path of the application. However, a rooted path was also considered relative
to the output path. To avoid two different ways of representing the path throughout the build
system. The output path is now normalized to a relative path at the beginning of the build
process.
2023-04-12 17:35:11 +00:00
Charles Lyding
26c67f92a8 fix(@angular-devkit/build-angular): ensure all build resources are served in esbuild dev server
Previously when using the esbuild-based browser application builder with the new dev server,
resource files referenced via stylesheets may not have been served by the development server.
The development server has now been adjusted to properly prioritize and serve files that were
generated during the build process.
Global stylesheets are also currently considered resource files as well to workaround issues
with development sourcemaps within the development server itself. Global stylesheets are already
fully processed by the build system prior to being passed to the development server.
2023-04-12 17:35:11 +00:00
Charles Lyding
587c4d05e9 refactor(@angular-devkit/build-angular): use base class for esbuild Angular JIT/AOT compilation
Types and functionality that were used by both the AOT and JIT compilation classes within
the esbuild Angular compiler plugin have been extracted into a common base class that
both now extend. This removes duplicate code from both classes.
2023-04-12 17:34:57 +00:00
Charles Lyding
4111682b84 refactor(@angular-devkit/build-angular): move esbuild compiler plugin in angular directory
Minor directory restructure to better organize the Angular compiler plugin code files.
The remainder of the Angular specific files for the Angular esbuild compiler plugin are now
within the `angular` subdirectory of the esbuild-based browser application builder.
2023-04-12 17:34:57 +00:00
Charles Lyding
df49c359de perf(@angular-devkit/build-angular): asynchronously delete output path in esbuild builder
When using the esbuild-based browser application builder, the output path is deleted
prior to performing a build to ensure a clean output with only the built files. The
deletion will now be performed asynchronously using the Node.js promised-based API.
This should provide a small performance improvement for projects with large output
directories.
2023-04-12 17:34:43 +00:00
Charles Lyding
11fa1221f0 perf(@angular-devkit/build-angular): enhance Sass package resolution in esbuild builder
The package module resolution logic for Sass stylesheets within the esbuild-based browser
application builder has been restructured to limit the need to perform fallback resolution
unless fully required. This allows common cases to avoid unnecessary and expensive resolution
attempts. This provided a roughly 40% improvement in build times for the Angular Material
documentation site.
2023-04-12 17:34:26 +00:00
Angular Robot
bbf871c817 build: update all non-major dependencies 2023-04-11 21:33:57 +00:00
Charles Lyding
f99e106e32 refactor(@angular-devkit/build-angular): directly watch package lock files in esbuild builder
When using the esbuild-based browser application builder in watch mode, all `node_modules`
directories will now be ignored by the file watcher. Instead all relevant package manifests
and lock files for `npm`, `yarn, and `pnpm` will be watched to detect potential changes
to the project's dependencies. This avoids creating a potentially large amount of filesystem
watchers as the node modules directories can be very large.
2023-04-11 16:48:22 +00:00
Charles Lyding
8e57db6518 fix(@angular-devkit/build-angular): show lazy files in stat table correctly with esbuild
When using the esbuild-based browser application builder, the output build file stat table
was incorrectly displaying non-injected global styles and scripts as initial files. These
output files will now be correctly shown as lazy files. Initial files will also now display
their respective name if available. The table entries are now sorted in descending order by
raw file size as was done in the Webpack-based builder.
2023-04-11 16:47:47 +00:00
Charles Lyding
2b937db66a fix(@angular-devkit/build-angular): ensure directories are properly ignored in esbuild builder
When using the esbuild-based browser application builder in watch mode, the underlying file
watcher based on chokidar would previously not fully ignore the output path if the path contained
a trailing slash. To workaround this, directory paths based on supplied options are now
normalized to remove any trailing slashes.
2023-04-11 16:47:26 +00:00
Charles Lyding
8daf3a5c9c perf(@angular-devkit/build-angular): only import esbuild watcher when in watch mode
When using the esbuild-based browser application builder, all the watch-related code
is now only imported when the watch mode is enabled. This removes the need for Node.js
to resolve and load code that will not be used.
2023-04-11 16:47:10 +00:00
Charles Lyding
d8ba2fedca test(@angular-devkit/build-angular): enable additional styles tests for esbuild builder
Now that output stat logging for the esbuild-based browser application builder has been
implemented, the previously disabled styles option tests can be enabled.
2023-04-11 16:46:55 +00:00
Alan Agius
4eaf107305 build: update minimum supported Node version from 16.13.0 -> 16.14.0
This commit updates the minimum supported Node version across packages from 16.13.0 -> 16.14.0 to ensure compatibility with dependencies.
2023-04-11 16:46:10 +00:00
Charles Lyding
c06b1bd3d7 perf(@angular-devkit/build-angular): skip Angular linker in JIT mode with esbuild
When using the esbuild-based browser application builder in JIT mode, the Angular
linker will now be skipped. The runtime Angular compiler present in JIT applications
will automatically link any needed code.
2023-04-06 17:58:55 +00:00
Charles Lyding
0eac98f617 feat(@angular-devkit/build-angular): implement progress option for esbuild builder
When using the esbuild-based browser application builder, the `progress` option which
is enabled by default will now show an activity spinner when building/rebuilding.
2023-04-05 16:07:44 +00:00
Charles Lyding
e4883b0ee1 feat(@angular-devkit/build-angular): support SSL options with esbuild development server
When using the esbuild-based browser application builder and its newly supported development
server, the SSL related `dev-server` builder options can now be used. These include the existing
`ssl`, `sslCert`, and `sslKey` options. Additionally, if no certificate and key are provided
the `@vitejs/plugin-basic-ssl` plugin will be used to provide an auto-generated one.
2023-04-05 16:07:33 +00:00
Alan Agius
295b8488a4 build: update all non-major dependencies
(cherry picked from commit 497da48086f84a8e7f260dcd817ffbe84ef7765e)
2023-04-05 10:26:32 +00:00
Charles Lyding
4822b3ba55 fix(@angular-devkit/build-angular): keep esbuild server active until builder fully stops
Use the now working builder teardown functionality to ensure that the development server
is properly closed when the builder is stopped.
2023-04-05 09:25:37 +00:00
Charles Lyding
48871381a1 fix(@angular-devkit/architect): allow registered builder teardowns to execute
Previously, the base job handler was completing the entire job before any teardowns
could attempt to execute.
2023-04-05 09:25:37 +00:00
Charles Lyding
67670b612e fix(@angular-devkit/build-angular): pass listening port in result for esbuild dev server
The deprecated protractor builder requires that the result object from a development server
provide the port used to access the application if the port is not the default (4200). The
newly introduced esbuild development server will now provide the port when available.
2023-04-05 09:25:37 +00:00
Charles Lyding
ce46ecae01 feat(@angular-devkit/build-angular): support module resolution with less stylesheets in esbuild builder
When using the esbuild-based browser application builder with Less stylesheets, import rules
will now attempt to perform node package resolution if the import cannot be found as a relative
path. Built-in Less resolution is performed first to both avoid unnecessary node module resolution
overhead when not needed and also ensure Less relative import semantics continue to be supported.
2023-04-04 14:41:23 +00:00
Charles Lyding
584b51907c feat(@angular-devkit/build-angular): support scripts option with esbuild builder
When using the esbuild-based browser application builder, the `scripts` option will
now provide equivalent functionality to the current default Webpack-based builder.
The option provides full node resolution capabilities which allows both workspace
relative paths and package paths with support for the `script` exports condition.
2023-04-04 09:59:59 +00:00
Charles Lyding
8c550302cc feat(@angular-devkit/build-angular): initial development server for esbuild-based builder
When using the experimental esbuild-based browser application builder, the preexisting `dev-server` builder
can now be used to execute the `ng serve` command with an esbuild bundled application. The `dev-server` builder
provides an alternate development server that will execute the `browser-esbuild` builder to build the application
and then serve the output files within a development server with live reload capabilities.
This is an initial integration of the development server. It is not yet fully optimized and all features
may not yet be supported. SSL, in particular, does not yet work.

If already using the esbuild-based builder, no additional changes to the Angular configuration are required.
The `dev-server` builder will automatically detect the application builder and use the relevent development
server implementation. As the esbuild-based browser application builders is currently experimental, using
the development server in this mode is also considered experimental.
2023-04-04 08:22:36 +00:00
Charles Lyding
aae34fc02d perf(@angular-devkit/build-angular): fully lazy load sass in esbuild builder
When using the esbuild-based browser application builder, the Sass worker pool
import is now lazy to prevent unnecessary module loading when Sass is not used
within an application.
2023-04-04 08:22:20 +00:00
Charles Lyding
b8c9667f92 fix(@angular-devkit/build-angular): remove unintended files in esbuild output stats table
When using the esbuild-based browser application builder, the stat output table was incorrectly
displaying source map files and internal component resource files such as inline stylesheets
as initial entries.
2023-04-03 10:15:36 +00:00
Charles Lyding
005ba42766 fix(@angular-devkit/build-angular): ensure empty component styles compile with esbuild
Previously when using the esbuild-based browser application builder, an empty inline
component style (`styles: ['']`) would cause the build to fail. This was due to a
bad assertion condition that has now been corrected.
2023-03-31 15:36:42 +00:00
Charles Lyding
ee8013f66f feat(@angular-devkit/build-angular): display build output table with esbuild
When using the experimental esbuild-based browser application builder, a build
output table will now be displayed upon completion. The table is formatted to
display output file information in a similar way to the default Webpack-based
browser application builder. Estimated transfer size is currently not displayed
but will be added in a future change.
2023-03-31 15:36:26 +00:00
Alan Agius
458400b7b1 perf(@angular-devkit/build-angular): avoid unnessary iterations
This commit reduces the number of child node visited when adding the nonce attribute. This changes have been ported form angular/universal.
2023-03-30 17:17:37 +00:00
Angular Robot
32e80cf246 build: update angular
(cherry picked from commit b68b225a354e725451e2cd9f310160c4621be4d3)
2023-03-30 17:17:37 +00:00