Skip to content

Commit 119708f

Browse files
committed
chore: use advancedChunks instead of manualChunks
1 parent 6006b56 commit 119708f

File tree

5 files changed

+46
-25
lines changed

5 files changed

+46
-25
lines changed

playground/css-codesplit/__tests__/css-codesplit-consistent.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ beforeEach(async () => {
88
for (let i = 0; i < 5; i++) {
99
describe.runIf(isBuild)('css-codesplit build', () => {
1010
test('should be consistent with same content', () => {
11-
expect(findAssetFile(/style-.+\.css/)).toMatch('h2{color:#00f}')
12-
expect(findAssetFile(/style2-.+\.css/)).toBe('')
11+
expect(findAssetFile(/style2-.+\.css/)).toMatch('h2{color:#00f}')
12+
expect(findAssetFile(/style-.+\.css/)).toBe('')
1313
})
1414
})
1515
}

playground/css-codesplit/vite.config.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@ export default defineConfig({
1313
'shared-css-no-js': resolve(__dirname, 'shared-css-no-js.html'),
1414
},
1515
output: {
16-
manualChunks(id) {
17-
// make `chunk.css` it's own chunk for easier testing of pure css chunks
18-
if (id.includes('chunk.css')) {
19-
return 'chunk'
20-
}
16+
// manualChunks(id) {
17+
// // make `chunk.css` it's own chunk for easier testing of pure css chunks
18+
// if (id.includes('chunk.css')) {
19+
// return 'chunk'
20+
// }
21+
// },
22+
advancedChunks: {
23+
groups: [
24+
// make `chunk.css` it's own chunk for easier testing of pure css chunks
25+
{
26+
name: 'chunk',
27+
test: 'chunk.css',
28+
},
29+
],
2130
},
2231
},
2332
},

playground/js-sourcemap/__tests__/js-sourcemap.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe.runIf(isBuild)('build tests', () => {
140140
expect(formatSourcemapForSnapshot(JSON.parse(map))).toMatchInlineSnapshot(`
141141
{
142142
"ignoreList": [],
143-
"mappings": ";+8BAAA,OAAO,2BAAuB,EAAC,wBAE/B,QAAQ,IAAI,uBAAuB",
143+
"mappings": ";4jCAAA,OAAO,6BAAuB,wBAE9B,QAAQ,IAAI",
144144
"sources": [
145145
"../../after-preload-dynamic.js",
146146
],
@@ -156,7 +156,7 @@ describe.runIf(isBuild)('build tests', () => {
156156
// verify sourcemap comment is preserved at the last line
157157
const js = findAssetFile(/after-preload-dynamic-[-\w]{8}\.js$/)
158158
expect(js).toMatch(
159-
/\n\/\/# sourceMappingURL=after-preload-dynamic-[-\w]{8}\.js\.map\n$/,
159+
/\n\/\/# sourceMappingURL=after-preload-dynamic-[-\w]{8}\.js\.map\n?$/,
160160
)
161161
})
162162

@@ -177,7 +177,7 @@ describe.runIf(isBuild)('build tests', () => {
177177
const map = findAssetFile(/with-define-object.*\.js\.map/)
178178
expect(formatSourcemapForSnapshot(JSON.parse(map))).toMatchInlineSnapshot(`
179179
{
180-
"mappings": "qBAEA,SAASA,GAAO,CACJC,GACZ,CAEA,SAASA,GAAY,CAEX,QAAA,MAAM,qBAAsBC,CAAkB,CACxD,CAEAF,EAAK",
180+
"mappings": "qBAEA,SAAS,GAAO,CACd,EAAA,CACF,CAEA,SAAS,GAAY,CAEnB,QAAQ,MAAM,qBAAsB,CAAA,CACtC,CAEA,EAAA",
181181
"sources": [
182182
"../../with-define-object.ts",
183183
],

playground/js-sourcemap/vite.config.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,33 @@ export default defineConfig({
1111
sourcemap: true,
1212
rollupOptions: {
1313
output: {
14-
manualChunks(name) {
15-
if (name.endsWith('after-preload-dynamic.js')) {
16-
return 'after-preload-dynamic'
17-
}
18-
if (name.endsWith('after-preload-dynamic-hashbang.js')) {
19-
return 'after-preload-dynamic-hashbang'
20-
}
21-
if (name.endsWith('after-preload-dynamic-no-dep.js')) {
22-
return 'after-preload-dynamic-no-dep'
23-
}
24-
if (name.includes('with-define-object')) {
25-
return 'with-define-object'
26-
}
14+
// manualChunks(name) {
15+
// if (name.endsWith('after-preload-dynamic.js')) {
16+
// return 'after-preload-dynamic'
17+
// }
18+
// if (name.endsWith('after-preload-dynamic-hashbang.js')) {
19+
// return 'after-preload-dynamic-hashbang'
20+
// }
21+
// if (name.endsWith('after-preload-dynamic-no-dep.js')) {
22+
// return 'after-preload-dynamic-no-dep'
23+
// }
24+
// if (name.includes('with-define-object')) {
25+
// return 'with-define-object'
26+
// }
27+
// },
28+
advancedChunks: {
29+
groups: [
30+
{ name: 'after-preload-dynamic', test: 'after-preload-dynamic.js' },
31+
{
32+
name: 'after-preload-dynamic-hashbang',
33+
test: 'after-preload-dynamic-hashbang.js',
34+
},
35+
{
36+
name: 'after-preload-dynamic-no-dep',
37+
test: 'after-preload-dynamic-no-dep.js',
38+
},
39+
{ name: 'with-define-object', test: 'with-define-object' },
40+
],
2741
},
2842
banner(chunk) {
2943
if (chunk.name.endsWith('after-preload-dynamic-hashbang')) {

vitest.config.e2e.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ export default defineConfig({
1818
...(isBuild
1919
? [
2020
'./playground/backend-integration/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/2207
21-
'./playground/css-codesplit/**/*.spec.[tj]s', // manualChunks
2221
'./playground/css-dynamic-import/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/1842
2322
'./playground/dynamic-import/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/1842, https://github.com/rolldown/rolldown/issues/1843
2423
'./playground/external/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/2041
2524
'./playground/glob-import/**/*.spec.[tj]s', // remove empty CSS generate chunk https://github.com/rolldown/rolldown/issues/1842
26-
'./playground/js-sourcemap/**/*.spec.[tj]s', // manualChunks
2725
'./playground/lib/**/*.spec.[tj]s', // umd format
2826
'./playground/object-hooks/**/*.spec.[tj]s', // object hook sequential
2927
'./playground/optimize-deps/**/*.spec.[tj]s', // https://github.com/rolldown/rolldown/issues/2031

0 commit comments

Comments
 (0)