aws / aws/jsii

Missing support for npm local path dependencies

Open
#4,023 1 comment 0 reactions 0 assignees View on GitHub
feature-request p2
Dominant language
TypeScript
Stars
2.9k
Forks
267
Avg merge
1d 25m
Merged PRs (30d)
14

Description

### Describe the issue

The following POSIX shell script generates 3 JSII projects (A,B,C), where 2 of the projects (B,C) are dependent upon the other project (A). Project B depends upon project A by version reference, project C depends upon project A by local path reference.

```sh

mkdir -p project-a/lib project-b/lib project-c/lib

touch project-a/README.md project-b/README.md project-c/README.md

PROJECT_A_PREFIX=$(tr -dc a-z0-9 project-a/package.json
{
"name": "$PROJECT_A_PREFIX-project-a",
"version": "0.0.0",
"author": "Sample Author",
"description": "Sample Description",
"license": "GPL-3.0-only",
"repository": {
"type": "git",
"url": "about:blank"
},
"type": "module",
"main": "lib/index.js",
"devDependencies": {
"@types/node": "10.17.27",
"constructs": "10.1.285",
"jsii": "^1.71.0",
"typescript": "~4.9.3",
"jsii-pacmak": "^1.71.0"
},
"dependencies": {},
"bundleDependencies": [],
"peerDependencies": {
"constructs": "10.1.285"
},
"types": "lib/index.d.ts",
"stability": "experimental",
"jsii": {
"outdir": "dist",
"targets": {}
}
}
EOF

cat << EOF > project-b/package.json
{
"name": "project-b",
"version": "0.0.0",
"author": "Sample Author",
"description": "Sample Description",
"license": "GPL-3.0-only",
"repository": {
"type": "git",
"url": "about:blank"
},
"main": "lib/index.ts",
"devDependencies": {
"@types/node": "10.17.27",
"jsii": "^1.71.0",
"typescript": "~4.9.3",
"constructs": "10.1.285",
"$PROJECT_A_PREFIX-project-a": "0.0.0",
"jsii-pacmak": "^1.71.0"
},
"dependencies": {
},
"peerDependencies": {
"constructs": "^10.1.285",
"$PROJECT_A_PREFIX-project-a": "0.0.0"
},
"bundleDependencies": [
],
"types": "lib/index.d.ts",
"stability": "experimental",
"jsii": {
"outdir": "dist",
"targets": {}
}
}
EOF

cat << EOF > project-c/package.json
{
"name": "project-c",
"version": "0.0.0",
"author": "Sample Author",
"description": "Sample Description",
"license": "GPL-3.0-only",
"repository": {
"type": "git",
"url": "about:blank"
},
"main": "lib/index.ts",
"devDependencies": {
"@types/node": "10.17.27",
"jsii": "^1.71.0",
"typescript": "~4.9.3",
"constructs": "10.1.285",
"$PROJECT_A_PREFIX-project-a": "file:../project-a",
"jsii-pacmak": "^1.71.0"
},
"dependencies": {},
"peerDependencies": {
"constructs": "^10.1.285",
"$PROJECT_A_PREFIX-project-a": "0.0.0"
},
"bundleDependencies": [
],
"types": "lib/index.d.ts",
"stability": "experimental",
"jsii": {
"outdir": "dist",
"targets": {}
}
}
EOF

cat << EOF > project-a/lib/index.ts
import {
Construct,
IConstruct,
} from 'constructs';

export interface ISampleConstruct extends IConstruct {}

export class SampleConstruct extends Construct implements ISampleConstruct {

constructor(construct: Construct, id: string) {

super(construct, id);
};
}
EOF

cat << EOF > project-b/lib/index.ts
import {Construct} from 'constructs';
import {
SampleConstruct,
ISampleConstruct,
} from '$PROJECT_A_PREFIX-project-a';

export class ChildSampleConstruct extends SampleConstruct implements ISampleConstruct {

constructor(construct: Construct, id: string) {

super(construct, id);
};
}

new ChildSampleConstruct(undefined as unknown as Construct, 'sample');
EOF

cp project-b/lib/index.ts project-c/lib/index.ts

sh -c "cd project-a && npm install && npx jsii && npx jsii-pacmak -v --target js && npm publish"

sh -c "cd project-b && npm install && npx jsii && npx jsii-pacmak -v --target js"

sh -c "cd project-c && npm install && npx jsii && npx jsii-pacmak -v --target js"

```

results in:

```sh



up to date, audited 93 packages in 752ms

12 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
[jsii-pacmak] [INFO] Found 1 modules to package
[jsii-pacmak] [INFO] Packaging NPM bundles
[jsii-pacmak] [INFO] Loading jsii assemblies and translations
[jsii-pacmak] [INFO] Packaging 'js' for 1413x-project-a
[jsii-pacmak] [INFO] js finished
[jsii-pacmak] [INFO] Packaged. npm pack (0.7s) | js (0.0s) | load jsii (0.0s) | cleanup (0.0s)
npm notice
npm notice 📦 1413x-project-a@0.0.0
npm notice === Tarball Contents ===
npm notice 2.8kB .jsii
npm notice 0B README.md
npm notice 247B lib/index.d.ts
npm notice 1.3kB lib/index.js
npm notice 664B package.json
npm notice 38.1kB tsconfig.tsbuildinfo
npm notice === Tarball Details ===
npm notice name: 1413x-project-a
npm notice version: 0.0.0
npm notice filename: 1413x-project-a-0.0.0.tgz
npm notice package size: 7.6 kB
npm notice unpacked size: 43.1 kB
npm notice shasum: 08ac78b1ee97f5b5fe5af6c669d518542fd1c1ca
npm notice integrity: sha512-sw35CNjB/8VmT[...]KT99NTzjWIGMw==
npm notice total files: 6
npm notice
npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access
+ 1413x-project-a@0.0.0
+ 1413x-project-a@0.0.0

added 36 packages, removed 1 package, and audited 94 packages in 3s

12 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
[jsii-pacmak] [INFO] Found 1 modules to package
[jsii-pacmak] [INFO] Updated .npmignore
[jsii-pacmak] [INFO] Packaging NPM bundles
[jsii-pacmak] [INFO] Loading jsii assemblies and translations
[jsii-pacmak] [INFO] Packaging 'js' for project-b
[jsii-pacmak] [INFO] js finished
[jsii-pacmak] [INFO] Packaged. npm pack (0.7s) | js (0.0s) | load jsii (0.0s) | cleanup (0.0s)

added 36 packages, removed 1 package, and audited 94 packages in 2s

12 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
warning JSII6: A "peerDependency" on "1413x-project-a" at "0.0.0" means you should take a "devDependency" on "1413x-project-a" at "0.0.0" (found "file:../project-a")
[jsii-pacmak] [INFO] Found 1 modules to package
[jsii-pacmak] [INFO] Updated .npmignore
[jsii-pacmak] [INFO] Packaging NPM bundles
[jsii-pacmak] [INFO] Loading jsii assemblies and translations
[jsii-pacmak] [INFO] Packaging 'js' for project-b
[jsii-pacmak] [INFO] js finished
[jsii-pacmak] [INFO] Packaged. npm pack (0.7s) | js (0.0s) | load jsii (0.0s) | cleanup (0.0s)
```

The warning indicates, that local paths of dependencies inside `package.json` are currently not supported, whatever that implies.

This has been confusing to me, since i tried fixing it by following the suggestions, which lead upon many iterations of switching the dependency types and running into fatal errors.

It is nice to have the npm local path feature, since it speeds up development across multiple dependent JSII npm packages, but at least a notice about them not being supported, or a more thorough explanation on what is not expected to work would be nice.

### Links

https://aws.github.io/jsii/user-guides/lib-author/configuration/#dependency-considerations
https://docs.npmjs.com/cli/v7/configuring-npm/package-json#local-paths

Contributor guide

Open the contributing guide

Research direction

The reproduction is defined by the package.json files created for project-a, project-b, and project-c; begin by comparing project-b's version dependency with project-c's file:../project-a dependency and run the listed npm install, jsii, and jsii-pacmak commands. Done means the local-path case has explicit supported behavior or a clear diagnostic without the reported packaging failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.