Skip to content

vite_legacy_javascript_tag execution order inconsistent with vite_javascript_tag #106

Answered by ElMassimo
duprasa asked this question in Q&A
Discussion options

You must be logged in to vote

It seems that when using the module polyfill, the order of System.import calls does not guarantee execution order.

A way to enforce execution order is to leverage the module system.

For example, in your case, create another entrypoint combined_first_and_second.js:

import '~/entrypoints/first_to_run'
import '~/entrypoints/second_to_run'

and then reference this entrypoint in your pages:

<%= vite_javascript_tag "combined_first_and_second" %>
<%= vite_legacy_javascript_tag "combined_first_and_second" %>

If creating a shared entrypoint is not an option because the tags are being rendered in different views or partials, then there's really no guarantee to the execution order given the async na…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ElMassimo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #104 on July 19, 2021 18:52.