Skip to content

Commit e037dc9

Browse files
committed
refactor(@angular-devkit/core): use package exports field for secondary entries
The secondary entry point (`node`) within the `@angular-devkit/core` package is now defined by an exports entry in the main package.json file for the package. This removes the need for the additional nested package.json file in a subdirectory. The exports field also contains backward compatible entries to allow for continued deep imports into the package. These compatibility entries will, however, be removed in a future major version. Deep imported files are not considered part of the public API of the package.
1 parent c032162 commit e037dc9

File tree

6 files changed

+48
-10
lines changed

6 files changed

+48
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## API Report File for "@angular-devkit/core_node_testing"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
/// <reference types="node" />
8+
9+
import * as fs from 'fs';
10+
import { Observable } from 'rxjs';
11+
12+
// @public
13+
export class TempScopedNodeJsSyncHost extends virtualFs.ScopedHost<fs.Stats> {
14+
constructor();
15+
// (undocumented)
16+
get files(): Path[];
17+
// (undocumented)
18+
get root(): Path;
19+
// (undocumented)
20+
protected _root: Path;
21+
// (undocumented)
22+
get sync(): virtualFs.SyncDelegateHost<fs.Stats>;
23+
// (undocumented)
24+
protected _sync?: virtualFs.SyncDelegateHost<fs.Stats>;
25+
}
26+
27+
// (No @packageDocumentation comment for this package)
28+
29+
```

Diff for: packages/angular_devkit/core/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ pkg_npm(
8888
":core",
8989
":license",
9090
"//packages/angular_devkit/core/node",
91-
"//packages/angular_devkit/core/node:package.json",
9291
"//packages/angular_devkit/core/node/testing",
9392
],
9493
)

Diff for: packages/angular_devkit/core/node/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ ts_library(
2020
"**/*_spec.ts",
2121
],
2222
),
23-
data = ["package.json"],
2423
module_name = "@angular-devkit/core/node",
2524
module_root = "index.d.ts",
2625
deps = [

Diff for: packages/angular_devkit/core/node/host_spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
*/
88

99
/* eslint-disable @typescript-eslint/no-non-null-assertion */
10-
/* eslint-disable import/no-extraneous-dependencies */
11-
import { normalize, virtualFs } from '@angular-devkit/core';
12-
import { NodeJsAsyncHost, NodeJsSyncHost } from '@angular-devkit/core/node';
1310
import * as fs from 'fs';
1411
import { tmpdir } from 'os';
1512
import { join } from 'path';
13+
import { normalize, virtualFs } from '../src';
14+
import { NodeJsAsyncHost, NodeJsSyncHost } from './host';
1615

1716
// TODO: replace this with an "it()" macro that's reusable globally.
1817
let linuxOnlyIt: typeof it = it;

Diff for: packages/angular_devkit/core/node/package.json

-5
This file was deleted.

Diff for: packages/angular_devkit/core/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
"keywords": [
88
"core"
99
],
10+
"exports": {
11+
".": {
12+
"types": "./src/index.d.ts",
13+
"default": "./src/index.js"
14+
},
15+
"./node": {
16+
"types": "./node/index.d.ts",
17+
"default": "./node/index.js"
18+
},
19+
"./node/testing": {
20+
"types": "./node/testing/index.d.ts",
21+
"default": "./node/testing/index.js"
22+
},
23+
"./package.json": "./package.json",
24+
"./*": "./*.js",
25+
"./*.js": "./*.js"
26+
},
1027
"dependencies": {
1128
"ajv-formats": "2.1.1",
1229
"ajv": "8.12.0",

0 commit comments

Comments
 (0)