Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102036701
NaturalModuleIdsPlugin.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
Sun, Feb 16, 11:13
Size
1 KB
Mime Type
text/x-c++
Expires
Tue, Feb 18, 11:13 (2 d)
Engine
blob
Format
Raw Data
Handle
24256734
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
NaturalModuleIdsPlugin.js
View Options
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Florent Cailhol @ooflorent
*/
"use strict"
;
const
{
compareModulesByPreOrderIndexOrIdentifier
}
=
require
(
"../util/comparators"
);
const
{
assignAscendingModuleIds
}
=
require
(
"./IdHelpers"
);
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Module")} Module */
class
NaturalModuleIdsPlugin
{
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply
(
compiler
)
{
compiler
.
hooks
.
compilation
.
tap
(
"NaturalModuleIdsPlugin"
,
compilation
=>
{
compilation
.
hooks
.
moduleIds
.
tap
(
"NaturalModuleIdsPlugin"
,
modules
=>
{
const
chunkGraph
=
compilation
.
chunkGraph
;
const
modulesInNaturalOrder
=
Array
.
from
(
modules
)
.
filter
(
m
=>
m
.
needId
&&
chunkGraph
.
getNumberOfModuleChunks
(
m
)
>
0
&&
chunkGraph
.
getModuleId
(
m
)
===
null
)
.
sort
(
compareModulesByPreOrderIndexOrIdentifier
(
compilation
.
moduleGraph
)
);
assignAscendingModuleIds
(
modulesInNaturalOrder
,
compilation
);
});
});
}
}
module
.
exports
=
NaturalModuleIdsPlugin
;
Event Timeline
Log In to Comment