You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The RuntimeGlobals is correspondence with one RuntimeModule. It will generate code at the render chunk.
RuntimeRequirements
The set of RuntimeGlobals, it divided into ModuleRuntimeRequirementsChunkRuntimeRequirements, and TreeRuntimeRequirements.
The ModuleRuntimeRequirements is RuntimeGlobals for module runtime, eg __webpack_require__.
The ChunkRuntimeRequirements is RuntimeGlobals for chunk runtime, eg __webpack_require__.l is used load chunk.
The TreeRuntimeRequirements is extract ChunkRuntimeRequirements to Runtime Chunk.
The webpack provides some hooks to add RuntimeRequirements, eg The HotModuleReplacementPlugin will add HotModuleReplacementRuntimeModule and the depend RuntimeGlobals.
Runtime Chunk
Turn on runtime and dependOn options will generate an extra Runtime Chunk which only has runtime code, else the runtime code will inlined entry chunk or async chunk, see here.
The logic of render the normal chunk is different from runtime chunk, see here. The normal chunk is only rendered modules inside the chunk, but the runtime chunk is extra rendered RuntimeModule.
RuntimeSpec
The name of Runtime Chunk, is generated from the runtime and dependOn options. One chunk or module maybe be long as multiply runtime chunk.
Guide-level explanation
EntryDescription
Setting dependOn means the entry points that the current entry point depends on. They must be loaded before this entry point is loaded.
Setting runtime means the name of the runtime chunk. When set, a new runtime chunk will be created. It can be set to false to avoid a new runtime chunk since webpack 5.43.0.
Setting optimization.runtimeChunk to true or 'multiple' adds an additional chunk containing only the runtime to each entrypoint, The value 'single' instead creates a runtime file to be shared for all generated chunks. see doc.
some runtime is inlined by default because the RuntimeGlobals isn't implemented, eg _interop_require and _export_star helpers.
the webpack runtime hooks are not implemented, some plugins depend on it, eg HotModuleReplacementPlugin.
The implementation of runtime chunk generate isn't respect runtime and dependOn option, see here. It must generate one runtime file for all entries and also can't be smaller.
The analyzer excludes runtime.js because the RuntimeModule isn't implemented.
some runtime isn't consistent with webpack.
The new architecture
The architecture is the same as webpack, it is divided into some parts to implement it.
Add module RuntimeGlobals to CodeGenerationResultsRuntimeRequirements, eg _interop_require.
Implement the processRuntimeRequirements hooks to add RuntimeGlobals for RuntimeRequirements.
Implement RuntimePlugin tap hooks to add RuntimeModule.
Refactor the logic of generating chunk.
Turn on runtime and dependOn options to generate single runtime chunk for entrypoint.
Else it will use entry chunk as runtime chunk.
Implement optimization.runtimeChunk to mutate EntryDescription.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Runtime ArchitectureSummary
Motivation
Ensure the rspack runtime architecture is consistent with
webpack.Prior Art
Webpack Runtime
Glossary
RuntimeGlobalsThe expression that provides the module interop or chunk loading and more webpack features.
Please see here to read more.
RuntimeModuleThe
RuntimeGlobalsis correspondence with oneRuntimeModule. It will generate code at the render chunk.RuntimeRequirementsThe set of
RuntimeGlobals, it divided intoModuleRuntimeRequirementsChunkRuntimeRequirements, andTreeRuntimeRequirements.The
ModuleRuntimeRequirementsisRuntimeGlobalsfor module runtime, eg__webpack_require__.The
ChunkRuntimeRequirementsisRuntimeGlobalsfor chunk runtime, eg__webpack_require__.lis used load chunk.The
TreeRuntimeRequirementsis extractChunkRuntimeRequirementstoRuntime Chunk.The webpack provides some hooks to add
RuntimeRequirements, eg TheHotModuleReplacementPluginwill addHotModuleReplacementRuntimeModuleand the dependRuntimeGlobals.Runtime ChunkTurn on
runtimeanddependOnoptions will generate an extraRuntime Chunkwhich only has runtime code, else the runtime code will inlined entry chunk or async chunk, see here.The logic of render the
normal chunkis different fromruntime chunk, see here. Thenormal chunkis only rendered modules inside the chunk, but theruntime chunkis extra renderedRuntimeModule.RuntimeSpecThe name of
Runtime Chunk, is generated from theruntimeanddependOnoptions. One chunk or module maybe be long as multiply runtime chunk.Guide-level explanation
EntryDescriptionSetting
dependOnmeans the entry points that the current entry point depends on. They must be loaded before this entry point is loaded.Setting
runtimemeans the name of the runtime chunk. When set, a new runtime chunk will be created. It can be set to false to avoid a new runtime chunk since webpack 5.43.0.see doc.
optimization.runtimeChunkto true or 'multiple' adds an additional chunk containing only the runtime to each entrypoint, The value 'single' instead creates a runtime file to be shared for all generated chunks. see doc.Reference-level explanation
Current Implementation
some runtime is inlined by default because the
RuntimeGlobalsisn't implemented, eg_interop_requireand_export_starhelpers.the
webpackruntime hooks are not implemented, some plugins depend on it, egHotModuleReplacementPlugin.The implementation of runtime chunk generate isn't respect
runtimeanddependOnoption, see here. It must generate one runtime file for all entries and also can't be smaller.The analyzer excludes
runtime.jsbecause theRuntimeModuleisn't implemented.some runtime isn't consistent with
webpack.The new architecture
The architecture is the same as
webpack, it is divided into some parts to implement it.RuntimeGlobalstoCodeGenerationResultsRuntimeRequirements, eg_interop_require.processRuntimeRequirementshooks to addRuntimeGlobalsforRuntimeRequirements.RuntimePlugintap hooks to addRuntimeModule.runtimeanddependOnoptions to generate singleruntime chunkfor entrypoint.runtime chunk.optimization.runtimeChunkto mutateEntryDescription.webpack.Beta Was this translation helpful? Give feedback.
All reactions