@@ -22,6 +22,41 @@ function customWarn(warning) {
2222 onWarn ( warning ) ;
2323}
2424
25+ /**
26+ * @param {object } options
27+ * @param {boolean } options.autoInstall
28+ * @param {boolean } options.production
29+ * @param {string } options.cacheDir
30+ * @param {string } options.cwd
31+ * @param {string } options.registryUrl
32+ * @param {string } [options.requestId]
33+ * @param {Map<string, string> } options.resolutionCache
34+ * @param {Map<string, string> } options.browserReplacement
35+ * @returns {import('rollup').Plugin[] }
36+ */
37+ export function getNpmPlugins ( {
38+ autoInstall,
39+ production,
40+ cacheDir,
41+ cwd,
42+ resolutionCache,
43+ registryUrl,
44+ browserReplacement,
45+ requestId
46+ } ) {
47+ // @ts -ignore
48+ return [
49+ browserFieldPlugin ( { browserReplacement } ) ,
50+ ! production && requestId && npmExternalDeps ( { requestId } ) ,
51+ ! process . env . DISABLE_LOCAL_NPM && npmLocalPackage ( { root : cwd } ) ,
52+ autoInstall && npmAutoInstall ( { cacheDir, registryUrl } ) ,
53+ npmLoad ( { browserReplacement, resolutionCache } ) ,
54+ commonjsPlugin ( { production } ) ,
55+ subPackageLegacy ( ) ,
56+ sizeWarningPlugin ( )
57+ ] . filter ( Boolean ) ;
58+ }
59+
2560/**
2661 * @param {string } requestId
2762 * @param {object } options
@@ -39,22 +74,27 @@ export async function npmBundle(requestId, { autoInstall, production, cacheDir,
3974 /** @type {Map<string, string> } */
4075 const browserReplacement = new Map ( ) ;
4176
77+ console . log ( 'BUNDLE' , requestId , meta , { production } ) ;
78+
4279 const bundle = await rollup . rollup ( {
4380 input : requestId ,
4481 external : [ ...builtinModules ] ,
4582 onwarn : customWarn ,
4683 plugins : [
47- browserFieldPlugin ( { browserReplacement } ) ,
48- npmExternalDeps ( { requestId } ) ,
49- ! process . env . DISABLE_LOCAL_NPM && npmLocalPackage ( { root : cwd } ) ,
50- autoInstall && npmAutoInstall ( { cacheDir, registryUrl } ) ,
51- npmLoad ( { browserReplacement, resolutionCache } ) ,
52- jsonPlugin ( { root : cwd } ) ,
53- commonjsPlugin ( { production } ) ,
54- subPackageLegacy ( { rootId : requestId } ) ,
55- sizeWarningPlugin ( )
84+ ...getNpmPlugins ( {
85+ requestId,
86+ autoInstall,
87+ production,
88+ cacheDir,
89+ cwd,
90+ resolutionCache,
91+ registryUrl,
92+ browserReplacement
93+ } ) ,
94+ jsonPlugin ( { root : cwd } )
5695 ]
5796 } ) ;
97+ console . log ( resolutionCache ) ;
5898
5999 const result = await bundle . generate ( {
60100 chunkFileNames : `${ pkgName } -[hash]` ,
0 commit comments