Skip to content

Commit 66716e3

Browse files
Add test coverage for 'import ... from ...' syntax
1 parent 81840c0 commit 66716e3

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

test/fixtures/importsfrom1.es6.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import shared from './shared.es6.js';
2+
3+
console.log('importsfrom1 loaded')
4+

test/fixtures/importsfrom2.es6.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import shared from './shared.es6.js';
2+
3+
console.log('importsfrom2 loaded')

test/sync-split.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@ test('Tracks a shared synchronous webpack split', async () => {
2828
})
2929
})
3030

31+
test('Tracks a shared synchronous webpack split using importfrom', async () => {
32+
const result = (await runWebpack({
33+
optimization: {
34+
splitChunks: {
35+
cacheGroups: {
36+
commons: {
37+
name: 'commons',
38+
chunks: 'all',
39+
minChunks: 1,
40+
minSize: 0,
41+
}
42+
}
43+
}
44+
},
45+
entry: {
46+
'importsfrom1': path.resolve(__dirname, './fixtures/importsfrom1.es6.js'),
47+
'importsfrom2': path.resolve(__dirname, './fixtures/importsfrom2.es6.js'),
48+
},
49+
})).result
50+
51+
expect(result).toEqual({
52+
importsfrom1: { version: '1.x', js: { 'importsfrom1.js': {} }, dependencies: ['commons'] },
53+
importsfrom2: { version: '1.x', js: { 'importsfrom2.js': {} }, dependencies: ['commons'] },
54+
commons: { version: '1.x', js: { 'commons.js': {} } },
55+
})
56+
})
57+
3158
test('Tracks a shared runtime chunk', async () => {
3259
const result = (await runWebpack({
3360
optimization: {

0 commit comments

Comments
 (0)