Skip to content

Commit e810db9

Browse files
committed
Upgrade deps, use chunkGraph API instead of deprecated getModules()
1 parent 0e7a1b2 commit e810db9

6 files changed

Lines changed: 2163 additions & 4099 deletions

File tree

lib/DrupalLibrariesPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class DrupalLibrariesPlugin {
122122

123123
const promises = []
124124
this.opts.rules.forEach(rule => {
125-
promises.push(rule.decorate(this.opts, metadata))
125+
promises.push(rule.decorate(this.opts, metadata, compilation.chunkGraph))
126126
})
127127

128128
entries[metadata.name] = metadata

lib/rules/AddDrupalRequireDependencies.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module.exports = class AddSyncChunkDependenciesRule extends DrupalLibraryRule {
88
/**
99
* {@inheritdoc}
1010
*/
11-
async decorate(opts, metadata) {
12-
metadata.chunk.getModules().forEach(module => {
11+
async decorate(opts, metadata, chunkGroup) {
12+
chunkGroup.getChunkModules(metadata.chunk).forEach(module => {
1313
module.dependencies.forEach(dependency => {
1414
const result = opts.requirePattern.exec(dependency.request)
1515
if (result && result[1] != metadata.name) {

lib/rules/AddSyncChunkDependenciesRule.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = class AddSyncChunkDependenciesRule extends DrupalLibraryRule {
1111
/**
1212
* {@inheritdoc}
1313
*/
14-
async decorate(opts, metadata) {
15-
(await this._getDependencies(opts, metadata.chunk)).forEach(dependencyName => {
14+
async decorate(opts, metadata, chunkGraph) {
15+
(await this._getDependencies(opts, metadata.chunk, chunkGraph)).forEach(dependencyName => {
1616
metadata.addItem('dependencies', dependencyName)
1717
})
1818
}
@@ -28,10 +28,10 @@ module.exports = class AddSyncChunkDependenciesRule extends DrupalLibraryRule {
2828
* @return {string}
2929
* A list of library dependencies for the webpack chunk.
3030
*/
31-
async _getDependencies(opts, chunk) {
31+
async _getDependencies(opts, chunk, chunkGraph) {
3232
const dependencies = [], promises = []
3333

34-
if (chunk.hasEntryModule()) {
34+
if (chunkGraph.getNumberOfEntryModules(chunk) > 0) {
3535
for (const group of chunk.groupsIterable) {
3636
for (const chunkDependency of group.chunks) {
3737
if (chunkDependency !== chunk) {

lib/rules/DrupalLibraryRule.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ module.exports = class DrupalLibraryRule {
1010
* The options passed to the plugin.
1111
* @param {DrupalLibraryMetadata}
1212
* The metadata object being generated.
13+
* @param {object} chunkGraph
14+
* The chunk graph for the current compilation.
1315
*/
14-
async decorate(opts, metadata) {
16+
async decorate(opts, metadata, chunkGraph) {
1517
/* istanbul ignore next */
1618
throw new Error('unimplemented decorate method')
1719
}

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
],
2222
"dependencies": {
2323
"mkdirp": "^1.0.4",
24-
"yaml": "^1.6.0"
24+
"yaml": "^2.1.3"
2525
},
2626
"devDependencies": {
27-
"coveralls": "^3.0.3",
28-
"css-loader": "^3.0.0",
29-
"jest": "^24.8.0",
30-
"mini-css-extract-plugin": "^0.8.0",
31-
"webpack": "^4.31.0",
32-
"webpack-cli": "^3.3.2"
27+
"coveralls": "^3.1.1",
28+
"css-loader": "^6.7.1",
29+
"jest": "^29.2.2",
30+
"mini-css-extract-plugin": "^2.6.1",
31+
"webpack": "^5.74.0",
32+
"webpack-cli": "^4.10.0"
3333
}
3434
}

0 commit comments

Comments
 (0)