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

Dynamically adding languages at runtime #36

Open
NullVoxPopuli opened this issue Nov 3, 2019 · 5 comments
Open

Dynamically adding languages at runtime #36

NullVoxPopuli opened this issue Nov 3, 2019 · 5 comments

Comments

@NullVoxPopuli
Copy link
Contributor

I'm trying to do this in emberclear.io, without ember-prism, but it's been tricky enough where I think once I figure it out, it should be pulled in to here.

The reasoning behind being able to dynamically load languages at runtime is to cut down on bundle size. Right now, the ember-prism config is static.
Prism is large, (esp when compared to the total size of small apps). So, being able to omit everything Prism for the initial load is greatly desireable, and then once code renders that needs prism, it could fetch the deps.
Also, for editor purposes (imagine slack's code snippet modal), having the list of languages selectable, but not always loaded would benefit load/parse performance as well.

@RobbieTheWagner
Copy link
Member

Totally open to this 👍

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Jun 20, 2020

I have this implemented in emberclear:

what are thoughts on this approach?
the downside is that it copies all prism assets into your dist directory but, has ~1KB impact on your initially served assets (due to only being a service)

With that approach, we could get rid of the config options as well (aside from maybe theme?)

@RobbieTheWagner
Copy link
Member

@NullVoxPopuli I think we should try to keep the config static, and keep the things you don't want out of dist, while also dynamically loading the things you do want when the time is right. I think that way we can get the best of both worlds.

@NullVoxPopuli
Copy link
Contributor Author

what's the advantage of keeping additional files out of dist?

@RobbieTheWagner
Copy link
Member

what's the advantage of keeping additional files out of dist?

Just to not have extra stuff in it. I suppose it's no big deal, but just don't like putting unnecessary things in the bundle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants