@@ -121,30 +121,30 @@ function getJSCCOptions(buildType, isUMD) {
121121}
122122
123123/**
124+ * @param {string } type - The type of the output (e.g., 'umd', 'es').
124125 * @returns {OutputOptions['plugins'] } - The output plugins.
125126 */
126- function getOutPlugins ( ) {
127- const plugins = [
128- ] ;
127+ function getOutPlugins ( type ) {
128+ const plugins = [ ] ;
129129
130130 if ( process . env . treemap ) {
131131 plugins . push ( visualizer ( {
132- filename : ' treemap.html' ,
132+ filename : ` treemap.${ type } . html` ,
133133 brotliSize : true ,
134134 gzipSize : true
135135 } ) ) ;
136136 }
137137
138138 if ( process . env . treenet ) {
139139 plugins . push ( visualizer ( {
140- filename : ' treenet.html' ,
140+ filename : ` treenet.${ type } . html` ,
141141 template : 'network'
142142 } ) ) ;
143143 }
144144
145145 if ( process . env . treesun ) {
146146 plugins . push ( visualizer ( {
147- filename : ' treesun.html' ,
147+ filename : ` treesun.${ type } . html` ,
148148 template : 'sunburst'
149149 } ) ) ;
150150 }
@@ -155,6 +155,10 @@ function getOutPlugins() {
155155/**
156156 * Build a target that Rollup is supposed to build (bundled and unbundled).
157157 *
158+ * For faster subsequent builds, the unbundled and release builds are cached in the HISTORY map to
159+ * be used for bundled and minified builds. They are stored in the HISTORY map with the key:
160+ * `<debug|release|profiler>-<umd|esm>-<bundled>`.
161+ *
158162 * @param {object } options - The build target options.
159163 * @param {'umd'|'esm' } options.moduleFormat - The module format.
160164 * @param {'debug'|'release'|'profiler'|'min' } options.buildType - The build type.
@@ -169,6 +173,9 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index.
169173 const isMin = buildType === 'min' ;
170174 const bundled = isUMD || isMin || bundleState === 'bundled' ;
171175
176+ const prefix = `${ OUT_PREFIX [ buildType ] } ` ;
177+ const file = `${ prefix } ${ isUMD ? '.js' : '.mjs' } ` ;
178+
172179 const targets = [ ] ;
173180
174181 // bundle from unbundled
@@ -187,7 +194,7 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index.
187194 sourcemap : isDebug && 'inline' ,
188195 name : 'pc' ,
189196 preserveModules : false ,
190- file : `${ dir } /${ OUT_PREFIX [ buildType ] } .mjs`
197+ file : `${ dir } /${ prefix } .mjs`
191198 }
192199 } ;
193200
@@ -211,8 +218,7 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index.
211218 ] ,
212219 output : {
213220 banner : isUMD ? getBanner ( BANNER [ buildType ] ) : undefined ,
214- plugins : getOutPlugins ( ) ,
215- file : `${ dir } /${ OUT_PREFIX [ buildType ] } ${ isUMD ? '.js' : '.mjs' } `
221+ file : `${ dir } /${ file } `
216222 } ,
217223 context : isUMD ? 'this' : undefined
218224 } ;
@@ -230,15 +236,15 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index.
230236 input,
231237 output : {
232238 banner : bundled ? getBanner ( BANNER [ buildType ] ) : undefined ,
233- plugins : isMin ? getOutPlugins ( ) : undefined ,
239+ plugins : buildType === 'release' ? getOutPlugins ( isUMD ? 'umd' : 'es' ) : undefined ,
234240 format : isUMD ? 'umd' : 'es' ,
235241 indent : '\t' ,
236242 sourcemap : bundled && isDebug && 'inline' ,
237243 name : 'pc' ,
238244 preserveModules : ! bundled ,
239245 preserveModulesRoot : ! bundled ? rootDir : undefined ,
240- file : bundled ? `${ dir } /${ OUT_PREFIX [ buildType ] } ${ isUMD ? '.js' : '.mjs' } ` : undefined ,
241- dir : ! bundled ? `${ dir } /${ OUT_PREFIX [ buildType ] } ` : undefined ,
246+ file : bundled ? `${ dir } /${ file } ` : undefined ,
247+ dir : ! bundled ? `${ dir } /${ prefix } ` : undefined ,
242248 entryFileNames : chunkInfo => `${ chunkInfo . name . replace ( / n o d e _ m o d u l e s / g, 'modules' ) } .js`
243249 } ,
244250 plugins : [
0 commit comments