-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSii silently forgets to include bundledDependencies in a monorepo #4132
Comments
Per this discussion on slack, this is because jsii uses |
Yep. I suspect this is definitely because the bundled dependency is not present under |
I believe I got the correct tarball created by /// packages/case-example-mock-types/package.json
{
// ...
"scripts": {
// ...
"prepack": "mkdir -p node_modules/@contract-case && ln -sf ${PWD}/../case-entities node_modules/@contract-case/case-entities-internal",
"postpack": "rm -rf node_modules",
// ...
},
// ...
} The The For convenience, here's the patch: diff --git a/packages/case-example-mock-types/package.json b/packages/case-example-mock-types/package.json
index 1dd6379..ffbe498 100644
--- a/packages/case-example-mock-types/package.json
+++ b/packages/case-example-mock-types/package.json
@@ -23,6 +23,8 @@
"build:docs": "jsii-docgen",
"watch": "jsii -w",
"prepackage": "rimraf dist",
+ "prepack": "mkdir -p node_modules/@contract-case && ln -sf ${PWD}/../case-entities node_modules/@contract-case/case-entities-internal",
+ "postpack": "rm -rf node_modules",
"package": "jsii-pacmak",
"publish:maven": "publib-maven",
"test": "jest", |
I'll close this for now, as this appears to be due to issues or missing features with rpm that we can't really address "in userland". |
|
In case someone is experiencing this issue but are not using workspaces/monorepos, double check that you don't accidentally have your bundled dependency registered as a dev dependency as well. Apparently For example,
|
Describe the bug
When using an npm workspaces, with the following structure:
where
jsii-package/package.json
includes:JSii will not include the package in (at least) the Java bundle.
However, if you copy
jsii-package/
outside the monorepo and runnpm install && npx jsii-pacmak
then it will bundle correctly.Expected Behavior
I expect the generated Java package to include the bundled dependency.
Or, if jsii can't find the dependency at the time it is trying to bundle, I would expect it to fail with an error.
Current Behavior
The generated java package does not include the bundle, but the packaging otherwise appears successful.
This results in broken packages being published, which would result in:
Reproduction Steps
Follow the steps above
Possible Solution
I haven't looked, but I guess that it's expecting the module to be in
node_modules/non-jsii-module
and failing to find it. If this is the case, I think:Additional Information/Context
If you'd like to see this on a real example, the jsii package
@contract-case/case-example-mock-types
suffers from this problem (with the non-jsii dependency@contract-case/case-entities-internal
).To reproduce:
Then you can observe that the java package in
packages/case-example-mock-types/dist/java
does not contain the bundled dependency@contract-case/case-entities-internal
.(sorry I didn't have time to produce a minimal example - I don't think you'll actually need to reproduce it directly. Let me know if a minimal example would make a difference)
Interestingly, I think something resolves the file correctly - because if you do:
then you get:
I believe this is because a clean checkout doesn't have
@contract-case/test-equivalence-matchers
built, so any attempt to resolve its entry point will fail.My guess is that "do I have this module to bundle" is done differently to "ok now I will bundle it". Maybe?
SDK version used
[email protected] with [email protected]
Environment details (OS name and version, etc.)
node 18.13.0, npm 8.19.3, mac os 13.3.1 (a)
The text was updated successfully, but these errors were encountered: