Skip to content

Commit 1dc7cb4

Browse files
sapphi-redunderfinhi-ogawa
committed
feat: use rolldown for build
Co-authored-by: underfin <[email protected]> Co-authored-by: Hiroshi Ogawa <[email protected]>
1 parent 4546b3e commit 1dc7cb4

File tree

95 files changed

+822
-628
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+822
-628
lines changed

packages/plugin-legacy/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
}
2424
},
2525
"scripts": {
26-
"dev": "unbuild --stub",
27-
"build": "unbuild && pnpm run patch-cjs",
26+
"//dev": "unbuild --stub",
27+
"//build": "unbuild && pnpm run patch-cjs",
2828
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
2929
"prepublishOnly": "npm run build"
3030
},

packages/vite/LICENSE.md

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,11 @@ Repository: lukeed/polka
360360

361361
---------------------------------------
362362

363-
## @rollup/plugin-alias, @rollup/plugin-commonjs, @rollup/plugin-dynamic-import-vars, @rollup/pluginutils
363+
## @rollup/plugin-alias, @rollup/plugin-dynamic-import-vars, @rollup/pluginutils
364364
License: MIT
365365
By: Johannes Stein
366366
Repository: rollup/plugins
367367

368-
License: MIT
369-
By: Rich Harris
370-
Repository: rollup/plugins
371-
372368
License: MIT
373369
By: LarsDenBakker
374370
Repository: rollup/plugins
@@ -584,38 +580,6 @@ Repository: git+https://github.com/paulmillr/chokidar.git
584580
585581
---------------------------------------
586582

587-
## commondir, shell-quote
588-
License: MIT
589-
By: James Halliday
590-
Repositories: http://github.com/substack/node-commondir.git, http://github.com/ljharb/shell-quote.git
591-
592-
> The MIT License
593-
>
594-
> Copyright (c) 2013 James Halliday ([email protected])
595-
>
596-
> Permission is hereby granted, free of charge,
597-
> to any person obtaining a copy of this software and
598-
> associated documentation files (the "Software"), to
599-
> deal in the Software without restriction, including
600-
> without limitation the rights to use, copy, modify,
601-
> merge, publish, distribute, sublicense, and/or sell
602-
> copies of the Software, and to permit persons to whom
603-
> the Software is furnished to do so,
604-
> subject to the following conditions:
605-
>
606-
> The above copyright notice and this permission notice
607-
> shall be included in all copies or substantial portions of the Software.
608-
>
609-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
610-
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
611-
> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
612-
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
613-
> ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
614-
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
615-
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
616-
617-
---------------------------------------
618-
619583
## connect
620584
License: MIT
621585
By: TJ Holowaychuk, Douglas Christopher Wilson, Jonathan Ong, Tim Caswell
@@ -1298,13 +1262,6 @@ Repository: micromatch/is-glob
12981262
12991263
---------------------------------------
13001264

1301-
## is-reference
1302-
License: MIT
1303-
By: Rich Harris
1304-
Repository: git+https://github.com/Rich-Harris/is-reference.git
1305-
1306-
---------------------------------------
1307-
13081265
## isexe, which
13091266
License: ISC
13101267
By: Isaac Z. Schlueter
@@ -2147,6 +2104,38 @@ Repository: kevva/shebang-command
21472104
21482105
---------------------------------------
21492106

2107+
## shell-quote
2108+
License: MIT
2109+
By: James Halliday
2110+
Repository: http://github.com/ljharb/shell-quote.git
2111+
2112+
> The MIT License
2113+
>
2114+
> Copyright (c) 2013 James Halliday ([email protected])
2115+
>
2116+
> Permission is hereby granted, free of charge,
2117+
> to any person obtaining a copy of this software and
2118+
> associated documentation files (the "Software"), to
2119+
> deal in the Software without restriction, including
2120+
> without limitation the rights to use, copy, modify,
2121+
> merge, publish, distribute, sublicense, and/or sell
2122+
> copies of the Software, and to permit persons to whom
2123+
> the Software is furnished to do so,
2124+
> subject to the following conditions:
2125+
>
2126+
> The above copyright notice and this permission notice
2127+
> shall be included in all copies or substantial portions of the Software.
2128+
>
2129+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2130+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2131+
> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2132+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
2133+
> ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2134+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2135+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2136+
2137+
---------------------------------------
2138+
21502139
## sirv
21512140
License: MIT
21522141
By: Luke Edwards

packages/vite/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@
8787
"dependencies": {
8888
"esbuild": "^0.25.0",
8989
"postcss": "^8.5.3",
90-
"rolldown": "1.0.0-beta.3-commit.62fba31",
91-
"rollup": "^4.30.1"
90+
"rolldown": "1.0.0-beta.3-commit.62fba31"
9291
},
9392
"optionalDependencies": {
9493
"fsevents": "~2.3.3"
@@ -97,6 +96,7 @@
9796
"@ampproject/remapping": "^2.3.0",
9897
"@babel/parser": "^7.26.9",
9998
"@jridgewell/trace-mapping": "^0.3.25",
99+
"@oxc-project/types": "^0.53.0",
100100
"@polka/compression": "^1.0.0-next.25",
101101
"@rollup/plugin-alias": "^5.1.1",
102102
"@rollup/plugin-commonjs": "^28.0.2",
@@ -138,6 +138,7 @@
138138
"postcss-load-config": "^6.0.1",
139139
"postcss-modules": "^6.0.1",
140140
"resolve.exports": "^2.0.3",
141+
"rollup": "^4.30.1",
141142
"rollup-plugin-dts": "^6.1.1",
142143
"rollup-plugin-esbuild": "^6.2.1",
143144
"rollup-plugin-license": "^3.6.0",

packages/vite/rollup.dts.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ const identifierWithTrailingDollarRE = /\b(\w+)\$\d+\b/g
4747
* the module that imports the identifer as a named import alias
4848
*/
4949
const identifierReplacements: Record<string, Record<string, string>> = {
50-
rollup: {
51-
Plugin$1: 'rollup.Plugin',
52-
PluginContext$1: 'rollup.PluginContext',
53-
MinimalPluginContext$1: 'rollup.MinimalPluginContext',
54-
TransformPluginContext$1: 'rollup.TransformPluginContext',
55-
TransformResult$1: 'rollup.TransformResult',
50+
rolldown: {
51+
Plugin$1: 'rolldown.Plugin',
52+
PluginContext$1: 'rolldown.PluginContext',
53+
MinimalPluginContext$1: 'rolldown.MinimalPluginContext',
54+
TransformPluginContext$1: 'rolldown.TransformPluginContext',
55+
TransformResult$1: 'rolldown.TransformResult',
5656
},
5757
esbuild: {
5858
TransformResult$2: 'esbuild_TransformResult',

packages/vite/src/node/__tests__/build.spec.ts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import type {
88
LogLevel,
99
OutputChunk,
1010
OutputOptions,
11+
RolldownOptions,
12+
RolldownOutput,
1113
RollupLog,
12-
RollupOptions,
13-
RollupOutput,
14-
} from 'rollup'
14+
} from 'rolldown'
1515
import type { LibraryFormats, LibraryOptions } from '../build'
1616
import {
1717
build,
@@ -62,7 +62,7 @@ describe('build', () => {
6262
},
6363
},
6464
],
65-
})) as RollupOutput
65+
})) as RolldownOutput
6666
}
6767
const result = await Promise.all([
6868
buildProject('red'),
@@ -121,7 +121,7 @@ describe('build', () => {
121121
},
122122
},
123123
],
124-
})) as RollupOutput
124+
})) as RolldownOutput
125125
}
126126
const result = await Promise.all([
127127
buildProject('yellow'),
@@ -131,13 +131,13 @@ describe('build', () => {
131131
{
132132
"changed": [
133133
"index",
134-
"_foo",
135134
"_bar",
135+
"_foo",
136136
"_baz.css",
137137
],
138138
"unchanged": [
139-
"_foo.css",
140139
"_bar.css",
140+
"_foo.css",
141141
"undefined",
142142
],
143143
}
@@ -198,7 +198,7 @@ describe('build', () => {
198198
},
199199
},
200200
],
201-
})) as RollupOutput
201+
})) as RolldownOutput
202202

203203
const foo = esBundle.output.find(
204204
(chunk) => chunk.type === 'chunk' && chunk.isEntry,
@@ -245,7 +245,7 @@ describe('build', () => {
245245
},
246246
},
247247
],
248-
})) as RollupOutput[]
248+
})) as RolldownOutput[]
249249

250250
const foo = esBundle.output.find(
251251
(chunk) => chunk.fileName === 'foo.js',
@@ -756,7 +756,7 @@ describe('resolveBuildOutputs', () => {
756756
},
757757
})
758758
const result = await builder.build(builder.environments.ssr)
759-
expect((result as RollupOutput).output[0].code).not.toContain('preload')
759+
expect((result as RolldownOutput).output[0].code).not.toContain('preload')
760760
})
761761

762762
test('ssr custom', async () => {
@@ -777,7 +777,7 @@ describe('resolveBuildOutputs', () => {
777777
},
778778
})
779779
const result = await builder.build(builder.environments.custom)
780-
expect((result as RollupOutput).output[0].code).not.toContain('preload')
780+
expect((result as RolldownOutput).output[0].code).not.toContain('preload')
781781
})
782782
})
783783

@@ -858,14 +858,14 @@ test.for([true, false])(
858858
const custom1 = await builder.build(builder.environments.custom1)
859859
const custom2 = await builder.build(builder.environments.custom2)
860860
expect(
861-
([client, ssr, custom1, custom2] as RollupOutput[]).map(
861+
([client, ssr, custom1, custom2] as RolldownOutput[]).map(
862862
(o) => o.output[0].code.split('\n').length,
863863
),
864864
).toEqual([2, 5, 2, 5])
865865
},
866866
)
867867

868-
test('adjust worker build error for worker.format', async () => {
868+
test.skip('adjust worker build error for worker.format', async () => {
869869
try {
870870
await build({
871871
root: resolve(__dirname, 'fixtures/worker-dynamic'),
@@ -886,15 +886,16 @@ test('adjust worker build error for worker.format', async () => {
886886
expect.unreachable()
887887
})
888888

889-
describe('onRollupLog', () => {
889+
// rolldown does not append plugin name to the message automatically
890+
describe.skip('onRollupLog', () => {
890891
const pluginName = 'rollup-plugin-test'
891892
const msgInfo = 'This is the INFO message.'
892893
const msgWarn = 'This is the WARN message.'
893894
const buildProject = async (
894895
level: LogLevel | 'error',
895896
message: string | RollupLog,
896897
logger: Logger,
897-
options?: Pick<RollupOptions, 'onLog' | 'onwarn'>,
898+
options?: Pick<RolldownOptions, 'onLog' | 'onwarn'>,
898899
) => {
899900
await build({
900901
root: resolve(__dirname, 'packages/build-project'),
@@ -1059,7 +1060,7 @@ test('watch rebuild manifest', async (ctx) => {
10591060
},
10601061
})
10611062

1062-
function getManifestKeys(output: RollupOutput) {
1063+
function getManifestKeys(output: RolldownOutput) {
10631064
return Object.keys(
10641065
JSON.parse(
10651066
(output.output.find((o) => o.fileName === '.vite/manifest.json') as any)
@@ -1069,7 +1070,7 @@ test('watch rebuild manifest', async (ctx) => {
10691070
}
10701071

10711072
const result = await builder.build(builder.environments.client)
1072-
expect(getManifestKeys(result as RollupOutput)).toMatchInlineSnapshot(`
1073+
expect(getManifestKeys(result as RolldownOutput)).toMatchInlineSnapshot(`
10731074
[
10741075
"dep.js",
10751076
"entry.js",
@@ -1087,7 +1088,7 @@ test('watch rebuild manifest', async (ctx) => {
10871088
})
10881089

10891090
const result2 = await builder.build(builder.environments.client)
1090-
expect(getManifestKeys(result2 as RollupOutput)).toMatchInlineSnapshot(`
1091+
expect(getManifestKeys(result2 as RolldownOutput)).toMatchInlineSnapshot(`
10911092
[
10921093
"entry.js",
10931094
]
@@ -1099,8 +1100,8 @@ test('watch rebuild manifest', async (ctx) => {
10991100
* ensure that the chunk code is the same. if not, the chunk hash should have changed.
11001101
*/
11011102
function assertOutputHashContentChange(
1102-
output1: RollupOutput,
1103-
output2: RollupOutput,
1103+
output1: RolldownOutput,
1104+
output2: RolldownOutput,
11041105
) {
11051106
for (const chunk of output1.output) {
11061107
if (chunk.type === 'chunk') {
@@ -1117,7 +1118,10 @@ function assertOutputHashContentChange(
11171118
}
11181119
}
11191120

1120-
function getOutputHashChanges(output1: RollupOutput, output2: RollupOutput) {
1121+
function getOutputHashChanges(
1122+
output1: RolldownOutput,
1123+
output2: RolldownOutput,
1124+
) {
11211125
const map1 = Object.fromEntries(
11221126
output1.output.map((o) => [o.name, o.fileName]),
11231127
)

packages/vite/src/node/__tests__/environment.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'node:path'
22
import { describe, expect, onTestFinished, test } from 'vitest'
3-
import type { RollupOutput } from 'rollup'
3+
import type { RolldownOutput } from 'rolldown'
44
import { createServer } from '../server'
55
import type { InlineConfig } from '../config'
66
import { createBuilder } from '../build'
@@ -167,7 +167,7 @@ describe('custom environment conditions', () => {
167167
const results: Record<string, unknown> = {}
168168
for (const key of ['ssr', 'worker', 'custom1', 'custom1_2']) {
169169
const output = await builder.build(builder.environments[key])
170-
const chunk = (output as RollupOutput).output[0]
170+
const chunk = (output as RolldownOutput).output[0]
171171
const mod = await import(
172172
path.join(
173173
import.meta.dirname,

packages/vite/src/node/__tests__/plugins/modulePreloadPolyfill/__snapshots__/modulePreloadPolyfill.spec.ts.snap

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,28 @@ exports[`load > doesn't load modulepreload polyfill when format is cjs 1`] = `
88
exports[`load > loads modulepreload polyfill 1`] = `
99
"(function polyfill() {
1010
const relList = document.createElement("link").relList;
11-
if (relList && relList.supports && relList.supports("modulepreload")) {
12-
return;
13-
}
14-
for (const link of document.querySelectorAll('link[rel="modulepreload"]')) {
15-
processPreload(link);
16-
}
11+
if (relList && relList.supports && relList.supports("modulepreload")) return;
12+
for (const link of document.querySelectorAll('link[rel="modulepreload"]')) processPreload(link);
1713
new MutationObserver((mutations) => {
1814
for (const mutation of mutations) {
19-
if (mutation.type !== "childList") {
20-
continue;
21-
}
22-
for (const node of mutation.addedNodes) {
23-
if (node.tagName === "LINK" && node.rel === "modulepreload")
24-
processPreload(node);
25-
}
15+
if (mutation.type !== "childList") continue;
16+
for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node);
2617
}
27-
}).observe(document, { childList: true, subtree: true });
18+
}).observe(document, {
19+
childList: true,
20+
subtree: true
21+
});
2822
function getFetchOpts(link) {
2923
const fetchOpts = {};
3024
if (link.integrity) fetchOpts.integrity = link.integrity;
3125
if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
32-
if (link.crossOrigin === "use-credentials")
33-
fetchOpts.credentials = "include";
26+
if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include";
3427
else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
3528
else fetchOpts.credentials = "same-origin";
3629
return fetchOpts;
3730
}
3831
function processPreload(link) {
39-
if (link.ep)
40-
return;
32+
if (link.ep) return;
4133
link.ep = true;
4234
const fetchOpts = getFetchOpts(link);
4335
fetch(link.href, fetchOpts);

0 commit comments

Comments
 (0)