-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cjs
More file actions
29 lines (23 loc) · 1.05 KB
/
test.cjs
File metadata and controls
29 lines (23 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require("fs");
const path = require("path");
const packageJson = require("../package.json");
// A list of entry points from `package.json`: `['angular-material.js', 'angular-badge.js', ...]`.
const declaredEntryPoints = Object.values(packageJson.exports)
.map(({ es2022 }) => es2022)
.map((file) => path.parse(file).base);
// A list of built entry points in the `es2022` folder.
const builtEntryPoints = fs
.readdirSync(path.join(process.cwd(), "es2022"))
.filter((file) => !file.includes(".min.js") && !file.includes(".map"));
// This simple test basically ensures there's no difference between `@angular/material` entry points
// and `angular__material` entry points. This is used to ensure that we also add an entry point
// to `exports` when the Material team adds new entry point on their side.
const difference = builtEntryPoints.filter(
(entryPoint) => !declaredEntryPoints.includes(entryPoint),
);
if (difference.length > 0) {
console.error(
"There is a difference between `exports` and built entry points.",
);
process.exit(1);
}