aws / jsii

jsii allows code in any language to naturally interact with JavaScript classes. It is the technology that enables the AWS Cloud Development Kit to deliver polyglot libraries from a single codebase!
https://aws.github.io/jsii
Apache License 2.0
2.63k stars 244 forks source link

Support for local dependencies #4300

Open jeromevdl opened 11 months ago

jeromevdl commented 11 months ago

Describe the feature

Would be great to support local dependencies (with file:)

Use Case

My CDK library is used by another one. Both are in the same project and it makes no sense to release the dependency in order to work with the dependant (faster development cycle).

Proposed Solution

Verify if the dependency is a file or folder and do not fail if this is the case.

Other Information

Hi, I have a lerna project with 2 AwsCdkConstructLibrary projen projects (let's say foo & bar).

bar is depending on foo. I tried the following in bar:

deps: [
    'foo@file:../foo',
],

but it fails with jsii and the error:

Declared dependency on version file:../foo of foo, but version 0.0.0 was found
  at DependencyResolver.discoverDependencyTree (...node_modules/jsii/lib/project-info.js:161:23)
  at loadProjectInfo (...node_modules/jsii/lib/project-info.js:50:31)
  ...

I also tried to use the tgz in the dist of foo, but had the error (plus it's not easy to have the foo project built before bar install):

Error: ENOTDIR: not a directory, open '.../dist/js/foo@0.0.0.tgz/package.json'
  at _resolveVersion (...node_modules/jsii/lib/project-info.js:312:36)
  at DependencyResolver.resolveDependency (...node_modules/jsii/lib/project-info.js:188:58)

Acknowledgements

CDK version used

2.94.0

Environment details (OS name and version, etc.)

mac os 13.5.2, node 20.8.0, jsii ~5.2.16

gocapa commented 7 months ago

Any updates?

Thanks.

cloudkitect commented 7 months ago

This is a much needed feature, else the development cycle becomes tedious.

gadams999 commented 6 months ago

There is a PR that should fix this by changing the @ to a - in the filename. I've tested by having projen create a package file for the dependency, renaming by changing the @ sign, then including in the main project by adding a dependency (dep) of "dep-pkg-name@file:/path/to/dep-pkg-name-0.0.0.jsii.tgz and then running npx projen && npx projen install.

Support for the PR would be appreciated to get this in front of the JSII maintainers.

jregistr commented 3 weeks ago

I get this error too when trying to use a version I published to private registry:

[ERROR] Declared dependency on version ^2.160.2 of aws-cdk-lib, but version 0.0.0 was found

Is there any quick work around for this?