@@ -40,7 +40,7 @@ function addModulesToPackageJson(externalModules: string[], packageJson: JSONObj
4040/**
4141 * Resolve the needed versions of production dependencies for external modules.
4242 */
43- function getProdModules ( externalModules : { external : string } [ ] , packageJsonPath : string , dependencyGraph : JSONObject ) {
43+ function getProdModules ( externalModules : { external : string } [ ] , packageJsonPath : string ) {
4444 // eslint-disable-next-line @typescript-eslint/no-var-requires
4545 const packageJson = require ( packageJsonPath ) ;
4646 const prodModules : string [ ] = [ ] ;
@@ -67,11 +67,9 @@ function getProdModules(externalModules: { external: string }[], packageJsonPath
6767 ) ;
6868 const peerDependencies = require ( modulePackagePath ) . peerDependencies as Record < string , string > ;
6969 if ( ! isEmpty ( peerDependencies ) ) {
70- console . log ( `Adding explicit peers for dependency ${ externalModule . external } ` ) ;
7170 const peerModules = getProdModules (
7271 compose ( map ( ( [ external ] ) => ( { external } ) ) , toPairs ) ( peerDependencies ) ,
73- packageJsonPath ,
74- dependencyGraph
72+ packageJsonPath
7573 ) ;
7674 Array . prototype . push . apply ( prodModules , peerModules ) ;
7775 }
@@ -88,15 +86,8 @@ function getProdModules(externalModules: { external: string }[], packageJsonPath
8886
8987 if ( ! includes ( externalModule . external , ignoredDevDependencies ) ) {
9088 // Runtime dependency found in devDependencies but not forcefully excluded
91- console . log (
92- `ERROR: Runtime dependency '${ externalModule . external } ' found in devDependencies.`
93- ) ;
9489 throw new Error ( `dependency error: ${ externalModule . external } .` ) ;
9590 }
96-
97- console . log (
98- `INFO: Runtime dependency '${ externalModule . external } ' found in devDependencies. It has been excluded automatically.`
99- ) ;
10091 }
10192 }
10293 } , externalModules ) ;
@@ -131,18 +122,12 @@ export function packExternalModules(externals: string[], cwd: string, compositeM
131122 const packageJson = fs . readJsonSync ( packageJsonPath ) ;
132123 const packageSections = pick ( packager . copyPackageSectionNames , packageJson ) ;
133124
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-
139125 // (1) Generate dependency composition
140126 const externalModules = externals . map ( external => ( { external } ) ) ;
141- const compositeModules : JSONObject = uniq ( getProdModules ( externalModules , packageJsonPath , dependencyGraph ) ) ;
127+ const compositeModules : JSONObject = uniq ( getProdModules ( externalModules , packageJsonPath ) ) ;
142128
143129 if ( isEmpty ( compositeModules ) ) {
144130 // The compiled code does not reference any external modules at all
145- console . log ( 'No external modules needed' ) ;
146131 return ;
147132 }
148133
@@ -166,27 +151,13 @@ export function packExternalModules(externals: string[], cwd: string, compositeM
166151 const packageLockPath = path . join ( path . dirname ( packageJsonPath ) , packager . lockfileName ) ;
167152
168153 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 ) ;
177157 }
178158
179- const start = Date . now ( ) ;
180- console . log ( 'Packing external modules: ' + compositeModules . join ( ', ' ) ) ;
181-
182159 packager . install ( compositeModulePath ) ;
183160
184- console . log ( `Package took [${ Date . now ( ) - start } ms]` ) ;
185-
186161 // Prune extraneous packages - removes not needed ones
187- const startPrune = Date . now ( ) ;
188-
189162 packager . prune ( compositeModulePath ) ;
190-
191- console . log ( `Prune: ${ compositeModulePath } [${ Date . now ( ) - startPrune } ms]` ) ;
192163}
0 commit comments