Skip to content
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

Is it possible to bundle for iOS JavascriptCore? #1017

Closed
danielcrisp opened this issue Apr 21, 2021 · 1 comment
Closed

Is it possible to bundle for iOS JavascriptCore? #1017

danielcrisp opened this issue Apr 21, 2021 · 1 comment
Labels
kind: support Asking for support with something or a specific use case solution: already possible This is already possible / this feature already exists

Comments

@danielcrisp
Copy link

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 and document, but it also doesn't have Node globals such as require.

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? #788

Who 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.

@agilgur5
Copy link
Collaborator

agilgur5 commented Apr 21, 2021

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 #179 (comment) .

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.

@agilgur5 agilgur5 added kind: support Asking for support with something or a specific use case solution: already possible This is already possible / this feature already exists labels Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: support Asking for support with something or a specific use case solution: already possible This is already possible / this feature already exists
Projects
None yet
Development

No branches or pull requests

2 participants