55 type Module ,
66 type BundleAnalysisUploadPlugin ,
77 red ,
8+ normalizePath ,
89} from "@codecov/bundler-plugin-core" ;
910
1011const PLUGIN_NAME = "codecov-rollup-bundle-analysis-plugin" ;
@@ -31,17 +32,25 @@ export const rollupBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({
3132 output . bundleName = `${ userOptions . bundleName } -${ options . name } ` ;
3233 }
3334
35+ const cwd = process . cwd ( ) ;
36+ const assets : Asset [ ] = [ ] ;
37+ const chunks : Chunk [ ] = [ ] ;
38+ const moduleByFileName = new Map < string , Module > ( ) ;
39+ const items = Object . values ( bundle ) ;
3440 const customOptions = {
3541 moduleOriginalSize : false ,
3642 ...options ,
3743 } ;
3844
39- const assets : Asset [ ] = [ ] ;
40- const chunks : Chunk [ ] = [ ] ;
41- const moduleByFileName = new Map < string , Module > ( ) ;
42- const items = Object . values ( bundle ) ;
45+ let assetFormatString = "" ;
46+ if ( typeof customOptions . assetFileNames === "string" ) {
47+ assetFormatString = customOptions . assetFileNames ;
48+ }
4349
44- const cwd = process . cwd ( ) ;
50+ let chunkFormatString = "" ;
51+ if ( typeof customOptions . chunkFileNames === "string" ) {
52+ chunkFormatString = customOptions . chunkFileNames ;
53+ }
4554
4655 let counter = 0 ;
4756 for ( const item of items ) {
@@ -53,6 +62,7 @@ export const rollupBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({
5362 assets . push ( {
5463 name : fileName ,
5564 size : size ,
65+ normalized : normalizePath ( fileName , assetFormatString ) ,
5666 } ) ;
5767 } else {
5868 const fileName = item ?. fileName ?? "" ;
@@ -61,6 +71,7 @@ export const rollupBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({
6171 assets . push ( {
6272 name : fileName ,
6373 size : size ,
74+ normalized : normalizePath ( fileName , assetFormatString ) ,
6475 } ) ;
6576 }
6677 }
@@ -75,14 +86,15 @@ export const rollupBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({
7586 assets . push ( {
7687 name : fileName ,
7788 size : size ,
89+ normalized : normalizePath ( fileName , chunkFormatString ) ,
7890 } ) ;
7991
8092 chunks . push ( {
8193 id : chunkId ,
8294 uniqueId : uniqueId ,
8395 entry : item ?. isEntry ,
8496 initial : item ?. isDynamicEntry ,
85- files : [ item ?. fileName ] ,
97+ files : [ fileName ] ,
8698 names : [ item ?. name ] ,
8799 } ) ;
88100
@@ -103,17 +115,15 @@ export const rollupBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({
103115 // if the modules exists append chunk ids to the grabbed module
104116 // else create a new module and create a new entry in the map
105117 if ( moduleEntry ) {
106- moduleEntry . chunks . push ( chunkId ) ;
107118 moduleEntry . chunkUniqueIds . push ( uniqueId ) ;
108119 } else {
109120 const size = customOptions . moduleOriginalSize
110121 ? moduleInfo . originalLength
111122 : moduleInfo . renderedLength ;
112123
113- const module = {
124+ const module : Module = {
114125 name : relativeModulePathWithPrefix ,
115126 size : size ,
116- chunks : [ chunkId ] ,
117127 chunkUniqueIds : [ uniqueId ] ,
118128 } ;
119129
0 commit comments