Skip to content

Commit 0dff827

Browse files
authored
build: re-work upgrade-dependencies and refactor pdk to remove depend… (#34)
* build: re-work upgrade-dependencies and refactor pdk to remove dependency on exports
1 parent 7963ea5 commit 0dff827

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+705
-2870
lines changed

.eslintrc.json

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CONTRIBUTING.md

+1-47
Original file line numberDiff line numberDiff line change
@@ -222,50 +222,4 @@ Type 'import(".../aws-pdk/node_modules/aws-prototyping-sdk/node_modules/projen/l
222222
Types have separate declarations of a private property '_patterns'.
223223
```
224224

225-
This means there are two conflicting versions of a package in the monorepo. To resolve this, from the root directory run: `npx projen upgrade-deps`. This will bump all dependencies to be the same/latest versions and update the `yarn.lock` file accordingly.
226-
227-
### Jest import issue
228-
229-
If you run into an issue in Jest when importing from the aws-prototyping-sdk:
230-
231-
```bash
232-
Cannot find module 'aws-prototyping-sdk/pipeline' from 'src/pipeline-stack.ts'
233-
```
234-
235-
Make the following changes:
236-
237-
1. Add a devDependency on `jest-node-exports-resolver`
238-
1. Add a resolver property to jest config, pointing to `jest-node-exports-resolver`
239-
240-
Here is an illustrative example:
241-
242-
```ts
243-
const myProjectWithJestImportErrors = new TypescriptProject({
244-
...,
245-
devDeps: ["jest-node-exports-resolver"],
246-
});
247-
248-
myProjectWithJestImportErrors.jest!.config.resolver = 'jest-node-exports-resolver'; // need this for exports
249-
```
250-
251-
### ESLint `import/no-unresolved` error
252-
253-
If you run into an issue with eslint that resembles the following:
254-
255-
`error Unable to resolve path to module 'aws-prototyping-sdk/pipeline' import/no-unresolved`
256-
257-
This is due to the fact that `aws-prototyping-sdk` is using a relatively new exports feature which is not natively supported by the eslint import resolver.
258-
259-
To fix, add the following to your problematic projects' configuration:
260-
261-
```ts
262-
const myProjectWithEsLintImportErrors = new TypescriptProject({
263-
...,
264-
});
265-
266-
myProjectWithEsLintImportErrors.eslint?.addRules({
267-
"import/no-unresolved": [
268-
"off"
269-
]
270-
});
271-
```
225+
This means there are two conflicting versions of a package in the monorepo. To resolve this, from the root directory run: `npx projen upgrade-deps`. This will bump all dependencies to be the same/latest versions and update the `yarn.lock` file accordingly.

package.json

+24-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/aws-prototyping-sdk/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464
],
6565
"import/no-unresolved": [
66-
"off"
66+
"error"
6767
],
6868
"import/order": [
6969
"warn",

packages/aws-prototyping-sdk/package.json

+31-40
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"devDependencies": {
4040
"@aws-prototyping-sdk/nx-monorepo": "0.0.0",
4141
"@aws-prototyping-sdk/pipeline": "0.0.0",
42-
"@types/jest": "^28.1.0",
42+
"@types/jest": "^28.1.1",
4343
"@types/node": "^14",
4444
"@typescript-eslint/eslint-plugin": "^5",
4545
"@typescript-eslint/parser": "^5",
@@ -53,29 +53,29 @@
5353
"fs-extra": "^10.1.0",
5454
"jest": "^27",
5555
"jest-junit": "^13",
56-
"jsii": "^1.59.0",
57-
"jsii-diff": "^1.59.0",
58-
"jsii-pacmak": "^1.59.0",
56+
"jsii": "^1.60.1",
57+
"jsii-diff": "^1.60.1",
58+
"jsii-pacmak": "^1.60.1",
5959
"json-schema": "^0.4.0",
6060
"license-checker": "^25.0.1",
6161
"npm-check-updates": "^12",
6262
"oss-attribution-generator": "^1.7.1",
63-
"prettier": "^2.6.2",
64-
"projen": "^0.57.1",
63+
"prettier": "^2.7.0",
64+
"projen": "^0.58.15",
6565
"ts-jest": "^27",
66-
"ts-node": "^10.8.0",
67-
"typescript": "^4.7.2"
66+
"ts-node": "^10.8.1",
67+
"typescript": "^4.7.3"
6868
},
6969
"peerDependencies": {
70-
"aws-cdk-lib": "^2.26.0",
71-
"constructs": "^10.1.25",
72-
"projen": "^0.57.1"
70+
"aws-cdk-lib": "^2.28.1",
71+
"constructs": "^10.1.42",
72+
"projen": "^0.58.15"
7373
},
7474
"dependencies": {
75-
"@nrwl/devkit": "^14.1.9",
76-
"aws-cdk-lib": "^2.26.0",
77-
"constructs": "^10.1.25",
78-
"projen": "^0.57.1"
75+
"@nrwl/devkit": "^14.3.5",
76+
"aws-cdk-lib": "^2.28.1",
77+
"constructs": "^10.1.42",
78+
"projen": "^0.58.15"
7979
},
8080
"bundledDependencies": [
8181
"@nrwl/devkit"
@@ -86,7 +86,7 @@
8686
"pdk",
8787
"projen"
8888
],
89-
"main": "lib/index.js",
89+
"main": "./index.js",
9090
"license": "Apache-2.0",
9191
"publishConfig": {
9292
"access": "public"
@@ -132,7 +132,7 @@
132132
}
133133
}
134134
},
135-
"types": "lib/index.d.ts",
135+
"types": "./index.d.ts",
136136
"stability": "stable",
137137
"jsii": {
138138
"outdir": "dist",
@@ -150,44 +150,35 @@
150150
}
151151
},
152152
"tsc": {
153-
"outDir": "./lib",
154-
"rootDir": "./lib"
153+
"outDir": ".",
154+
"rootDir": "."
155155
},
156156
"excludeTypescript": [
157157
"**/samples/**"
158158
]
159159
},
160+
"bundle": {
161+
"exclude": true
162+
},
163+
"exports": {
164+
".": "./index.js",
165+
"./package.json": "./package.json",
166+
"./.jsii": "./.jsii",
167+
"./.warnings.jsii.js": "./.warnings.jsii.js",
168+
"./nx_monorepo": "./nx-monorepo/index.js",
169+
"./pipeline": "./pipeline/index.js"
170+
},
160171
"resolutions": {
161172
"@types/prettier": "2.6.0",
162173
"ansi-regex": "^5.0.1",
163174
"underscore": "^1.12.1",
164175
"deep-extend": "^0.5.1",
176+
"argparse": "^1.0.10",
165177
"debug": "^2.6.9",
166178
"minimist": "^1.2.6",
167179
"ejs": "^3.1.7",
168180
"async": "^2.6.4"
169181
},
170-
"bundle": {
171-
"exclude": true
172-
},
173-
"exports": {
174-
".": "./lib/index.js",
175-
"./package.json": "./package.json",
176-
"./.jsii": "./.jsii",
177-
"./.warnings.jsii.js": "./.warnings.jsii.js",
178-
"./nx_monorepo": "./lib/nx-monorepo/lib/index.js",
179-
"./pipeline": "./lib/pipeline/lib/index.js"
180-
},
181-
"typesVersions": {
182-
"*": {
183-
"nx_monorepo": [
184-
"lib/nx-monorepo/lib/index.d.ts"
185-
],
186-
"pipeline": [
187-
"lib/pipeline/lib/index.d.ts"
188-
]
189-
}
190-
},
191182
"nx": {
192183
"targets": {
193184
"build": {
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/usr/bin/env ts-node
22
export {};
3-
//# sourceMappingURL=bundle.d.ts.map

packages/aws-prototyping-sdk/scripts/bundle.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ async function prepareSourceFiles(libraries: readonly LibraryReference[], packag
209209

210210
const indexStatements = new Array<string>();
211211
for (const library of libraries) {
212-
const libDir = path.join(libRoot, 'lib', library.shortName);
212+
const libDir = path.join(libRoot, library.shortName);
213213
const copied = await transformPackage(library, packageJson, libDir, libraries);
214214

215215
if (!copied) {
@@ -219,7 +219,7 @@ async function prepareSourceFiles(libraries: readonly LibraryReference[], packag
219219
indexStatements.push(`export * as ${library.shortName.replace(/-/g, '_')} from './${library.shortName}';`);
220220
}
221221

222-
await fs.writeFile(path.join(libRoot, 'lib', 'index.ts'), indexStatements.join('\n'), { encoding: 'utf8' });
222+
await fs.writeFile(path.join(libRoot, 'index.ts'), indexStatements.join('\n'), { encoding: 'utf8' });
223223

224224
console.log('\t🍺 Success!');
225225
}

packages/aws-prototyping-sdk/tsconfig.dev.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"strictNullChecks": true,
2323
"strictPropertyInitialization": true,
2424
"stripInternal": true,
25-
"target": "ES2019"
25+
"target": "ES2019",
26+
"outDir": ".",
27+
"rootDir": "."
2628
},
2729
"include": [
2830
".projenrc.js",

packages/identity/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464
],
6565
"import/no-unresolved": [
66-
"off"
66+
"error"
6767
],
6868
"import/order": [
6969
"warn",

0 commit comments

Comments
 (0)