Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default
javascript_include_tag
added toapplication.html.erb
hastype='text/javascript'
, which can cause problems when the bundler output is in ESM format. If the bundler outputs ESM code, we need to import it withtype="module"
. Otherwise the module varibles end up in the global scope. See hotwired/turbo#1077This is especially problematic for bun.js, because bun can only emit
ESM
code at the moment.This PR updates the install generator to add the
type="module"
attribute to the defaultjavascript_include_tag
.defer
is no longer needed, as JS modules are deferred by default.Ref. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#other_differences_between_modules_and_standard_scripts
This PR also updates the default config to ensure that all bundlers output ESM bundles.
--format=esm
flag https://esbuild.github.io/api/#format-esmoutput.chunkFormat
https://webpack.js.org/configuration/output/#outputchunkformatoutput.format
https://rollupjs.org/configuration-options/#output-format