The Test
This test checks to see if exports from a common module can be separated when they are used exclusively by different consuming modules. In this particular variation, an entry module and a lazily-loaded module each use one of the exported objects from a third common module.
index.js
import { foo } from './objects.js';
console.log(foo);
import('./lazy.js');
lazy.js
import { bar } from './objects.js';
console.log(bar);
objects.js
export const foo = { name: 'foo' };
export const bar = { name: 'bar' };
In this example, index.js
only uses foo
from objects.js
, whereas lazy.js
only uses bar
.
There are a few possible outputs that could be considered ideal:
- inline
foo
into the generated bundle forindex.js
, andbar
into the bundle forlazy.js
- split
objects.js
into separate bundles forfoo
andbar
, used by the bundles forindex.js
andlazy.js