You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In some environments like React Native there is a possibility of using different type of bundles, which does not consist only of plan JavaScript. One of the example is an Indexed RAM bundle in React Native which is a mix of binary metadata and the JavaScript source code (more info here) and File RAM bundle, which spreads modules into separate files.
It would be awesome if we could get an option to analyse those bundles, more specifically have an option in inject custom logic that allows to analyse them.
Describe the solution you'd like
Essentially the solution is to allow to customise parts of the source-map-explorer pipeline. For example RAM bundles are so different compared to regular plain JS bundles, that almost the whole code for iterating over mappings and computing sizes has to be altered and only the visualisation part is usable.
Describe alternatives you've considered
I was thinking about 2 options that would work:
Allow to customise computeFileSizes (provide custom one) in the Node API or in other way eg:
explore('dummy.js',{// for RAM bundles we cannot use the built-in logic for reading/loading code/mapsoutput: {format: 'html'},computeFileSizes: (sourceMapData: SourceMapData,options: ExploreOptions,coverageRanges?: CoverageRange[][]): FileSizes=>{// custom logic here}})
Hide bundle specific operations like loading source code, loading source map, getting mappings, computing file sizes behind an abstraction and implement this abstraction for plain/regular JS bundles for example (rough draft):
typeSourceAndMapBuffers={code: Buffer,map?: Buffer};interfaceBundleAnalyzer{load(fileTokens: Array<string|{code: string,map?: string}>,options: LoadOptions): SourceAndMapBuffers[];computeSizes(sourceAndMapBuffers: SourceAndMapBuffers[],options: ComputeSizeOptions): FileSizes[];}classMyBundleAnalyzerimplementsBundleAnalyzer{// implement load and computeSizes here}explore(newMyBundleAnalyzer());// passing currently available options would make `source-map-explorer` use built-in `PlainJavaScriptBundleAnalyzer`
Additional context
I'm open to other suggestions/ideas and once we get some agreement which path we should take, we will create a PR to add this support.
@danvk How about exposing function(s) that takes info about modules and it's file sizes (eg FileSizes type) which would generate the reports? That way we could implement computation ourselves but still use the visualization related logic. Is that what you had in mind?
Is your feature request related to a problem? Please describe.
In some environments like React Native there is a possibility of using different type of bundles, which does not consist only of plan JavaScript. One of the example is an Indexed RAM bundle in React Native which is a mix of binary metadata and the JavaScript source code (more info here) and File RAM bundle, which spreads modules into separate files.
It would be awesome if we could get an option to analyse those bundles, more specifically have an option in inject custom logic that allows to analyse them.
Describe the solution you'd like
Essentially the solution is to allow to customise parts of the
source-map-explorer
pipeline. For example RAM bundles are so different compared to regular plain JS bundles, that almost the whole code for iterating over mappings and computing sizes has to be altered and only the visualisation part is usable.Describe alternatives you've considered
I was thinking about 2 options that would work:
computeFileSizes
(provide custom one) in the Node API or in other way eg:Additional context
I'm open to other suggestions/ideas and once we get some agreement which path we should take, we will create a PR to add this support.
cc: @danvk @nikolay-borzov
The text was updated successfully, but these errors were encountered: