Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102318681
StartupChunkDependenciesPlugin.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 19, 11:16
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Feb 21, 11:16 (2 d)
Engine
blob
Format
Raw Data
Handle
24327753
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
StartupChunkDependenciesPlugin.js
View Options
/*
MIT License http://www.opensource.org/licenses/mit-license.php
*/
"use strict"
;
const
RuntimeGlobals
=
require
(
"../RuntimeGlobals"
);
const
StartupChunkDependenciesRuntimeModule
=
require
(
"./StartupChunkDependenciesRuntimeModule"
);
const
StartupEntrypointRuntimeModule
=
require
(
"./StartupEntrypointRuntimeModule"
);
/** @typedef {import("../Compiler")} Compiler */
class
StartupChunkDependenciesPlugin
{
constructor
(
options
)
{
this
.
chunkLoading
=
options
.
chunkLoading
;
this
.
asyncChunkLoading
=
typeof
options
.
asyncChunkLoading
===
"boolean"
?
options
.
asyncChunkLoading
:
true
;
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply
(
compiler
)
{
compiler
.
hooks
.
thisCompilation
.
tap
(
"StartupChunkDependenciesPlugin"
,
compilation
=>
{
const
globalChunkLoading
=
compilation
.
outputOptions
.
chunkLoading
;
const
isEnabledForChunk
=
chunk
=>
{
const
options
=
chunk
.
getEntryOptions
();
const
chunkLoading
=
(
options
&&
options
.
chunkLoading
)
||
globalChunkLoading
;
return
chunkLoading
===
this
.
chunkLoading
;
};
compilation
.
hooks
.
additionalTreeRuntimeRequirements
.
tap
(
"StartupChunkDependenciesPlugin"
,
(
chunk
,
set
)
=>
{
if
(
!
isEnabledForChunk
(
chunk
))
return
;
if
(
compilation
.
chunkGraph
.
hasChunkEntryDependentChunks
(
chunk
))
{
set
.
add
(
RuntimeGlobals
.
startup
);
set
.
add
(
RuntimeGlobals
.
ensureChunk
);
set
.
add
(
RuntimeGlobals
.
ensureChunkIncludeEntries
);
compilation
.
addRuntimeModule
(
chunk
,
new
StartupChunkDependenciesRuntimeModule
(
this
.
asyncChunkLoading
)
);
}
}
);
compilation
.
hooks
.
runtimeRequirementInTree
.
for
(
RuntimeGlobals
.
startupEntrypoint
)
.
tap
(
"StartupChunkDependenciesPlugin"
,
(
chunk
,
set
)
=>
{
if
(
!
isEnabledForChunk
(
chunk
))
return
;
set
.
add
(
RuntimeGlobals
.
ensureChunk
);
set
.
add
(
RuntimeGlobals
.
ensureChunkIncludeEntries
);
compilation
.
addRuntimeModule
(
chunk
,
new
StartupEntrypointRuntimeModule
(
this
.
asyncChunkLoading
)
);
});
}
);
}
}
module
.
exports
=
StartupChunkDependenciesPlugin
;
Event Timeline
Log In to Comment