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

Javascript compiler for ESM chunks #49

Closed
wants to merge 1 commit into from
Closed

Conversation

brenogazzola
Copy link
Collaborator

Closes #48

@navidemad Could you test this one please? Also, I haven't started using ESM modules yet, so I'm not too familiar with chunking, but it seems that a pure import('file.js') is also possible instead of import {} from 'file.js'?

@navidemad
Copy link

Could you test this one please?
✅ Yes it is working fine with this pull request, thanks for the quick PR 🔥

It seems that a pure import('file.js') is also possible instead of import {} from 'file.js' ?
Yes but there is some more complicated format as you can see here :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

@brenogazzola
Copy link
Collaborator Author

Updated so it also handles import 'chunk' and import('chunk')

@dhh
Copy link
Member

dhh commented Dec 14, 2021

Should we extend this to deal with images and styles as well? Since those can also be imported?

But also, need to deal with compatibility with import maps. Where you don't want to rewrite.

@brenogazzola
Copy link
Collaborator Author

brenogazzola commented Dec 15, 2021

Importing CSS and images through javascript means the page can’t render before JS executes, making it feel slower. Not supporting it out-of-the-box but allowing devs to add support through their own compiler feels like a good compromise and reduces our maintenance burden.

I’ll take a look at how this behaves with import maps and see what needs changing.

@navidemad
Copy link

Any update on this PR ? 💯
Merry Xmas 🥇

@brenogazzola
Copy link
Collaborator Author

Closed in favor of #55. An example of the esbuild configuration needed can be seem in #48

@brenogazzola brenogazzola deleted the jscompiler branch December 28, 2021 14:41
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

Successfully merging this pull request may close these issues.

Propshaft ESM Modules chunks not resolved correctly (works with sprockets-rails)
3 participants