1- const fs = require ( 'fs' )
2- const path = require ( 'path' )
3- const webpack = require ( 'webpack' )
1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+ const webpack = require ( 'webpack' ) ;
44const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
55
6- const electronRoot = path . resolve ( __dirname , '../..' )
6+ const electronRoot = path . resolve ( __dirname , '../..' ) ;
77
8- const onlyPrintingGraph = ! ! process . env . PRINT_WEBPACK_GRAPH
8+ const onlyPrintingGraph = ! ! process . env . PRINT_WEBPACK_GRAPH ;
99
1010class AccessDependenciesPlugin {
11- apply ( compiler ) {
11+ apply ( compiler ) {
1212 // Only hook into webpack when we are printing the dependency graph
13- if ( ! onlyPrintingGraph ) return
13+ if ( ! onlyPrintingGraph ) return ;
1414
1515 compiler . hooks . compilation . tap ( 'AccessDependenciesPlugin' , compilation => {
1616 compilation . hooks . finishModules . tap ( 'AccessDependenciesPlugin' , modules => {
17- const filePaths = modules . map ( m => m . resource ) . filter ( p => p ) . map ( p => path . relative ( electronRoot , p ) )
18- console . info ( JSON . stringify ( filePaths ) )
19- } )
20- } )
17+ const filePaths = modules . map ( m => m . resource ) . filter ( p => p ) . map ( p => path . relative ( electronRoot , p ) ) ;
18+ console . info ( JSON . stringify ( filePaths ) ) ;
19+ } ) ;
20+ } ) ;
2121 }
2222}
2323
2424const defines = {
2525 BUILDFLAG : onlyPrintingGraph ? '(a => a)' : ''
26- }
26+ } ;
2727
28- const buildFlagsPrefix = '--buildflags='
28+ const buildFlagsPrefix = '--buildflags=' ;
2929const buildFlagArg = process . argv . find ( arg => arg . startsWith ( buildFlagsPrefix ) ) ;
3030
3131if ( buildFlagArg ) {
32- const buildFlagPath = buildFlagArg . substr ( buildFlagsPrefix . length )
32+ const buildFlagPath = buildFlagArg . substr ( buildFlagsPrefix . length ) ;
3333
34- const flagFile = fs . readFileSync ( buildFlagPath , 'utf8' )
34+ const flagFile = fs . readFileSync ( buildFlagPath , 'utf8' ) ;
3535 for ( const line of flagFile . split ( / ( \r \n | \r | \n ) / g) ) {
36- const flagMatch = line . match ( / # d e f i n e B U I L D F L A G _ I N T E R N A L _ ( .+ ?) \( \) \( ( [ 0 1 ] ) \) / )
36+ const flagMatch = line . match ( / # d e f i n e B U I L D F L A G _ I N T E R N A L _ ( .+ ?) \( \) \( ( [ 0 1 ] ) \) / ) ;
3737 if ( flagMatch ) {
3838 const [ , flagName , flagValue ] = flagMatch ;
3939 defines [ flagName ] = JSON . stringify ( Boolean ( parseInt ( flagValue , 10 ) ) ) ;
4040 }
4141 }
4242}
4343
44- const ignoredModules = [ ]
44+ const ignoredModules = [ ] ;
4545
46- if ( defines [ ' ENABLE_DESKTOP_CAPTURER' ] === 'false' ) {
46+ if ( defines . ENABLE_DESKTOP_CAPTURER === 'false' ) {
4747 ignoredModules . push (
4848 '@electron/internal/browser/desktop-capturer' ,
4949 '@electron/internal/browser/api/desktop-capturer' ,
5050 '@electron/internal/renderer/api/desktop-capturer'
51- )
51+ ) ;
5252}
5353
54- if ( defines [ ' ENABLE_REMOTE_MODULE' ] === 'false' ) {
54+ if ( defines . ENABLE_REMOTE_MODULE === 'false' ) {
5555 ignoredModules . push (
5656 '@electron/internal/browser/remote/server' ,
5757 '@electron/internal/renderer/api/remote'
58- )
58+ ) ;
5959}
6060
61- if ( defines [ ' ENABLE_VIEWS_API' ] === 'false' ) {
61+ if ( defines . ENABLE_VIEWS_API === 'false' ) {
6262 ignoredModules . push (
6363 '@electron/internal/browser/api/views/image-view.js'
64- )
64+ ) ;
6565}
6666
6767module . exports = ( {
@@ -71,9 +71,9 @@ module.exports = ({
7171 target,
7272 wrapInitWithProfilingTimeout
7373} ) => {
74- let entry = path . resolve ( electronRoot , 'lib' , target , 'init.ts' )
74+ let entry = path . resolve ( electronRoot , 'lib' , target , 'init.ts' ) ;
7575 if ( ! fs . existsSync ( entry ) ) {
76- entry = path . resolve ( electronRoot , 'lib' , target , 'init.js' )
76+ entry = path . resolve ( electronRoot , 'lib' , target , 'init.js' ) ;
7777 }
7878
7979 return ( {
@@ -88,16 +88,16 @@ module.exports = ({
8888 resolve : {
8989 alias : {
9090 '@electron/internal' : path . resolve ( electronRoot , 'lib' ) ,
91- ' electron' : path . resolve ( electronRoot , 'lib' , loadElectronFromAlternateTarget || target , 'api' , 'exports' , 'electron.ts' ) ,
91+ electron : path . resolve ( electronRoot , 'lib' , loadElectronFromAlternateTarget || target , 'api' , 'exports' , 'electron.ts' ) ,
9292 // Force timers to resolve to our dependency that doesn't use window.postMessage
93- ' timers' : path . resolve ( electronRoot , 'node_modules' , 'timers-browserify' , 'main.js' )
93+ timers : path . resolve ( electronRoot , 'node_modules' , 'timers-browserify' , 'main.js' )
9494 } ,
9595 extensions : [ '.ts' , '.js' ]
9696 } ,
9797 module : {
9898 rules : [ {
9999 test : ( moduleName ) => ! onlyPrintingGraph && ignoredModules . includes ( moduleName ) ,
100- loader : 'null-loader' ,
100+ loader : 'null-loader'
101101 } , {
102102 test : / \. t s $ / ,
103103 loader : 'ts-loader' ,
@@ -106,7 +106,7 @@ module.exports = ({
106106 transpileOnly : onlyPrintingGraph ,
107107 ignoreDiagnostics : [
108108 // File '{0}' is not under 'rootDir' '{1}'.
109- 6059 ,
109+ 6059
110110 ]
111111 }
112112 } ]
@@ -116,32 +116,32 @@ module.exports = ({
116116 __filename : false ,
117117 // We provide our own "timers" import above, any usage of setImmediate inside
118118 // one of our renderer bundles should import it from the 'timers' package
119- setImmediate : false ,
119+ setImmediate : false
120120 } ,
121121 optimization : {
122122 minimize : true ,
123123 minimizer : [
124124 new TerserPlugin ( {
125125 terserOptions : {
126126 keep_classnames : true ,
127- keep_fnames : true ,
128- } ,
129- } ) ,
130- ] ,
127+ keep_fnames : true
128+ }
129+ } )
130+ ]
131131 } ,
132132 plugins : [
133133 new AccessDependenciesPlugin ( ) ,
134134 ...( targetDeletesNodeGlobals ? [
135135 new webpack . ProvidePlugin ( {
136136 process : [ '@electron/internal/renderer/webpack-provider' , 'process' ] ,
137137 global : [ '@electron/internal/renderer/webpack-provider' , '_global' ] ,
138- Buffer : [ '@electron/internal/renderer/webpack-provider' , 'Buffer' ] ,
138+ Buffer : [ '@electron/internal/renderer/webpack-provider' , 'Buffer' ]
139139 } )
140140 ] : [ ] ) ,
141141 new webpack . ProvidePlugin ( {
142- Promise : [ '@electron/internal/common/webpack-globals-provider' , 'Promise' ] ,
142+ Promise : [ '@electron/internal/common/webpack-globals-provider' , 'Promise' ]
143143 } ) ,
144- new webpack . DefinePlugin ( defines ) ,
144+ new webpack . DefinePlugin ( defines )
145145 ]
146- } )
147- }
146+ } ) ;
147+ } ;
0 commit comments