Skip to content

Commit 3eae85d

Browse files
devversionjosephperrott
authored andcommitted
build: add exports entries for Sass module resolution
Adds the `exports` field for module resolution of `@angular/cdk` and `@angular/material` when Sass is requested. Since these packages use the `exports` field already, to prevent deep imports, we also need to expose the Sass entry-points and prebuilt files. The webpack loader requires the `sass` conditional to be set when the CDK or Material modules are loaded without the `includePaths` option. It is worth noting that the Sass webpack loader does not seem to respect the exports field when `@import` is used. Still for consistency and other potential bundlers/loaders, we will expose the `.css` extension subpaths. Also as a side-note: the `.css` extension imports do not work with `@use`, so the non-extension variants are helpful there for backwards compatibility & convenient access.
1 parent 43d4b33 commit 3eae85d

File tree

8 files changed

+218
-160
lines changed

8 files changed

+218
-160
lines changed

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@
5050
},
5151
"version": "13.0.0-next.7",
5252
"dependencies": {
53-
"@angular/animations": "13.0.0-next.12",
54-
"@angular/common": "13.0.0-next.12",
55-
"@angular/compiler": "13.0.0-next.12",
56-
"@angular/core": "13.0.0-next.12",
57-
"@angular/forms": "13.0.0-next.12",
58-
"@angular/platform-browser": "13.0.0-next.12",
53+
"@angular/animations": "13.0.0-next.15",
54+
"@angular/common": "13.0.0-next.15",
55+
"@angular/compiler": "13.0.0-next.15",
56+
"@angular/core": "13.0.0-next.15",
57+
"@angular/forms": "13.0.0-next.15",
58+
"@angular/platform-browser": "13.0.0-next.15",
5959
"@types/google.maps": "^3.45.6",
6060
"@types/youtube": "^0.0.42",
6161
"core-js-bundle": "^3.8.2",
@@ -69,13 +69,13 @@
6969
"@angular-devkit/build-optimizer": "0.1300.0-next.7",
7070
"@angular-devkit/core": "13.0.0-next.7",
7171
"@angular-devkit/schematics": "13.0.0-next.7",
72-
"@angular/bazel": "13.0.0-next.12",
73-
"@angular/compiler-cli": "13.0.0-next.12",
72+
"@angular/bazel": "13.0.0-next.15",
73+
"@angular/compiler-cli": "13.0.0-next.15",
7474
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#e674228281ff6ac4d21779070b090e8a8bde9e69",
75-
"@angular/localize": "13.0.0-next.12",
76-
"@angular/platform-browser-dynamic": "13.0.0-next.12",
77-
"@angular/platform-server": "13.0.0-next.12",
78-
"@angular/router": "13.0.0-next.12",
75+
"@angular/localize": "13.0.0-next.15",
76+
"@angular/platform-browser-dynamic": "13.0.0-next.15",
77+
"@angular/platform-server": "13.0.0-next.15",
78+
"@angular/router": "13.0.0-next.15",
7979
"@axe-core/webdriverjs": "^4.1.0",
8080
"@babel/core": "^7.13.10",
8181
"@babel/traverse": "^7.13.0",

src/cdk/config.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ CDK_TARGETS = ["//src/cdk"] + ["//src/cdk/%s" % ep for ep in CDK_ENTRYPOINTS]
3030
# Within the CDK, only a few targets have sass libraries which need to be
3131
# part of the release package. This list declares all CDK targets with sass
3232
# libraries that need to be included and re-exported at the package root.
33+
# **Note**: When updating the list of CDK entry-points with styles, also update
34+
# the `exports` field in the `cdk/package.json` file.
3335
CDK_ENTRYPOINTS_WITH_STYLES = [
3436
"a11y",
3537
"overlay",

src/cdk/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
"url": "https://github.com/angular/components/issues"
1919
},
2020
"homepage": "https://github.com/angular/components#readme",
21+
"exports": {
22+
".": {
23+
"sass": "./_index.scss"
24+
},
25+
"./a11y-prebuilt.css": {"style": "./a11y-prebuilt.css"},
26+
"./a11y-prebuilt": {"style": "./a11y-prebuilt.css"},
27+
"./overlay-prebuilt.css": {"style": "./overlay-prebuilt.css"},
28+
"./overlay-prebuilt": {"style": "./overlay-prebuilt.css"},
29+
"./text-field-prebuilt.css": {"style": "./text-field-prebuilt.css"},
30+
"./text-field-prebuilt": {"style": "./text-field-prebuilt.css"}
31+
},
2132
"peerDependencies": {
2233
"@angular/core": "0.0.0-NG",
2334
"@angular/common": "0.0.0-NG",

src/material-experimental/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
"url": "https://github.com/angular/components/issues"
1212
},
1313
"homepage": "https://github.com/angular/components#readme",
14+
"exports": {
15+
".": {
16+
"sass": "./_index.scss"
17+
},
18+
"./mdc-theming/prebuilt/indigo-pink.css": {
19+
"style": "./mdc-theming/prebuilt/indigo-pink.css"
20+
},
21+
"./mdc-theming/prebuilt/*": {
22+
"style": "./mdc-theming/prebuilt/*.css"
23+
}
24+
},
1425
"peerDependencies": {
1526
"@angular/core": "0.0.0-NG",
1627
"@angular/material": "0.0.0-PLACEHOLDER",

src/material/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@
1717
"url": "https://github.com/angular/components/issues"
1818
},
1919
"homepage": "https://github.com/angular/components#readme",
20+
"exports": {
21+
".": {
22+
"sass": "./_index.scss"
23+
},
24+
"./theming": {
25+
"sass": "./_theming.scss"
26+
},
27+
"./_theming": {
28+
"sass": "./_theming.scss"
29+
},
30+
"./prebuilt-themes/indigo-pink.css": {
31+
"style": "./prebuilt-themes/indigo-pink.css"
32+
},
33+
"./prebuilt-themes/deeppurple-amber.css": {
34+
"style": "./prebuilt-themes/deeppurple-amber.css"
35+
},
36+
"./prebuilt-themes/pink-bluegrey.css": {
37+
"style": "./prebuilt-themes/pink-bluegrey.css"
38+
},
39+
"./prebuilt-themes/purple-green.css": {
40+
"style": "./prebuilt-themes/purple-green.css"
41+
},
42+
"./prebuilt-themes/*": {
43+
"style": "./prebuilt-themes/*.css"
44+
}
45+
},
2046
"peerDependencies": {
2147
"@angular/animations": "0.0.0-NG",
2248
"@angular/cdk": "0.0.0-PLACEHOLDER",

src/material/prebuilt-themes/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ package(default_visibility = ["//visibility:public"])
44
# package in the right spot. The *right* thing to do would be to move them, but
55
# we would need to update references for Google apps.
66

7+
## **NOTE**: When adding/removing prebuilt themes from here, make sure to update
8+
# the `material/package.json` exports field.
9+
710
genrule(
811
name = "indigo-pink",
912
srcs = ["//src/material/core:theming/prebuilt/indigo-pink.css"],

tools/postinstall/apply-patches.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const chalk = require('chalk');
1414
* Version of the post install patch. Needs to be incremented when
1515
* existing patches or edits have been modified.
1616
*/
17-
const PATCH_VERSION = 11;
17+
const PATCH_VERSION = 13;
1818

1919
/** Path to the project directory. */
2020
const projectDir = path.join(__dirname, '../..');

0 commit comments

Comments
 (0)