@@ -2,7 +2,6 @@ import path from 'path';
2
2
import os from 'os' ;
3
3
4
4
import { SourceMapConsumer } from 'source-map' ;
5
- import webpackSources from 'webpack-sources' ;
6
5
import webpack , {
7
6
util ,
8
7
ModuleFilenameHelpers ,
@@ -23,7 +22,9 @@ import schema from './options.json';
23
22
import { minify as minifyFn } from './minify' ;
24
23
25
24
// webpack 5 exposes the sources property to ensure the right version of webpack-sources is used
26
- const sources = webpack . sources || webpackSources ;
25
+ const { SourceMapSource, RawSource, ConcatSource } =
26
+ // eslint-disable-next-line global-require
27
+ webpack . sources || require ( 'webpack-sources' ) ;
27
28
28
29
class TerserPlugin {
29
30
constructor ( options = { } ) {
@@ -267,7 +268,7 @@ class TerserPlugin {
267
268
}
268
269
269
270
if ( map ) {
270
- outputSource = new sources . SourceMapSource (
271
+ outputSource = new SourceMapSource (
271
272
code ,
272
273
name ,
273
274
map ,
@@ -276,7 +277,7 @@ class TerserPlugin {
276
277
true
277
278
) ;
278
279
} else {
279
- outputSource = new sources . RawSource ( code ) ;
280
+ outputSource = new RawSource ( code ) ;
280
281
}
281
282
282
283
const assetInfo = { ...info , minimized : true } ;
@@ -300,7 +301,7 @@ class TerserPlugin {
300
301
}
301
302
302
303
if ( banner ) {
303
- outputSource = new sources . ConcatSource (
304
+ outputSource = new ConcatSource (
304
305
shebang ? `${ shebang } \n` : '' ,
305
306
`/*! ${ banner } */\n` ,
306
307
outputSource
@@ -580,7 +581,7 @@ class TerserPlugin {
580
581
TerserPlugin . emitAsset (
581
582
compilation ,
582
583
commentsFilename ,
583
- new sources . RawSource ( `${ extractedComments } \n` )
584
+ new RawSource ( `${ extractedComments } \n` )
584
585
) ;
585
586
} ) ;
586
587
0 commit comments