3544 Commits

Author SHA1 Message Date
Angular Robot
248b4c9a75 build: update all non-major dependencies 2024-01-23 10:52:36 +01:00
Charles Lyding
f83a4858d3 fix(@angular-devkit/build-angular): allow package file loader option with Vite prebundling
Previously, the `application` builder would consider all imports originating from a package
to be considered external when caching was enabled. This allows Vite's prebundling to function
and optimize the build/rebuild experience for the development server. However, when using the
newly introduced `loader` option, this also inadvertently caused files that should be affected
by the option that originate from a package to also be considered external. This behavior would
then prevent the loader customization from being performed. To rectify this situation, all files
that would be affected by a loader customization will not be marked as external for the purposes
of prebundling unless explicitly configured by the `externalDependencies` option.
2024-01-23 10:52:12 +01:00
Alan Agius
0b0df5a761 fix(@angular-devkit/build-angular): pre-transform error when using vite with SSR
This commit fixes a regression which causes a pre-transform error when using vite with ssr. The `request.url` is now passed to the index transformer instead of `request.originalUrl`. This is because the `request.url` will have a value of the `index.html`.

Closes #26897
2024-01-22 16:05:06 +01:00
Alan Agius
14b1be26b9 refactor(@angular-devkit/build-angular): use for loop instead of filter and forEach
Reduce iterations by using a `for loop`.
2024-01-22 15:56:44 +01:00
Alan Agius
af1f0da37f fix(@angular-devkit/build-angular): do not add internal CSS resources files in watch
This change fixes an issue which caused internal virtual inputs to be added to the watch, this cases watchpack to emit a removed event as this file does not exist on disk.

We fix this issue, by prefixing `css-resouces` namespace with `angular:` which the input to be filtered out, see: 4539961968/packages/angular_devkit/build_angular/src/tools/esbuild/bundler-context.ts (L251)

Closes #26918
2024-01-22 15:56:32 +01:00
Alan Agius
f844e98c0e fix(@angular-devkit/build-angular): ENOENT: no such file or directory on Windows during component rebuild
Previously, we `joined` the workspace root with the `outputFile.path`, in windows this caused a problem as during the 2nd rebuild it caused the workspace root to be prepended again which causes a `ENOENT` error. To avoid this problem, now we `clone` the output file.

Closes #26900
2024-01-22 15:56:19 +01:00
Angular Robot
4539961968 build: update all non-major dependencies 2024-01-22 13:28:04 +01:00
Charles Lyding
ebe3afb15b refactor(@angular-devkit/build-angular): move Angular memory Vite plugin into separate file
To reduce the amount of code within the main Vite development server file, the Vite plugin
that handles the in-memory output file integration for the Angular build system is now within
a separate file.
2024-01-22 13:27:37 +01:00
Angular Robot
fffc9e1f7e build: update dependency vite to v5.0.12 [security] 2024-01-19 22:35:53 -05:00
Angular Robot
8eab5aa912 build: update all non-major dependencies 2024-01-18 09:58:07 -05:00
Angular Robot
9c15470511 build: update dependency postcss-loader to v8 2024-01-17 08:46:53 -05:00
Alan Agius
771fdcdc1d fix(@angular-devkit/build-angular): alllow OPTIONS requests to be proxied when using vite
This commit fixes an issue were `OPTIONS` requests were not being proxied when using Vite dev-server

Closes #26782
2024-01-16 14:28:33 +01:00
Charles Lyding
7d1cff0276 refactor(@angular-devkit/build-angular): allow internal Angular compilation control of diagnostic modes
To support generate diagnostics in varying ways, the internal compilation classes
now support a `modes` argument when diagnosing files during a build using the `application` builder.
This is not exposed as an option at this time but can be experimented with a build using the
`NG_BUILD_TYPE_CHECK` environment variable. This environment variable is not considered part of the
public API and may be removed or altered in the future. Its current purpose is to allow profiling
of the type checking diagnostics functionality of the build system.
2024-01-16 08:21:15 -05:00
Angular Robot
898b7504eb build: update dependency sass-loader to v14 2024-01-16 08:20:41 -05:00
Doug Parker
ca431712b2 refactor: add node: prefix to imports of Jest builder 2024-01-16 08:20:01 -05:00
Angular Robot
5fdfa5561d build: update all non-major dependencies 2024-01-16 08:18:45 -05:00
Angular Robot
2b161f2ddc build: update dependency source-map-loader to v5 2024-01-16 09:10:08 +01:00
Charles Lyding
8f47f1e965 feat(@angular-devkit/build-angular): provide default and abbreviated build target support for dev-server and extract-i18n
The `buildTarget` options for both the `dev-server` and `extract-i8n` builders
now have default values that reflect the recommended and new project generated
values. The defaults are as follows where `<current-project>` is the name of the project
where the `dev-server` or `extract-i18n` builder target is located:
* `dev-server` --> `<current-project>:build:development`
* `extract-i18n` --> `<current-project>:build`

Additionally, abbreviated target specifiers are now supported for these
options. This allows target specifiers such as `::production` which would expand
to `<current-project>:build:production` for either builder.
Abbreviated target specifiers are only supported for the `buildTarget` option in
the `dev-server` and `extract-i18n` builders.
2024-01-12 10:58:29 -08:00
Angular Robot
6e691230f0 build: update dependency copy-webpack-plugin to v12 2024-01-11 10:50:23 -08:00
Angular Robot
4b26211ea6 build: update all non-major dependencies 2024-01-11 10:50:09 -08:00
Alan Agius
c49f9abe85 Revert "build: update dependency webpack-dev-middleware to v7" 2024-01-09 19:20:23 +01:00
Angular Robot
7a91323189 build: update all non-major dependencies 2024-01-09 09:42:06 -08:00
Charles Lyding
18a11f503c refactor(@angular-devkit/build-angular): add experimental builder selector extension for dev-server
When using the experimental programmatic API for the development server, the choice of builder used
to execute the actual underlying build can now be chosen via a selector function extension option.
The returned string value must be one of the first-party esbuild-based builders for the Vite-based
development server to be used. All other returned values will cause the Webpack-based development
server to be used. The Vite-based development server currently requires one of those builders to
be used (either `@angular-devkit/build-angular:application` or `@angular-devkit/build-angular:browser-esbuild`).
2024-01-09 09:41:40 -08:00
Angular Robot
cd78e03500 build: update dependency webpack-dev-middleware to v7 2024-01-08 16:33:58 -08:00
Charles Lyding
b18bd20bc8 refactor(@angular-devkit/build-angular): move diagnostic logging out of build execution
The logging of diagnostic (error/warning) messages from the build execution within the
`application` builder has been moved up one level. This allows the actual execution to
focus more on generating a result and leaves the enclosing builder system to handle
notification of the results.
2024-01-08 16:33:39 -08:00
Charles Lyding
2d260eae7c refactor(@angular-devkit/build-angular): move bundler context setup into separate file
To reduce the amount of code within the main `application` builder execution function,
the bundler context setup has been moved into a separate file. This also reduces the
amount of imports within the main execution function's module.
2024-01-08 16:33:39 -08:00
Leosvel Pérez Espinosa
8d56365e7e fix(@angular-devkit/build-angular): fix normalization of the application builder extensions 2024-01-08 16:33:18 -08:00
Charles Lyding
481358618b fix(@angular-devkit/build-angular): show diagnostic messages after build stats
To improve the readability and discoverability of any warnings or errors present
during build, the diagnostic messages will be shown after the build stats are
displayed. For large projects the amount of generated files previously could cause
warnings to scroll off the screen and potentially be missed.
2024-01-05 10:47:50 +01:00
Angular Robot
2ead55d7db build: update all non-major dependencies 2024-01-05 10:38:14 +01:00
Doug Parker
4f53e0f4d8 refactor: remove process.cwd from Web Test Runner builder
Turns out this isn't needed for `application` builder to correctly resolve inputs. Not using `process.cwd` should make this builder a little less brittle for monorepo use cases or when running `ng test` inside a subdirectory.
2024-01-04 14:11:46 +01:00
Angular Robot
3451e9da7c build: update dependency @web/test-runner to ^0.18.0 2024-01-04 11:00:25 +01:00
Doug Parker
bdd4f2c5d8 refactor: log warnings for unsupported options in Web Test Runner
This helps notify users when they are attempting to use an option from Karma which hasn't been implemented yet.
2024-01-03 18:52:58 +01:00
Alan Agius
68dae539ad feat(@angular-devkit/build-angular): initial experimental implementation of @web/test-runner builder
This is a new `@angular-devkit/build-angular:web-test-runner` builder which invokes Web Test Runner to execute unit tests in a real browser.

The implementation calls `application` builder under the hood with some option overrides build the application to a temporary directory and then runs Web Test Runner on the output. This set up is still minimal, but sufficient to run and pass tests in the generated `ng new` application.

The `schema.json` file is directly copied from the `karma` builder, since this is intended to serve as a migration target for users coming from Karma. Most of the options don't actually work yet, which is logged when they are used.

The most interesting part of this change is configuring Jasmine to execute in Web Test Runner. This is done through the `testRunnerHtml` option which allows us to control the HTML page tests are executed on. We use `test_page.html` which very carefully controls the loading process. I opted to make a single `<script type="module">` which dynamic imports all the relevant pieces so the ordering can be directly controlled more easily. This is better than trying to manage multiple `<script>` tags and pass data between them. Ideally everything would be bundled into a single entry point, however this is not feasible due to the way that ordering requirements do not align with typical `import` structure. Jasmine must come before polyfills which must come before the runner which invokes user code. In an ideal world, this ordering relationship would be represented in `import` statements, but this is not practically feasible because Angular CLI doesn't own all the files (`./polyfills.js` is user-defined) and Jasmine's loading must be split into two places so Zone.js can properly patch it.

`jasmine_runner.js` serves the purpose of executing Jasmine tests and reporting their results to Web Test Runner. I tried to write `jasmine_runner.js` in TypeScript and compile it with a `ts_library`. Unfortunately I don't think this is feasible because it needs to import `@web/test-runner-core` at runtime. This dependency has some code generated at runtime in Web Test Runner, meaning we cannot bundle this dependency and must mark it as external and dynamic `import()` the package at runtime. This works fine in native ESM, but compiling with TypeScript outputs CommonJS code by default (and I don't believe our `@build_bazel_rules_nodejs` setup can easily change that), so any `import('@web/test-runner-core')` becomes `require('@web/test-runner-core')` which fails because that package is ESM-only. The `loadEsmModule` trick does work here either because Web Test Runner is applying Node module resolution at serve time, meaning it looks for `import('@web/test-runner-core')` and rewrites it to something like `import('/node_modules/@web/test-runner-core')`. In short, there is no easy syntax which circumvents the TypeScript compiler while also being statically analyzable to Web Test Runner.
2024-01-03 18:52:58 +01:00
Doug Parker
7a8bdee0f6 refactor: update application builder entry points to property treat bare strings as module specifiers
Previously an entry point `foo` would be incorrectly treated as a relative path, which meant it was not possible to use an NPM package as an entry point. This now requires `./foo` for relative paths while `foo` is treated as a module specifier referring to an NPM package called `foo`.
2024-01-03 18:52:58 +01:00
Doug Parker
bffaa773ca refactor: move findTestFiles to a common directory where it can be reused in multiple builders 2024-01-03 18:52:58 +01:00
Angular Robot
a6f3987341 build: update all non-major dependencies 2024-01-03 16:15:34 +01:00
Charles Lyding
5cffd3611b build: add function type annotation for bazel win32 build support
Due to the file structure of Bazel Windows builds, type annotations are
required in certain locations to successfully build the project. Function
return type annotations are generally recommended anyway within the code.
2024-01-03 09:46:56 +01:00
Alan Agius
10eebe9e69 build: update dependency browser-sync to v3
(cherry picked from commit 953780fdce795c9d65f54633f578470cf415858e)
2024-01-02 16:03:22 +01:00
Charles Lyding
c257e6e60e refactor(@angular-devkit/build-angular): support cache option with JavaScript transformer
The previously unused `reuseResults` option for the JavaScript transformer used by the
`application` builder has been removed and replaced with an optional cache option. This
option is currently unused by will allow the caching of JavaScript transformations including
the Angular linker.
2023-12-29 13:04:56 -05:00
Charles Lyding
8786daa2b1 refactor(@angular-devkit/build-angular): create reusable internal cache infrastructure
Several parts of application builder use slightly different variants of an in-memory
cache. To avoid duplication of code, unified cache infrastructure is now available for
use internally. This also allows for expanded use in other areas of the build system
including the future potential for adding additional backing cache stores.
2023-12-29 13:04:56 -05:00
Angular Robot
af43c3472a build: update all non-major dependencies 2023-12-29 12:39:11 +01:00
cexbrayat
bd26a18e7a fix(@angular-devkit/build-angular): typo in preloadInitial option description
The description had different types of quotes.
2023-12-27 12:56:01 -05:00
Alan Agius
116ee78613 refactor: remove unused code from CSS Lexer
This code is no longer used.
2023-12-27 15:05:51 +01:00
Alan Agius
a5f5561ba5 Revert "build: update dependency webpack-dev-middleware to v7"
This reverts commit 6741d2f8710416433a9276c9975f97c5ddb21cb9.
2023-12-27 09:01:22 -05:00
Angular Robot
6741d2f871 build: update dependency webpack-dev-middleware to v7 2023-12-27 09:03:25 +01:00
Alan Agius
49ed9a26cb fix(@angular-devkit/build-angular): emit error when using prerender and app-shell builders with application builder
The application builder has built-in prerendering and app-shell generation capabilities which makes using these builders redundant.
2023-12-26 10:19:00 -05:00
Angular Robot
db87e4f730 build: update all non-major dependencies 2023-12-26 10:16:04 -05:00
Charles Lyding
874e576b52 fix(@angular-devkit/build-angular): filter explicit external dependencies for Vite prebundling
To ensure that Vite does not unintentionally attempt to prebundle a module that was explicitly
marked as external (typically via the `externalDependencies` build option), the full list of
externalized imports is now filtered by the dependencies specified within the external configuration.
Vite currently will include a module for prebundling if it is present in the include list even though
it may also be present in the exclude list.
2023-12-22 08:17:57 +01:00
Angular Robot
1867a0a3cf build: update dependency mrmime to v2 2023-12-21 16:17:22 +01:00
Angular Robot
f167e5445b build: update all non-major dependencies 2023-12-20 19:31:19 +01:00