Two modules with same relative name cause getBundles to return duplicate entries
tomkelsey opened this issue · 1 comments
tomkelsey commented
Expected Behavior
Calling getBundles
should only return a specific chunk once.
Current Behavior
Using the build in example, getBundles
returns:
Bundles: { js:
[ { file: 'index.js',
hash: '8f79901c42dd94f639f2',
publicPath: '/dist/index.js' },
{ file: 'header.chunk.js',
hash: '65a54ba3e1a237af26f6',
publicPath: '/dist/header.chunk.js' },
{ file: 'content.chunk.js',
hash: 'ff806ccb9f861560a980',
publicPath: '/dist/content.chunk.js' },
{ file: 'content-nested.chunk.js',
hash: 'ea831f89529ab7fd0acd',
publicPath: '/dist/content-nested.chunk.js' },
{ file: 'multilevel.chunk.js',
hash: '397037a9c96fb38bce9c',
publicPath: '/dist/multilevel.chunk.js' },
{ file: 'shared-multilevel.chunk.js',
hash: '7e0c20e6d0612b573cf5',
publicPath: '/dist/shared-multilevel.chunk.js' },
{ file: 'shared-multilevel.chunk.js',
hash: '7e0c20e6d0612b573cf5',
publicPath: '/dist/shared-multilevel.chunk.js' },
{ file: 'deeplevel.chunk.js',
hash: 'd10a8161e8b0e381d8c4',
publicPath: '/dist/deeplevel.chunk.js' },
{ file: 'shared-multilevel.chunk.js',
hash: '7e0c20e6d0612b573cf5',
publicPath: '/dist/shared-multilevel.chunk.js' },
{ file: 'shared-multilevel.chunk.js',
hash: '7e0c20e6d0612b573cf5',
publicPath: '/dist/shared-multilevel.chunk.js' } ] }
You can see shared-multilevel.chunk.js
is included multiple times.
This results in duplicate entries when outputting the script tag:
<script src="/dist/index.js"></script>
<script src="/dist/header.chunk.js"></script>
<script src="/dist/content.chunk.js"></script>
<script src="/dist/content-nested.chunk.js"></script>
<script src="/dist/multilevel.chunk.js"></script>
<script src="/dist/shared-multilevel.chunk.js"></script>
<script src="/dist/shared-multilevel.chunk.js"></script>
<script src="/dist/deeplevel.chunk.js"></script>
<script src="/dist/shared-multilevel.chunk.js"></script>
<script src="/dist/shared-multilevel.chunk.js"></script>
Possible Solution
I guess you need to check if the file already exists before adding into that file type's array?
Steps to Reproduce
Run the example, inspect the source
Other Comments
Apologies this looks like an unforeseen side effect of my suggested fix for #5!
themgoncalves commented
I'm already working on this issue 😄