@@ -2,6 +2,7 @@ const path = require("node:path");
2
2
const fsp = require ( "node:fs/promises" ) ;
3
3
4
4
const TerserPlugin = require ( "terser-webpack-plugin" ) ;
5
+ const { BundleAnalyzerPlugin } = require ( 'webpack-bundle-analyzer' ) ;
5
6
6
7
const isProd = process . env . NODE_ENV === "production" ;
7
8
@@ -29,17 +30,7 @@ module.exports = {
29
30
} ,
30
31
} ,
31
32
plugins : [
32
- // https://github.com/unjs/jiti/issues/109
33
- // TODO: Remove in next semver-major version
34
- ( compiler ) => {
35
- const plugin = { name : "replace node: protocol" } ;
36
- compiler . hooks . done . tap ( plugin , async ( ) => {
37
- const jitiDist = path . resolve ( compiler . options . context , "dist/jiti.js" ) ;
38
- const src = await fsp . readFile ( jitiDist , "utf8" ) ;
39
- const newSrc = src . replace ( / r e q u i r e \( " n o d e : / g, 'require("' ) ;
40
- await fsp . writeFile ( jitiDist , newSrc , "utf8" ) ;
41
- } ) ;
42
- } ,
33
+ process . argv . find ( arg => arg . includes ( '--analyze' ) ) && new BundleAnalyzerPlugin ( { } )
43
34
] ,
44
35
ignoreWarnings : [ / c r i t i c a l d e p e n d e n c y : / i] ,
45
36
module : {
@@ -58,13 +49,13 @@ module.exports = {
58
49
chunkIds : "named" ,
59
50
minimizer : isProd
60
51
? [
61
- new TerserPlugin ( {
62
- terserOptions : {
63
- // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
64
- mangle : false ,
65
- } ,
66
- } ) ,
67
- ]
52
+ new TerserPlugin ( {
53
+ terserOptions : {
54
+ // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
55
+ mangle : false ,
56
+ } ,
57
+ } ) ,
58
+ ]
68
59
: [ ] ,
69
60
} ,
70
61
} ;
0 commit comments