Comments (6)
I believe I got the correct tarball created by npm pack
by inserting the following pre- and post-pack scripts to the @contract-case/case-example-mock-types
package... this isn't super pretty but it gets the job done (and you can substitute with something more elegant, in particular if building on Windows is a concern):
/// 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 prepack
script is run just before npm pack
creates the tarball, and creates a symbolic link to the bundled dependency in the right location, so that npm pack
correctly discovers & bundles it up.
The postpack
script runs just after npm pack
created the tarball, and cleans the node_modules
folder up (including the symlink inside it). This is optional but I don't like to leave cruft behind myself 😅
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",
from jsii.
Per this discussion on slack, this is because jsii uses npm pack
, which doesn't correctly respect workspaces. The linked npm bug above has been open since npm v7.
from jsii.
Yep. I suspect this is definitely because the bundled dependency is not present under crase-example-mock-types/node_modules
and so npm pack
silently omits it. I'm afraid this is a limitation of npm
itself... and not quite a bug in jsii-pacmak
, however I'm trying to see if we can work around the issue to get you out of that pit...
from jsii.
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".
from jsii.
⚠️ COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
from jsii.
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 npm pack
will not bundle dependencies that exist in both places.
For example, yaml
will not be bundled if your package.json
looks like this:
{
"devDependencies": {
"yaml": "^2.1.3"
},
"dependencies": {
"yaml": "^2.1.3"
},
"bundledDependencies": [
"yaml"
]
}
from jsii.
Related Issues (20)
- JSII compiled Python package fails in Python CDK application [ERR_PACKAGE_PATH_NOT_EXPORTED] HOT 1
- String Enum values compile to the key rather than source value HOT 1
- Cannot access Cfn layer of resource class software.amazon.awscdk.Resource$Jsii$Proxy
- structural typing allowed in typescript breaks python users HOT 2
- C#: JSII-Pacmak adds extra }
- Support for local dependencies HOT 3
- Override JavaScript methods HOT 1
- Make Jsii Thread Safe
- JSII Go integration does not render structs with captials in CFN
- Make jsii libraries thread-safe in Java HOT 2
- Python packages from @user/package-name have non-compliant names HOT 2
- jsii does not recognize an IDependable implementation written in Python
- C#: JSII cannot infer type for IDictionary
- .net: error CS1009: Unrecognized escape sequence
- Import of dateutil.parser causing DeprecationWarning on Python 3.12 HOT 2
- JSII9000 Encountered use of module that is not declared in "dependencies" or "peerDependencies" HOT 4
- jsii-pacmak: H5 tags on Markdown files break Python packaging
- Update tsconfig.json to the latest standards HOT 6
- Python class (Interface) is generated out of order HOT 6
- Bundled dependencies in monorepo contain ignored files when using --pack-command
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsii.