@@ -40,7 +40,7 @@ function addModulesToPackageJson(externalModules: string[], packageJson: JSONObj
40
40
/**
41
41
* Resolve the needed versions of production dependencies for external modules.
42
42
*/
43
- function getProdModules ( externalModules : { external : string } [ ] , packageJsonPath : string , dependencyGraph : JSONObject ) {
43
+ function getProdModules ( externalModules : { external : string } [ ] , packageJsonPath : string ) {
44
44
// eslint-disable-next-line @typescript-eslint/no-var-requires
45
45
const packageJson = require ( packageJsonPath ) ;
46
46
const prodModules : string [ ] = [ ] ;
@@ -67,11 +67,9 @@ function getProdModules(externalModules: { external: string }[], packageJsonPath
67
67
) ;
68
68
const peerDependencies = require ( modulePackagePath ) . peerDependencies as Record < string , string > ;
69
69
if ( ! isEmpty ( peerDependencies ) ) {
70
- console . log ( `Adding explicit peers for dependency ${ externalModule . external } ` ) ;
71
70
const peerModules = getProdModules (
72
71
compose ( map ( ( [ external ] ) => ( { external } ) ) , toPairs ) ( peerDependencies ) ,
73
- packageJsonPath ,
74
- dependencyGraph
72
+ packageJsonPath
75
73
) ;
76
74
Array . prototype . push . apply ( prodModules , peerModules ) ;
77
75
}
@@ -88,15 +86,8 @@ function getProdModules(externalModules: { external: string }[], packageJsonPath
88
86
89
87
if ( ! includes ( externalModule . external , ignoredDevDependencies ) ) {
90
88
// Runtime dependency found in devDependencies but not forcefully excluded
91
- console . log (
92
- `ERROR: Runtime dependency '${ externalModule . external } ' found in devDependencies.`
93
- ) ;
94
89
throw new Error ( `dependency error: ${ externalModule . external } .` ) ;
95
90
}
96
-
97
- console . log (
98
- `INFO: Runtime dependency '${ externalModule . external } ' found in devDependencies. It has been excluded automatically.`
99
- ) ;
100
91
}
101
92
}
102
93
} , externalModules ) ;
@@ -131,18 +122,12 @@ export function packExternalModules(externals: string[], cwd: string, compositeM
131
122
const packageJson = fs . readJsonSync ( packageJsonPath ) ;
132
123
const packageSections = pick ( packager . copyPackageSectionNames , packageJson ) ;
133
124
134
- // Get first level dependency graph
135
- console . log ( `Fetch dependency graph from ${ packageJsonPath } ` ) ;
136
-
137
- const dependencyGraph = packager . getProdDependencies ( path . dirname ( packageJsonPath ) , 1 ) ;
138
-
139
125
// (1) Generate dependency composition
140
126
const externalModules = externals . map ( external => ( { external } ) ) ;
141
- const compositeModules : JSONObject = uniq ( getProdModules ( externalModules , packageJsonPath , dependencyGraph ) ) ;
127
+ const compositeModules : JSONObject = uniq ( getProdModules ( externalModules , packageJsonPath ) ) ;
142
128
143
129
if ( isEmpty ( compositeModules ) ) {
144
130
// The compiled code does not reference any external modules at all
145
- console . log ( 'No external modules needed' ) ;
146
131
return ;
147
132
}
148
133
@@ -166,27 +151,13 @@ export function packExternalModules(externals: string[], cwd: string, compositeM
166
151
const packageLockPath = path . join ( path . dirname ( packageJsonPath ) , packager . lockfileName ) ;
167
152
168
153
if ( fs . existsSync ( packageLockPath ) ) {
169
- console . log ( 'Package lock found - Using locked versions' ) ;
170
- try {
171
- let packageLockFile = fs . readJsonSync ( packageLockPath ) ;
172
- packageLockFile = packager . rebaseLockfile ( relativePath , packageLockFile ) ;
173
- fs . writeJsonSync ( path . join ( compositeModulePath , packager . lockfileName ) , packageLockFile ) ;
174
- } catch ( err ) {
175
- console . log ( `Warning: Could not read lock file: ${ err . message } ` ) ;
176
- }
154
+ let packageLockFile = fs . readJsonSync ( packageLockPath ) ;
155
+ packageLockFile = packager . rebaseLockfile ( relativePath , packageLockFile ) ;
156
+ fs . writeJsonSync ( path . join ( compositeModulePath , packager . lockfileName ) , packageLockFile ) ;
177
157
}
178
158
179
- const start = Date . now ( ) ;
180
- console . log ( 'Packing external modules: ' + compositeModules . join ( ', ' ) ) ;
181
-
182
159
packager . install ( compositeModulePath ) ;
183
160
184
- console . log ( `Package took [${ Date . now ( ) - start } ms]` ) ;
185
-
186
161
// Prune extraneous packages - removes not needed ones
187
- const startPrune = Date . now ( ) ;
188
-
189
162
packager . prune ( compositeModulePath ) ;
190
-
191
- console . log ( `Prune: ${ compositeModulePath } [${ Date . now ( ) - startPrune } ms]` ) ;
192
163
}
0 commit comments