fix: add entry startup to fix async script chunk loading #2966
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.
Related issue (if exists)
close #2775
Summary
🤖 Generated by Copilot at d86865c
This pull request adds a new library plugin for exporting properties, improves the code generation and performance of the JavaScript and runtime plugins, and fixes the async script chunk loading issue. It also refactors some code, updates some imports, and adds a changeset file.
Walkthrough
🤖 Generated by Copilot at d86865c
render_bootstrap
function in therspack_binding_options
crate to include the new plugin for theumd
,umd2
,amd
, andamd-require
library types (link, link)source
, to theRenderStartupArgs
struct in therspack_core
crate to pass the startup code generated by the previous plugins to the next plugins (link, link, link, link, link, link)render_startup
function in theplugin_driver.rs
file in therspack_core
crate to clone and pass the source code to each plugin and return the final source code (link)ENTRY_MODULE_ID
, to theruntime_globals.rs
file in therspack_core
crate to store the module id of the entry module of a chunk (link)get_runtime_global
function in theruntime_globals.rs
file in therspack_core
crate to handle the case of theENTRY_MODULE_ID
constant and return the corresponding code (link)generate_chunk_entry_code
function from theruntime.rs
file in therspack_plugin_javascript
crate, as it is replaced by thegenerate_entry_startup
function in thehelpers.rs
file in therspack_plugin_runtime
crate (link)render_bootstrap
function in theplugin.rs
file in therspack_plugin_javascript
crate into two parts, one that returns the header code and one that returns the startup code, and add a parameter,chunk_ukey
, to the function (link, link)render_bootstrap
function in theplugin.rs
file in therspack_plugin_javascript
crate, and add a condition to check if theINTERCEPT_MODULE_EXECUTION
runtime requirement is present (link)generate_chunk_entry_code
function with a call to thegenerate_entry_startup
function in therender_chunk
function in theplugin.rs
file in therspack_plugin_javascript
crate, and pass the startup code to therender_startup
hook of the plugins (link)RETURN_EXPORTS_FROM_RUNTIME
runtime requirement is present in therender_chunk
function in theplugin.rs
file in therspack_plugin_javascript
crate, and move the code for returning the exports to the end of the function (link)RenderStartupArgs
struct to the output source in therender_startup
function in theassign_library_plugin.rs
andmodule_library_plugin.rs
files in therspack_plugin_library
crate, so that the plugins can preserve the startup code generated by the previous plugins (link, link)OnChunkLoadedRuntimeModule
to the chunk if theON_CHUNKS_LOADED
runtime requirement is present in theapply
function in thebasic_runtime_requirements.rs
file in therspack_plugin_runtime
crate (link)OnChunkLoadedRuntimeModule
to the chunk from theapply
function in thelib.rs
file in therspack_plugin_runtime
crate, as it is handled by thebasic_runtime_requirements.rs
file (link)get_runtime_chunk_path
function with a call to theget_relative_path
function in therender_chunk
function in thecommon_js_chunk_format.rs
andmodule_chunk_format.rs
files in therspack_plugin_runtime
crate, and add a new variable,base_chunk_output_name
, to store the output name of the base chunk (link, link, link)get_runtime_chunk_path
function toget_runtime_chunk_output_name
in thehelpers.rs
file in therspack_plugin_runtime
crate, and remove the./
prefix from the output name (link)render
method of thechunk_filename
field of the output options with a call to theget_chunk_output_name
function in theget_runtime_chunk_output_name
function in thehelpers.rs
file in therspack_plugin_runtime
crate, and add theget_chunk_output_name
function to the same file (link)exclude_chunk2
parameter from a reference to aChunkUkey
to an option of a reference to aChunkUkey
in theget_all_chunks
function in thehelpers.rs
file in therspack_plugin_runtime
crate, and add a condition to check if the parameter isSome
(link, link, link)stringify_chunks_to_array
andstringify_array
functions from theutils.rs
file in therspack_plugin_runtime
crate to theruntime.rs
file in therspack_plugin_javascript
crate, as they are more related to the JavaScript plugin than the runtime plugin (link, link, link)stringify_chunks
function from theutils.rs
file in therspack_plugin_runtime
crate to themod.rs
file in the same crate, as it is more related to the runtime plugin than the JavaScript plugin (link).changeset
folder, which is used by thechangesets
tool to generate changelogs and version bumps for the packages in the repository (link)