Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide consistent chunking via a consistent order of entry modules w…
…hen emitting chunks (#3055)
- Loading branch information
1 parent
9cd5668
commit 6b2b650
Showing
33 changed files
with
321 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
test/chunking-form/samples/emit-file/emit-chunk-order1/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const assert = require('assert'); | ||
|
||
module.exports = { | ||
description: | ||
'creates a consistent chunking order (needs to be consistent with the other test of this kind)', | ||
options: { | ||
input: 'main', | ||
plugins: { | ||
resolveId(id) { | ||
if (id === 'emitted') { | ||
return id; | ||
} | ||
}, | ||
load(id) { | ||
if (id === 'emitted') { | ||
return `import value from './dep.js'; | ||
export const id = 'emitted'; | ||
console.log(id, value); | ||
`; | ||
} | ||
}, | ||
buildStart() { | ||
this.emitFile({ | ||
type: 'chunk', | ||
id: 'emitted' | ||
}); | ||
}, | ||
generateBundle(options, bundle) { | ||
assert.deepStrictEqual(Object.keys(bundle).map(key => bundle[key].name), [ | ||
'main', | ||
'dep', | ||
'emitted' | ||
]); | ||
} | ||
} | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(['exports'], function (exports) { 'use strict'; | ||
|
||
var value = 42; | ||
|
||
exports.value = value; | ||
|
||
}); |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define(['exports', './generated-dep'], function (exports, dep) { 'use strict'; | ||
|
||
const id = 'emitted'; | ||
console.log(id, dep.value); | ||
|
||
exports.id = id; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}); |
7 changes: 7 additions & 0 deletions
7
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(['./generated-dep', './generated-emitted'], function (dep, emitted) { 'use strict'; | ||
|
||
console.log(emitted.id); | ||
|
||
console.log('main', dep.value); | ||
|
||
}); |
5 changes: 5 additions & 0 deletions
5
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/cjs/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
var value = 42; | ||
|
||
exports.value = value; |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/cjs/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
var dep = require('./generated-dep.js'); | ||
|
||
const id = 'emitted'; | ||
console.log(id, dep.value); | ||
|
||
exports.id = id; |
8 changes: 8 additions & 0 deletions
8
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/cjs/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
var dep = require('./generated-dep.js'); | ||
var emitted = require('./generated-emitted.js'); | ||
|
||
console.log(emitted.id); | ||
|
||
console.log('main', dep.value); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/es/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var value = 42; | ||
|
||
export { value as v }; |
6 changes: 6 additions & 0 deletions
6
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/es/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { v as value } from './generated-dep.js'; | ||
|
||
const id = 'emitted'; | ||
console.log(id, value); | ||
|
||
export { id }; |
6 changes: 6 additions & 0 deletions
6
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/es/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { v as value } from './generated-dep.js'; | ||
import { id } from './generated-emitted.js'; | ||
|
||
console.log(id); | ||
|
||
console.log('main', value); |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
var value = exports('v', 42); | ||
|
||
} | ||
}; | ||
}); |
15 changes: 15 additions & 0 deletions
15
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
System.register(['./generated-dep.js'], function (exports) { | ||
'use strict'; | ||
var value; | ||
return { | ||
setters: [function (module) { | ||
value = module.v; | ||
}], | ||
execute: function () { | ||
|
||
const id = exports('id', 'emitted'); | ||
console.log(id, value); | ||
|
||
} | ||
}; | ||
}); |
18 changes: 18 additions & 0 deletions
18
test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
System.register(['./generated-dep.js', './generated-emitted.js'], function () { | ||
'use strict'; | ||
var value, id; | ||
return { | ||
setters: [function (module) { | ||
value = module.v; | ||
}, function (module) { | ||
id = module.id; | ||
}], | ||
execute: function () { | ||
|
||
console.log(id); | ||
|
||
console.log('main', value); | ||
|
||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 42; |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/emit-file/emit-chunk-order1/dep2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { id } from 'emitted'; | ||
|
||
console.log(id); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/emit-file/emit-chunk-order1/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import value from './dep.js'; | ||
import './dep2.js'; | ||
console.log('main', value); |
43 changes: 43 additions & 0 deletions
43
test/chunking-form/samples/emit-file/emit-chunk-order2/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const assert = require('assert'); | ||
|
||
module.exports = { | ||
description: | ||
'creates a consistent chunking order (needs to be consistent with the other test of this kind)', | ||
options: { | ||
input: 'main', | ||
plugins: { | ||
resolveId(id) { | ||
if (id === 'emitted') { | ||
return id; | ||
} | ||
}, | ||
load(id) { | ||
if (id === 'emitted') { | ||
return new Promise(resolve => | ||
setTimeout( | ||
() => | ||
resolve(`import value from './dep.js'; | ||
export const id = 'emitted'; | ||
console.log(id, value); | ||
`), | ||
200 | ||
) | ||
); | ||
} | ||
}, | ||
buildStart() { | ||
this.emitFile({ | ||
type: 'chunk', | ||
id: 'emitted' | ||
}); | ||
}, | ||
generateBundle(options, bundle) { | ||
assert.deepStrictEqual(Object.keys(bundle).map(key => bundle[key].name), [ | ||
'main', | ||
'dep', | ||
'emitted' | ||
]); | ||
} | ||
} | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(['exports'], function (exports) { 'use strict'; | ||
|
||
var value = 42; | ||
|
||
exports.value = value; | ||
|
||
}); |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define(['exports', './generated-dep'], function (exports, dep) { 'use strict'; | ||
|
||
const id = 'emitted'; | ||
console.log(id, dep.value); | ||
|
||
exports.id = id; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}); |
7 changes: 7 additions & 0 deletions
7
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
define(['./generated-dep', './generated-emitted'], function (dep, emitted) { 'use strict'; | ||
|
||
console.log(emitted.id); | ||
|
||
console.log('main', dep.value); | ||
|
||
}); |
5 changes: 5 additions & 0 deletions
5
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/cjs/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
var value = 42; | ||
|
||
exports.value = value; |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/cjs/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
var dep = require('./generated-dep.js'); | ||
|
||
const id = 'emitted'; | ||
console.log(id, dep.value); | ||
|
||
exports.id = id; |
8 changes: 8 additions & 0 deletions
8
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/cjs/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
var dep = require('./generated-dep.js'); | ||
var emitted = require('./generated-emitted.js'); | ||
|
||
console.log(emitted.id); | ||
|
||
console.log('main', dep.value); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/es/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var value = 42; | ||
|
||
export { value as v }; |
6 changes: 6 additions & 0 deletions
6
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/es/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { v as value } from './generated-dep.js'; | ||
|
||
const id = 'emitted'; | ||
console.log(id, value); | ||
|
||
export { id }; |
6 changes: 6 additions & 0 deletions
6
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/es/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { v as value } from './generated-dep.js'; | ||
import { id } from './generated-emitted.js'; | ||
|
||
console.log(id); | ||
|
||
console.log('main', value); |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-dep.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
var value = exports('v', 42); | ||
|
||
} | ||
}; | ||
}); |
15 changes: 15 additions & 0 deletions
15
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
System.register(['./generated-dep.js'], function (exports) { | ||
'use strict'; | ||
var value; | ||
return { | ||
setters: [function (module) { | ||
value = module.v; | ||
}], | ||
execute: function () { | ||
|
||
const id = exports('id', 'emitted'); | ||
console.log(id, value); | ||
|
||
} | ||
}; | ||
}); |
18 changes: 18 additions & 0 deletions
18
test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
System.register(['./generated-dep.js', './generated-emitted.js'], function () { | ||
'use strict'; | ||
var value, id; | ||
return { | ||
setters: [function (module) { | ||
value = module.v; | ||
}, function (module) { | ||
id = module.id; | ||
}], | ||
execute: function () { | ||
|
||
console.log(id); | ||
|
||
console.log('main', value); | ||
|
||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 42; |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/emit-file/emit-chunk-order2/dep2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { id } from 'emitted'; | ||
|
||
console.log(id); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/emit-file/emit-chunk-order2/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import value from './dep.js'; | ||
import './dep2.js'; | ||
console.log('main', value); |