I have combined two files file1.js
and file2.js
into single chunk using the following configuration:
optimization: {
splitChunks: {
cacheGroups: {
test(module) {
return (module.resource.includes('file1') || module.resource.includes('file2'));
},
chunks: 'All',
name: 'test'
}
}
}
when I run two dynamic imports, I can see only 1 request is sent to the server for test.js
which is the chunk created by web pack.
import('file1').then(doSomething);
import('file2').then(doAnotherThing);
My question is if my chunk file is large and my first import hasn't been resolved yet, is there a possibility that my second import will re-fetch the same bundle again? Since the two promises are different, they can resolve in any order, therefore is it possible that I can see two network requests for the same chunk?
This may be a stupid question, but I am having a hard time to get a confirmation on this.