Skip to content

Commit 3a46843

Browse files
committed
Put current data under an "entrypoints" key in the entrypoints.json file
1 parent bb11e74 commit 3a46843

File tree

2 files changed

+94
-79
lines changed

2 files changed

+94
-79
lines changed

lib/plugins/entry-files-manifest.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,25 @@ const copyEntryTmpName = require('../utils/copyEntryTmpName');
1515
const AssetsPlugin = require('assets-webpack-plugin');
1616

1717
function processOutput(assets) {
18-
if (assets.hasOwnProperty(copyEntryTmpName)) {
19-
delete assets[copyEntryTmpName];
20-
}
21-
if (assets.hasOwnProperty(sharedEntryTmpName)) {
22-
delete assets[sharedEntryTmpName];
18+
for (const entry of [copyEntryTmpName, sharedEntryTmpName]) {
19+
delete assets[entry];
2320
}
21+
2422
// This will iterate over all the entry points and remove the / from the start of the paths. It also converts the
2523
// one file entries into an array of one entry since that was how the entry point file was before this change.
2624
for (const asset in assets) {
2725
for (const fileType in assets[asset]) {
28-
if (Array.isArray(assets[asset][fileType])) {
29-
assets[asset][fileType] = assets[asset][fileType].map(buildPath => buildPath.replace(/^\//g, ''));
30-
} else {
31-
assets[asset][fileType] = [assets[asset][fileType].replace(/^\//g, '')];
26+
if (!Array.isArray(assets[asset][fileType])) {
27+
assets[asset][fileType] = [assets[asset][fileType]];
3228
}
29+
30+
assets[asset][fileType] = assets[asset][fileType].map(buildPath => buildPath.replace(/^\//g, ''));
3331
}
3432
}
35-
return JSON.stringify(assets);
33+
34+
return JSON.stringify({
35+
entrypoints: assets
36+
});
3637
}
3738

3839
/**

test/functional.js

Lines changed: 83 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,19 @@ describe('Functional tests using webpack', function() {
102102
);
103103

104104
webpackAssert.assertOutputJsonFileMatches('entrypoints.json', {
105-
main: {
106-
js: ['build/runtime.js', 'build/main.js']
107-
},
108-
font: {
109-
js: ['build/runtime.js'],
110-
css: ['build/font.css']
111-
},
112-
bg: {
113-
js: ['build/runtime.js'],
114-
css: ['build/bg.css']
115-
},
105+
entrypoints: {
106+
main: {
107+
js: ['build/runtime.js', 'build/main.js']
108+
},
109+
font: {
110+
js: ['build/runtime.js'],
111+
css: ['build/font.css']
112+
},
113+
bg: {
114+
js: ['build/runtime.js'],
115+
css: ['build/bg.css']
116+
}
117+
}
116118
});
117119

118120
done();
@@ -131,14 +133,16 @@ describe('Functional tests using webpack', function() {
131133

132134
testSetup.runWebpack(config, (webpackAssert) => {
133135
webpackAssert.assertOutputJsonFileMatches('entrypoints.json', {
134-
main: {
135-
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/main.js'],
136-
css: ['build/main~other.css']
137-
},
138-
other: {
139-
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/other.js'],
140-
css: ['build/main~other.css']
141-
},
136+
entrypoints: {
137+
main: {
138+
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/main.js'],
139+
css: ['build/main~other.css']
140+
},
141+
other: {
142+
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/other.js'],
143+
css: ['build/main~other.css']
144+
}
145+
}
142146
});
143147

144148
done();
@@ -689,14 +693,16 @@ describe('Functional tests using webpack', function() {
689693
// make sure runtime.js is here
690694
// but the _tmp_shared entry is NOT here
691695
webpackAssert.assertOutputJsonFileMatches('entrypoints.json', {
692-
main: {
693-
js: ['build/runtime.js', 'build/shared.js', 'build/main.js'],
694-
css: ['build/shared.css']
695-
},
696-
other: {
697-
js: ['build/runtime.js', 'build/shared.js', 'build/other.js'],
698-
css: ['build/shared.css']
699-
},
696+
entrypoints: {
697+
main: {
698+
js: ['build/runtime.js', 'build/shared.js', 'build/main.js'],
699+
css: ['build/shared.css']
700+
},
701+
other: {
702+
js: ['build/runtime.js', 'build/shared.js', 'build/other.js'],
703+
css: ['build/shared.css']
704+
}
705+
}
700706
});
701707

702708
testSetup.requestTestPage(
@@ -1613,14 +1619,16 @@ module.exports = {
16131619

16141620
testSetup.runWebpack(config, (webpackAssert) => {
16151621
webpackAssert.assertOutputJsonFileMatches('entrypoints.json', {
1616-
main: {
1617-
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/main.js'],
1618-
css: ['build/main~other.css']
1619-
},
1620-
other: {
1621-
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/other.js'],
1622-
css: ['build/main~other.css']
1623-
},
1622+
entrypoints: {
1623+
main: {
1624+
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/main.js'],
1625+
css: ['build/main~other.css']
1626+
},
1627+
other: {
1628+
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main~other.js', 'build/other.js'],
1629+
css: ['build/main~other.css']
1630+
}
1631+
}
16241632
});
16251633

16261634
// make split chunks are correct in manifest
@@ -1643,24 +1651,26 @@ module.exports = {
16431651

16441652
testSetup.runWebpack(config, (webpackAssert) => {
16451653
webpackAssert.assertOutputJsonFileMatches('entrypoints.json', {
1646-
main: {
1647-
js: [
1648-
'http://localhost:8080/build/runtime.js',
1649-
'http://localhost:8080/build/vendors~main~other.js',
1650-
'http://localhost:8080/build/main~other.js',
1651-
'http://localhost:8080/build/main.js'
1652-
],
1653-
css: ['http://localhost:8080/build/main~other.css']
1654-
},
1655-
other: {
1656-
js: [
1657-
'http://localhost:8080/build/runtime.js',
1658-
'http://localhost:8080/build/vendors~main~other.js',
1659-
'http://localhost:8080/build/main~other.js',
1660-
'http://localhost:8080/build/other.js'
1661-
],
1662-
css: ['http://localhost:8080/build/main~other.css']
1663-
},
1654+
entrypoints: {
1655+
main: {
1656+
js: [
1657+
'http://localhost:8080/build/runtime.js',
1658+
'http://localhost:8080/build/vendors~main~other.js',
1659+
'http://localhost:8080/build/main~other.js',
1660+
'http://localhost:8080/build/main.js'
1661+
],
1662+
css: ['http://localhost:8080/build/main~other.css']
1663+
},
1664+
other: {
1665+
js: [
1666+
'http://localhost:8080/build/runtime.js',
1667+
'http://localhost:8080/build/vendors~main~other.js',
1668+
'http://localhost:8080/build/main~other.js',
1669+
'http://localhost:8080/build/other.js'
1670+
],
1671+
css: ['http://localhost:8080/build/main~other.css']
1672+
}
1673+
}
16641674
});
16651675

16661676
// make split chunks are correct in manifest
@@ -1683,14 +1693,16 @@ module.exports = {
16831693
testSetup.runWebpack(config, (webpackAssert) => {
16841694
// in production, we hash the chunk names to avoid exposing any extra details
16851695
webpackAssert.assertOutputJsonFileMatches('entrypoints.json', {
1686-
main: {
1687-
js: ['build/runtime.js', 'build/vendors~cc515e6e.js', 'build/default~cc515e6e.js', 'build/main.js'],
1688-
css: ['build/default~cc515e6e.css']
1689-
},
1690-
other: {
1691-
js: ['build/runtime.js', 'build/vendors~cc515e6e.js', 'build/default~cc515e6e.js', 'build/other.js'],
1692-
css: ['build/default~cc515e6e.css']
1693-
},
1696+
entrypoints: {
1697+
main: {
1698+
js: ['build/runtime.js', 'build/vendors~cc515e6e.js', 'build/default~cc515e6e.js', 'build/main.js'],
1699+
css: ['build/default~cc515e6e.css']
1700+
},
1701+
other: {
1702+
js: ['build/runtime.js', 'build/vendors~cc515e6e.js', 'build/default~cc515e6e.js', 'build/other.js'],
1703+
css: ['build/default~cc515e6e.css']
1704+
}
1705+
}
16941706
});
16951707

16961708
// make split chunks are correct in manifest
@@ -1712,14 +1724,16 @@ module.exports = {
17121724

17131725
testSetup.runWebpack(config, (webpackAssert) => {
17141726
webpackAssert.assertOutputJsonFileMatches('entrypoints.json', {
1715-
main: {
1716-
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main.js']
1717-
},
1718-
other: {
1719-
// the 0.[hash].js is because the "no_require" module was already split to this
1720-
// so, it has that filename, instead of following the normal pattern
1721-
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/0.js', 'build/other.js']
1722-
},
1727+
entrypoints: {
1728+
main: {
1729+
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/main.js']
1730+
},
1731+
other: {
1732+
// the 0.[hash].js is because the "no_require" module was already split to this
1733+
// so, it has that filename, instead of following the normal pattern
1734+
js: ['build/runtime.js', 'build/vendors~main~other.js', 'build/0.js', 'build/other.js']
1735+
}
1736+
}
17231737
});
17241738

17251739
// make split chunks are correct in manifest

0 commit comments

Comments
 (0)