Skip to content

Commit a4db383

Browse files
split heic-to to separate eager chunk
1 parent 04c1fbd commit a4db383

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

config/webpack/webpack.common.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ const getCommonConfiguration = ({file = '.env', platform = 'web'}: Environment):
349349
name: 'lottiePlayer',
350350
chunks: 'all',
351351
},
352+
// heic-to library is used sparsely and we want to load it as a separate chunk
353+
// to reduce the potential bundled size of the initial chunk
354+
heicTo: {
355+
test: /[\\/]node_modules[\\/](heic-to)[\\/]/,
356+
name: 'heicTo',
357+
chunks: 'all',
358+
},
352359
// Extract all 3rd party dependencies (~75% of App) to separate js file
353360
// This gives a more efficient caching - 3rd party deps don't change as often as main source
354361
// When dependencies don't change webpack would produce the same js file (and content hash)

src/libs/fileDownload/heicConverter/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const convertHeicImage: HeicConverterFunction = (file, {onSuccess = () => {}, on
2323
}
2424

2525
// Start loading the conversion library in parallel with fetching the file
26-
const libraryPromise = import(/* webpackChunkName: "heic-converter" */ 'heic-to').catch((importError) => {
26+
const libraryPromise = import(/* webpackMode: "eager" */ 'heic-to').catch((importError) => {
2727
console.error('Error loading heic-to library:', importError);
2828
// Re-throw a normalized error so the outer catch can handle it uniformly
2929
throw new Error('HEIC conversion library unavailable');

0 commit comments

Comments
 (0)