22 * External dependencies
33 */
44const path = require ( 'path' ) ;
5- const webpack = require ( 'webpack' ) ;
65const json2php = require ( 'json2php' ) ;
7- const { createHash } = webpack . util ;
86
97/**
108 * Internal dependencies
@@ -15,9 +13,6 @@ const {
1513 defaultRequestToHandle,
1614} = require ( './util' ) ;
1715
18- const { RawSource } = webpack . sources ;
19- const { AsyncDependenciesBlock } = webpack ;
20-
2116const defaultExternalizedReportFileName = 'externalized-dependencies.json' ;
2217
2318class DependencyExtractionWebpackPlugin {
@@ -147,12 +142,13 @@ class DependencyExtractionWebpackPlugin {
147142 /** @type {webpack.WebpackPluginInstance['apply'] } */
148143 apply ( compiler ) {
149144 this . useModules = Boolean ( compiler . options . output ?. module ) ;
145+ const { webpack } = compiler ;
150146
151147 /**
152148 * Offload externalization work to the ExternalsPlugin.
153149 * @type {webpack.ExternalsPlugin }
154150 */
155- this . externalsPlugin = new compiler . webpack . ExternalsPlugin (
151+ this . externalsPlugin = new webpack . ExternalsPlugin (
156152 this . useModules ? 'import' : 'window' ,
157153 this . externalizeWpDeps . bind ( this )
158154 ) ;
@@ -165,16 +161,15 @@ class DependencyExtractionWebpackPlugin {
165161 compilation . hooks . processAssets . tap (
166162 {
167163 name : this . constructor . name ,
168- stage : compiler . webpack . Compilation
164+ stage : webpack . Compilation
169165 . PROCESS_ASSETS_STAGE_OPTIMIZE_COMPATIBILITY ,
170166 } ,
171167 ( ) => this . checkForMagicComments ( compilation )
172168 ) ;
173169 compilation . hooks . processAssets . tap (
174170 {
175171 name : this . constructor . name ,
176- stage : compiler . webpack . Compilation
177- . PROCESS_ASSETS_STAGE_ANALYSE ,
172+ stage : webpack . Compilation . PROCESS_ASSETS_STAGE_ANALYSE ,
178173 } ,
179174 ( ) => this . addAssets ( compilation )
180175 ) ;
@@ -247,6 +242,10 @@ class DependencyExtractionWebpackPlugin {
247242 outputFilename,
248243 } = this . options ;
249244
245+ const { webpack } = compilation . compiler ;
246+ const { RawSource } = webpack . sources ;
247+ const { createHash } = webpack . util ;
248+
250249 // Dump actually externalized dependencies to a report file.
251250 if ( externalizedReport ) {
252251 const externalizedReportFile =
@@ -493,6 +492,9 @@ class DependencyExtractionWebpackPlugin {
493492 return true ;
494493 }
495494
495+ const { webpack } = compilation . compiler ;
496+ const { AsyncDependenciesBlock } = webpack ;
497+
496498 const staticDependentModules = incomingConnections . flatMap (
497499 ( connection ) => {
498500 const { dependency } = connection ;
0 commit comments