Giter VIP home page Giter VIP logo

Comments (6)

RomainMuller avatar RomainMuller commented on August 24, 2024 1

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.

TimothyJones avatar TimothyJones commented on August 24, 2024

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.

RomainMuller avatar RomainMuller commented on August 24, 2024

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.

RomainMuller avatar RomainMuller commented on August 24, 2024

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.

github-actions avatar github-actions commented on August 24, 2024

⚠️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.

icj217 avatar icj217 commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.