Optimizing "Internal Packages" bundling to prevent dependency nesting #165
JoelBrenstrum
started this conversation in
General
Replies: 1 comment 1 reply
|
I was able to come up with a simple solution that works for us.
Let me know if you think this is a suitable fix. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Bundle Optimization Issue: Internal Packages &
tsdownWe are currently using the Internal Packages strategy, and while the setup is working well, we've identified a bundling issue.
The Issue
When performing a single bundle using
tsdown(wherenoExternalis set for internal packages), the bundler includes all the third-party dependencies of our internal packages directly into the output file.node_modulesduring deployment because they exist in the isolatedpackage.json. However, because they are already baked into the bundle, the application never actually loads them fromnode_modules.node_modules.Attempted Solutions
I experimented with making all third-party dependencies of our internal packages
external. This successfully kept the bundle lean, but introduced a new failure:The app fails at runtime when attempting to import them because they weren't installed in the final container/function environment. Because the dependencies didn't exist in the root
package.json.Requested Outcome
I'm looking for a way to treat internal packages as source (bundle them) while ensuring their third-party dependencies are treated as external and correctly tracked in the deployment
package.json.All reactions