Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101801830
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
Thu, Feb 13, 20:42
Size
2 KB
Mime Type
text/x-c++
Expires
Sat, Feb 15, 20:42 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24233996
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