Closed danielcrisp closed 3 years ago
but it contains all the dependencies inline (like you would do for a browser bundle).
Is that possible already?
Yes. Bundling or not is independent of your target, you just need to unset the default externals
. You can see an example of this in https://github.com/formium/tsdx/issues/179#issuecomment-605502952 .
That question is UMD-specific, so I check for UMD specifically in that snippet, but it works for any module format.
with one of the existing module formats, but if not perhaps
iife
would work? #788
Per above, externals / bundling deps is also independent of module format. I don't know what format iOS JavaScriptCore supports but you'd want to output to a compatible one.
Current Behavior
I'm trying to bundle my package for use in Apple's iOS JavascriptCore context. This context doesn't have browser globals such as
window
anddocument
, but it also doesn't have Node globals such asrequire
.I'm finding that if I bundle for the browser then, naturally, my underlying dependencies expect things like
document
to be there. And if I bundle for Node, then the result attempts to require or import the dependencies at runtime.Desired Behavior
Perhaps I'm missing a trick here, but I feel like I need to create a sort of hybrid bundle that runs as if it is in Node, but it contains all the dependencies inline (like you would do for a browser bundle).
Is that possible already? Or is there a better solution?
Suggested Solution
Hopefully what I want to achieve is already possible with one of the existing module formats, but if not perhaps
iife
would work? #788Who does this impact? Who is this for?
People, like me, who want to be able to create a package that can be used by both the front end dev team and also the native app dev team.
Describe alternatives you've considered
I've attempted re-bundling the TSDX output with webpack, which seems like it should be unnecessary.
Additional context
Here's my SO question with a bit more detail: https://stackoverflow.com/questions/67193663/how-to-bundle-tsdx-package-for-ios-javascriptcore
The bundle for the React app works great; TSDX made that super easy - thank you.