Skip to content

Commit

Permalink
fix(zone.js): add conditional exports to zone.js package (#51652)
Browse files Browse the repository at this point in the history
This is needed to better support native ESM modules and avoid the otherwise necessary deep imports like `zone.js/fesm2015/zone-node.js` due to disallowed directory imports.

PR Close #51652
  • Loading branch information
alan-agius4 authored and thePunderWoman committed Sep 6, 2023
1 parent fe0b793 commit 4798ec4
Show file tree
Hide file tree
Showing 74 changed files with 62 additions and 883 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ yarn_install(
YARN_LABEL,
"//:.yarnrc",
"//tools:postinstall-patches.js",
"//tools/esm-interop:patches/npm/@angular+build-tooling+0.0.0-8d4803573edc70b90a1134ffa996303d1dcc18a9.patch",
"//tools/esm-interop:patches/npm/@angular+build-tooling+0.0.0-0109d498b0f6aae418ed4924a5e5c65695f0ac61.patch",
"//tools/esm-interop:patches/npm/@bazel+concatjs+5.8.1.patch",
"//tools/esm-interop:patches/npm/@bazel+esbuild+5.7.1.patch",
"//tools/esm-interop:patches/npm/@bazel+protractor+5.7.1.patch",
Expand Down
4 changes: 2 additions & 2 deletions integration/cli-elements-universal/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js/dist/zone"
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"aot": true,
Expand Down Expand Up @@ -83,7 +83,7 @@
"options": {
"main": "src/test.ts",
"polyfills": [
"zone.js/dist/zone"
"zone.js"
],
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
Expand Down
2 changes: 1 addition & 1 deletion integration/cli-elements-universal/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
Expand Down
5 changes: 1 addition & 4 deletions integration/injectable-def/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// ZoneJS does not add any package exports right now, so we need to directly
// reference the ESM entry-point for ZoneJS in NodeJS.
// TODO: Replace this with a package import if ZoneJS sets the `exports` field.
import 'zone.js/fesm2015/zone-node.js';
import 'zone.js/node';

// Load the Angular compiler as we will rely on JIT compilation for this test.
// This test does not use the CLI and we are not processing the framework packages
Expand Down
5 changes: 0 additions & 5 deletions packages/zone.js/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,12 @@ pkg_npm(
"CHANGELOG.md",
"README.md",
"package.json",
"//packages/zone.js/mix:package.json",
"//packages/zone.js/node:package.json",
"//packages/zone.js/testing:package.json",
],
visibility = ["//visibility:public"],
deps = [
":LICENSE.wrapped",
":LICENSE_copy",
":zone_externs",
"//packages/zone.js/dist:dist_bundle_group",
"//packages/zone.js/plugins:plugin_bundle_group",
] + [
"//packages/zone.js/bundles:" + b + "-es5.dist"
for b in BUNDLES_ENTRY_POINTS.keys()
Expand Down
125 changes: 0 additions & 125 deletions packages/zone.js/dist/BUILD.bazel

This file was deleted.

71 changes: 0 additions & 71 deletions packages/zone.js/dist/tools.bzl

This file was deleted.

3 changes: 0 additions & 3 deletions packages/zone.js/mix/BUILD.bazel

This file was deleted.

8 changes: 0 additions & 8 deletions packages/zone.js/mix/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages/zone.js/node/BUILD.bazel

This file was deleted.

8 changes: 0 additions & 8 deletions packages/zone.js/node/package.json

This file was deleted.

36 changes: 36 additions & 0 deletions packages/zone.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,41 @@
"license": "MIT",
"bugs": {
"url": "https://github.com/angular/angular/issues"
},
"exports": {
"./package.json": {
"default": "./package.json"
},
".": {
"typings": "./zone.d.ts",
"require": "./bundles/zone.umd.js",
"default": "./fesm2015/zone.js"
},
"./testing": {
"require": "./bundles/zone-testing.umd.js",
"default": "./fesm2015/zone-testing.js"
},
"./node": {
"require": "./bundles/zone-node.umd.js",
"default": "./fesm2015/zone-node.js"
},
"./mix": {
"require": "./bundles/zone-mix.umd.js",
"default": "./fesm2015/zone-mix.js"
},
"./dist/*.min": {
"default": "./bundles/*.umd.min.js"
},
"./dist/*": {
"default": "./bundles/*.umd.js"
},
"./plugins/*.min": {
"require": "./bundles/*.umd.min.js",
"default": "./fesm2015/*.min.js"
},
"./plugins/*": {
"require": "./bundles/*.umd.js",
"default": "./fesm2015/*.js"
}
}
}
63 changes: 0 additions & 63 deletions packages/zone.js/plugins/BUILD.bazel

This file was deleted.

7 changes: 0 additions & 7 deletions packages/zone.js/plugins/async-test.min/package.json

This file was deleted.

Loading

0 comments on commit 4798ec4

Please sign in to comment.