Commit Graph
25895 Commits
Author SHA1 Message Date
Paul Gschwendtner d2689012bf refactor: update elements test to work with ESM outputs (#48538)
* Uses the `.mjs` ESM output for testing/checking circular dependencies.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 6b8c3e2d63 refactor: update forms package tests to work with ES2020 ESM (#48538)
Tests now always run with ESM 2020, while previously they ran with
ES2015 CommonJS UMD bundles.

Since ZoneJS does not support intercepting native `async/await` syntax,
the forms test needs to use the zone-compatible variant of
`jasmine_node_tests`. This variant downlevels the native `async/await`
syntax to generators that ZoneJS can intercept. All of this is done
using the dev-infra ESBuild `spec_bundle` rule.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 61d2eacf79 refactor: update upgrade package tests to work with ESM output (#48538)
* Uses the `.mjs` output of the upgrade package when checking for
  circular deps.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 4fce3e3a02 refactor: update platform-browser-dynamic to work with ESM output (#48538)
* Switches circular dependency tests to use the `.mjs` output.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner b6424ac3c5 refactor: update platform-server tests to work with ESM (#48538)
* Uses `.mjs` for circular deps tests
* Replaces `require` with ESM-equivalent. uses an import statement here
  for proper typing, and specify dependency properly.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner ab4b5c8b0e refactor: update packages/localize to be strict ESM (#48538)
The `packages/localize` package still required some trickery
to support CommonJS because tests in the repo were running as CommonJS.

This commit removes the CommonJS logic in localize and its tests, so
that only ESM is used in production & tests.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner def64a3d57 build: bundle tests for protractor tests to support ESM output (#48538)
Protractor does not support ESM, so we need to take all the ESM
output and bundle it into a CommonJS file. This comes at the cost
of not using actual ESM for execution, but the ESBuild bundle follows
strict ESM semantics so we can be sure it's compatible when we have
an ESM-compatible e2e test runner in the future.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 2597e3b7ff build: add missing dependencies to platform-server and tools/testing (#48538)
There are two build targets which never had all its runtime dependencies
properly specified. This wasn't noticed because there were macros in
`defaults.bzl` that automatically included these deps.

In a follow-up we will clean-up this legacy auto-deps feature in
`defaults.bzl`.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner cca335dc40 refactor: update packages/router tests to be compatible with ESM (#48538)
The ESM js files need to be referenced, and the router tests rely
on `async/await` with change detection- so a special rule is required
that downlevels `async/await` to generators (similar to the Angular CLI)

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 9b0a7e2d7d build: introduce zone_compatible_jasmine_node_test rule (#48538)
Introduces a variant of `jasmine_node_test` that works with async/await
in combination with ZoneJS. This is needed for tests relying on
async/await in combinatin with change detection.

Browser tests are already benefting from ESbuild async-await
downleveling. Node tests would ideally not need this, but until
ZoneJS supports native async/await we need to also process
source files to avoid native async/await syntax.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 4f156fb6da refactor: update image-directive e2e test to work with ESM (#48538)
* Switches to the canonical dev-infra http server
* Uses the bundle for serving.
* Switches app_bundle to simple `esbuild` since the test relies
  on `ngDevMode` which `app_bundle` elides as optimization.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 0787f0131a refactor: update platform-browser tests to run as ESM (#48538)
`platform-browser` tests now run in ESM and with `.mjs` output, so
the build targets and tests need to be updated.

Here we change the `zone_event_unpatched` script to include the
`.init` suffix that will be picked up by `spec_bundle`.

Also some circular dependency tests are updated to refer to the
`.mjs` files.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 260faaf912 refactor: update compiler-cli to work with ESM (#48538)
Updates compiler-cli & tests to be full ESM compatible. Tests
no longer with CommonJS.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner ef2de133a3 refactor: change ngcc to only rely on ESM features (#48538)
Refactors ngcc to only rely on ESM features because CJS
is no longer needed & tested.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner f25d71498d refactor: update compiler-cli babel linker to be ESM only (#48538)
Since the linker is no longer being tested with CommonJS, we can remove
most of the CJS/ESM interop trickery.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner e8783286af build: refactor packages/compiler/test to work with ESM (#48538)
Switches the circular deps test to use the ESM output. The
normal `.js` devmode output is no longer available.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner ea6d21ec71 build: update packages/bazel/test to work with ESM (#48538)
The bazel tests cannot use CommonJS features like `require` and should
be updated to work with ESM. Additionally some specs are updated to
no longer assert CJS/UMD output from `ng_module`. The rule only emits
ESM now.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner d53b456d8c refactor: update packages/common tests to work with ESM pipeline (#48538)
We no longer have generated `.js` files as everything generated
is the ESM `.mjs` output. The tests need to be updated to reflect that.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 091a7b5715 refactor: update animations tests to work with ESM output (#48538)
The circular deps tests should use the `.mjs` output.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 8499bfcfa5 build: update angular-in-memory-web-api to work with ESM (#48538)
Properly imports `jasmine-ajax` instead of attempting to load
some CommonJS bundle as a bootstrap dependency in Karma.

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner 3a6a568113 build: override schematics to be built and tested using CommonJS (#48538)
The Angular CLI does not yet support schematics running as ESM. For
this reason we switch the schematics BUILD targets to explicitly
use ESM (as an exception in the repo).

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner 3922443827 build: bundle tests for karma web test suites (#48538)
Since Karma with Bazel does not support ESM natively, we bundle the
tests using ESBuild into a single AMD file. This not only solves the
ESM issue until we can run browser ESM tests natively (also pending
in the components repo - the esbuild generation follows ESM semantics
but since collapsed we don't rely on the real module system).

A benefit of bundling is also faster and more reliable Karma browser
tests since only a single file needs to be loaded- compared to hundreds
of individual files.

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner 008fe464e4 test: refactor render3 definition feature test to be less sensitive to JS output (#48538)
If tests are bundled using e.g. esbuild, the `ee` symbols may
be rewritten to `\u0275\u0275`. This breaks assertions that
rely on `Function.toString`. We can avoid this string comparison
and make it more future proof by just comparing the symbols directly.

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner b055818419 build: update dev-infra build tooling to leverage recent ESM changes (#48538)
Update dev-infra's build-tooling since multiple ESM changes have
landed there. e.g. not relying on `require.main === module` for API
bundling. This will allow us to also execute all dev-infra rules
in ESM because we plan on applying our ESM patching to `ts_library`
(which would also affect build-tooling then).

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner fc96316039 test: refactor core bundling tests to work with ESM (#48538)
Switches all `core/test/bundling` tests to not rely on
CommonJS-specific features like `require.resolve

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner 7e07f333c3 refactor: update symbol extractor test tool to work with ESM (#48538)
The symbol extractor test tool now runs with ESM too. This commit
makes it ESM compatible.

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner abad407474 build: support esbuild configurations using ESM dependencies (#48538)
We use `bazel/esbuild` in various places (e.g. for app bundling tests).
These tests rely on the Angular Compiler-CLI itself for e.g. linking
or the Terser configuration. Since everything in this repo is now
strict ESM, the ESBuild configs (which are already ESM-supported)
need to import from `//packages/compiler-cli`. We also need to be
able to leverage our existing ESM Bazel loader for this though as
otherwise resolution would fail.

Long-term we can remove this if everything in the compiler-cli
would use `.mjs` extensions and the import paths would also specify
an explicit extension. See: https://nodejs.org/api/esm.html#mandatory-file-extensions

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner 3ef7d89e2f build: update esm nodejs loader to properly handle subpaths (#48538)
The ESM loader when used with patched Bazel module resolution
handled subpaths incorrectly. e.g.
`@bazel/concatjs/tsc_wrapped/internal/index.js` could be incorrectly
resolved to `@bazel/concatjs/index.js`.

This commit fixes the flawed logic. Also we prioritize the ESM attempts
before the original specifier. This is necessary because otherwise
the default Node resolution (using `require.resolve`) may incorrectly
prefer the `index.js` file over a `index.mjs` when a directory is
imported.

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner fd8344a333 refactor: adjust packages/core/test to work with ESM (#48538)
The `packages/core/test` test code was relying on non-ESM
compatible features like untyped `require` calls.

We switch these to ESM `import` statements/expressions and
make it strongly typed. It's a trade-off between type-safety
and the dependency graph- but it feels more reasonable typing
this properly to actually benefit from the type system provided
by using TypeScript.

Additionally, we align the IDE tsconfigs to use `esnext` as module
because that is what we use in Bazel and it allows us to use
top-level await.

PR Close #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner 92da3aae2c refactor(platform-server): use proper ESM-compatible import to domino (#48538)
Now that everything runs from within ESM, we need to use the proper
default-import variant to be able to load `domino` from ESM.

PR Close #48538
2022-12-19 20:12:35 +00:00