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
-
Runtime Architecture
Summary
Motivation
Ensure the rspack runtime architecture is consistent with
webpack
.Prior Art
Webpack Runtime
Glossary
RuntimeGlobals
The expression that provides the module interop or chunk loading and more webpack features.
Please see here to read more.
RuntimeModule
The
RuntimeGlobals
is correspondence with oneRuntimeModule
. It will generate code at the render chunk.RuntimeRequirements
The set of
RuntimeGlobals
, it divided intoModuleRuntimeRequirements
ChunkRuntimeRequirements
, andTreeRuntimeRequirements
.The
ModuleRuntimeRequirements
isRuntimeGlobals
for module runtime, eg__webpack_require__
.The
ChunkRuntimeRequirements
isRuntimeGlobals
for chunk runtime, eg__webpack_require__.l
is used load chunk.The
TreeRuntimeRequirements
is extractChunkRuntimeRequirements
toRuntime Chunk
.The webpack provides some hooks to add
RuntimeRequirements
, eg TheHotModuleReplacementPlugin
will addHotModuleReplacementRuntimeModule
and the dependRuntimeGlobals
.Runtime Chunk
Turn on
runtime
anddependOn
options will generate an extraRuntime 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 fromruntime chunk
, see here. Thenormal chunk
is only rendered modules inside the chunk, but theruntime chunk
is extra renderedRuntimeModule
.RuntimeSpec
The name of
Runtime Chunk
, is generated from theruntime
anddependOn
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.see doc.
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.Reference-level explanation
Current Implementation
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, egHotModuleReplacementPlugin
.The implementation of runtime chunk generate isn't respect
runtime
anddependOn
option, see here. It must generate one runtime file for all entries and also can't be smaller.The analyzer excludes
runtime.js
because theRuntimeModule
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.RuntimeGlobals
toCodeGenerationResults
RuntimeRequirements
, eg_interop_require
.processRuntimeRequirements
hooks to addRuntimeGlobals
forRuntimeRequirements
.RuntimePlugin
tap hooks to addRuntimeModule
.runtime
anddependOn
options to generate singleruntime chunk
for entrypoint.runtime chunk
.optimization.runtimeChunk
to mutateEntryDescription
.webpack
.Beta Was this translation helpful? Give feedback.
All reactions