Skip to content

Commit ebdd10d

Browse files
authored
fix(jsii): flatten out dependency list (#454)
Stop deeply nesting dependency packages and their dependencies. All dependencies are now flattened to a single transitive dependency closure. This will save a lot of space and processing power in processing the assembly. Make jsii-reflect validate the schema (including the version). It wasn't doing that before!! Fixes #453.
1 parent ae85aa5 commit ebdd10d

File tree

36 files changed

+924
-292
lines changed

36 files changed

+924
-292
lines changed

package.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2-
"private": true,
3-
"license": "Apache-2.0",
4-
"devDependencies": {
5-
"lerna": "^3.13.1",
6-
"nodeunit": "^0.11.3",
7-
"nyc": "^13.3.0",
8-
"tslint": "^5.15.0",
9-
"typescript": "^3.4.2"
10-
}
2+
"private": true,
3+
"license": "Apache-2.0",
4+
"devDependencies": {
5+
"lerna": "^3.13.1",
6+
"nodeunit": "^0.11.3",
7+
"nyc": "^13.3.0",
8+
"tslint": "^5.15.0",
9+
"typescript": "^3.4.2"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/awslabs/jsii.git"
14+
}
1115
}

packages/jsii-calc-base-of-base/lib/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export interface IVeryBaseInterface {
2+
foo(): void;
3+
}
4+
15
export interface VeryBaseProps {
26
readonly foo: Very;
37
}

packages/jsii-calc-base-of-base/test/assembly.jsii

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,40 @@
3939
"sphinx": {}
4040
},
4141
"types": {
42+
"@scope/jsii-calc-base-of-base.IVeryBaseInterface": {
43+
"assembly": "@scope/jsii-calc-base-of-base",
44+
"fqn": "@scope/jsii-calc-base-of-base.IVeryBaseInterface",
45+
"kind": "interface",
46+
"locationInModule": {
47+
"filename": "lib/index.ts",
48+
"line": 1
49+
},
50+
"methods": [
51+
{
52+
"abstract": true,
53+
"locationInModule": {
54+
"filename": "lib/index.ts",
55+
"line": 2
56+
},
57+
"name": "foo"
58+
}
59+
],
60+
"name": "IVeryBaseInterface"
61+
},
4262
"@scope/jsii-calc-base-of-base.Very": {
4363
"assembly": "@scope/jsii-calc-base-of-base",
4464
"fqn": "@scope/jsii-calc-base-of-base.Very",
4565
"initializer": {},
4666
"kind": "class",
4767
"locationInModule": {
4868
"filename": "lib/index.ts",
49-
"line": 5
69+
"line": 9
5070
},
5171
"methods": [
5272
{
5373
"locationInModule": {
5474
"filename": "lib/index.ts",
55-
"line": 6
75+
"line": 10
5676
},
5777
"name": "hey",
5878
"returns": {
@@ -71,7 +91,7 @@
7191
"kind": "interface",
7292
"locationInModule": {
7393
"filename": "lib/index.ts",
74-
"line": 1
94+
"line": 5
7595
},
7696
"name": "VeryBaseProps",
7797
"properties": [
@@ -80,7 +100,7 @@
80100
"immutable": true,
81101
"locationInModule": {
82102
"filename": "lib/index.ts",
83-
"line": 2
103+
"line": 6
84104
},
85105
"name": "foo",
86106
"type": {
@@ -91,5 +111,5 @@
91111
}
92112
},
93113
"version": "0.9.0",
94-
"fingerprint": "1O+di7RZanglLmeCs57JLdO5m98kRnkL4uLPnDbm/z4="
114+
"fingerprint": "ENFUcMchPwpuq+F97Ft6h/qSsOv03zzW/rOn+EpnPkM="
95115
}

packages/jsii-calc-base/lib/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VeryBaseProps } from '@scope/jsii-calc-base-of-base';
1+
import { IVeryBaseInterface, VeryBaseProps } from '@scope/jsii-calc-base-of-base';
22

33
/**
44
* A base class.
@@ -15,3 +15,7 @@ export abstract class Base {
1515
export interface BaseProps extends VeryBaseProps {
1616
readonly bar: string;
1717
}
18+
19+
export interface IBaseInterface extends IVeryBaseInterface {
20+
bar(): void;
21+
}

packages/jsii-calc-base/test/assembly.jsii

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,32 @@
3333
"version": "0.9.0"
3434
}
3535
},
36+
"dependencyClosure": {
37+
"@scope/jsii-calc-base-of-base": {
38+
"targets": {
39+
"dotnet": {
40+
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace",
41+
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId"
42+
},
43+
"java": {
44+
"maven": {
45+
"artifactId": "calculator-base-of-base",
46+
"groupId": "software.amazon.jsii.tests"
47+
},
48+
"package": "software.amazon.jsii.tests.calculator.baseofbase"
49+
},
50+
"js": {
51+
"npm": "@scope/jsii-calc-base-of-base"
52+
},
53+
"python": {
54+
"distName": "scope.jsii-calc-base-of-base",
55+
"module": "scope.jsii_calc_base_of_base"
56+
},
57+
"sphinx": {}
58+
},
59+
"version": "0.9.0"
60+
}
61+
},
3662
"description": "An example direct dependency for jsii-calc.",
3763
"homepage": "https://github.com/awslabs/jsii.git",
3864
"jsiiVersion": "0.9.0",
@@ -124,8 +150,31 @@
124150
}
125151
}
126152
]
153+
},
154+
"@scope/jsii-calc-base.IBaseInterface": {
155+
"assembly": "@scope/jsii-calc-base",
156+
"fqn": "@scope/jsii-calc-base.IBaseInterface",
157+
"interfaces": [
158+
"@scope/jsii-calc-base-of-base.IVeryBaseInterface"
159+
],
160+
"kind": "interface",
161+
"locationInModule": {
162+
"filename": "lib/index.ts",
163+
"line": 19
164+
},
165+
"methods": [
166+
{
167+
"abstract": true,
168+
"locationInModule": {
169+
"filename": "lib/index.ts",
170+
"line": 20
171+
},
172+
"name": "bar"
173+
}
174+
],
175+
"name": "IBaseInterface"
127176
}
128177
},
129178
"version": "0.9.0",
130-
"fingerprint": "iWT7GmFaVPERM/zg8WXtKv7ydudD28ixjJDVfms7DJ4="
179+
"fingerprint": "8qBW6Salzbq8ies06F/P6IebT87rHy8zDsbL8JqBrvI="
131180
}

packages/jsii-calc-lib/lib/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,13 @@ export enum EnumFromScopedModule {
9898
Value1,
9999
Value2
100100
}
101+
102+
/**
103+
* Interface that inherits from packages 2 levels up the tree
104+
*
105+
* Their presence validates that .NET/Java/jsii-reflect can track all fields
106+
* far enough up the tree.
107+
*/
108+
export interface IThreeLevelsInterface extends base.IBaseInterface {
109+
baz(): void;
110+
}

packages/jsii-calc-lib/test/assembly.jsii

Lines changed: 76 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99
},
1010
"dependencies": {
1111
"@scope/jsii-calc-base": {
12-
"dependencies": {
13-
"@scope/jsii-calc-base-of-base": {
14-
"targets": {
15-
"dotnet": {
16-
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace",
17-
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId"
18-
},
19-
"java": {
20-
"maven": {
21-
"artifactId": "calculator-base-of-base",
22-
"groupId": "software.amazon.jsii.tests"
23-
},
24-
"package": "software.amazon.jsii.tests.calculator.baseofbase"
25-
},
26-
"js": {
27-
"npm": "@scope/jsii-calc-base-of-base"
28-
},
29-
"python": {
30-
"distName": "scope.jsii-calc-base-of-base",
31-
"module": "scope.jsii_calc_base_of_base"
32-
},
33-
"sphinx": {}
12+
"targets": {
13+
"dotnet": {
14+
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace",
15+
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BasePackageId"
16+
},
17+
"java": {
18+
"maven": {
19+
"artifactId": "calculator-base",
20+
"groupId": "software.amazon.jsii.tests"
3421
},
35-
"version": "0.9.0"
36-
}
22+
"package": "software.amazon.jsii.tests.calculator.base"
23+
},
24+
"js": {
25+
"npm": "@scope/jsii-calc-base"
26+
},
27+
"python": {
28+
"distName": "scope.jsii-calc-base",
29+
"module": "scope.jsii_calc_base"
30+
},
31+
"sphinx": {}
3732
},
33+
"version": "0.9.0"
34+
}
35+
},
36+
"dependencyClosure": {
37+
"@scope/jsii-calc-base": {
3838
"targets": {
3939
"dotnet": {
4040
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace",
@@ -57,6 +57,30 @@
5757
"sphinx": {}
5858
},
5959
"version": "0.9.0"
60+
},
61+
"@scope/jsii-calc-base-of-base": {
62+
"targets": {
63+
"dotnet": {
64+
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace",
65+
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId"
66+
},
67+
"java": {
68+
"maven": {
69+
"artifactId": "calculator-base-of-base",
70+
"groupId": "software.amazon.jsii.tests"
71+
},
72+
"package": "software.amazon.jsii.tests.calculator.baseofbase"
73+
},
74+
"js": {
75+
"npm": "@scope/jsii-calc-base-of-base"
76+
},
77+
"python": {
78+
"distName": "scope.jsii-calc-base-of-base",
79+
"module": "scope.jsii_calc_base_of_base"
80+
},
81+
"sphinx": {}
82+
},
83+
"version": "0.9.0"
6084
}
6185
},
6286
"description": "A simple calcuator library built on JSII.",
@@ -171,6 +195,33 @@
171195
],
172196
"name": "IFriendly"
173197
},
198+
"@scope/jsii-calc-lib.IThreeLevelsInterface": {
199+
"assembly": "@scope/jsii-calc-lib",
200+
"docs": {
201+
"remarks": "Their presence validates that .NET/Java/jsii-reflect can track all fields\nfar enough up the tree.",
202+
"summary": "Interface that inherits from packages 2 levels up the tree."
203+
},
204+
"fqn": "@scope/jsii-calc-lib.IThreeLevelsInterface",
205+
"interfaces": [
206+
"@scope/jsii-calc-base.IBaseInterface"
207+
],
208+
"kind": "interface",
209+
"locationInModule": {
210+
"filename": "lib/index.ts",
211+
"line": 108
212+
},
213+
"methods": [
214+
{
215+
"abstract": true,
216+
"locationInModule": {
217+
"filename": "lib/index.ts",
218+
"line": 109
219+
},
220+
"name": "baz"
221+
}
222+
],
223+
"name": "IThreeLevelsInterface"
224+
},
174225
"@scope/jsii-calc-lib.MyFirstStruct": {
175226
"assembly": "@scope/jsii-calc-lib",
176227
"datatype": true,
@@ -445,5 +496,5 @@
445496
}
446497
},
447498
"version": "0.9.0",
448-
"fingerprint": "/aA8aq2OBJL26oZOAhZj4Gi1QaKDqfEKQj3ONPxmbBM="
499+
"fingerprint": "bBNOrdlsau3qqxF1iTo055PjEb8RSSExF6rQNNnIwAY="
449500
}

0 commit comments

Comments
 (0)