Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Rolldown with Vite v6 #43

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b0f7e84
feat: use rolldown in the dep optimizer
sapphi-red Sep 11, 2024
622d987
feat: use rolldown for build
sapphi-red Sep 12, 2024
ba540ba
chore: skip plugin-legacy build
sapphi-red Sep 12, 2024
a23517c
chore: skip typecheck for now
sapphi-red Sep 12, 2024
7312f45
chore: 🤖 add justfile for faster dev
IWANABETHATGUY Aug 15, 2024
565c699
feat: add experimental.enableNativePlugin (#41)
IWANABETHATGUY Sep 10, 2024
5c972df
feat: native build plugins (#45) (#46)
IWANABETHATGUY Sep 12, 2024
a39bbf2
perf: reduce pre alias plugin in build mode
IWANABETHATGUY Sep 12, 2024
243ee96
feat: 🎸 add an new option to disable build report
IWANABETHATGUY Sep 13, 2024
2c8a013
feat: clone class plugins correctly
IWANABETHATGUY Sep 13, 2024
1dfdd16
feat: support native define
sapphi-red Sep 18, 2024
c2d46aa
feat: use filter for plugins (#49) (#50) (#51) (#52) (#53)
sapphi-red Sep 18, 2024
c484847
perf: ⚡️ use default resolver (#56)
IWANABETHATGUY Sep 14, 2024
f260d35
chore: fix native manifest plugin
sapphi-red Sep 19, 2024
30722bd
feat: handle non-relative paths by Vite's resolver for enableNativePl…
sapphi-red Sep 19, 2024
9acd079
fix: 🐛 lint (#58)
IWANABETHATGUY Sep 20, 2024
0708087
chore: bump rolldown
sapphi-red Sep 24, 2024
ab51cee
chore: skip data uri by load fallback plugin for native data uri hand…
sapphi-red Sep 24, 2024
582d4ec
chore: remove browser field edge case test
sapphi-red Sep 25, 2024
cbee042
chore: bump rolldown
sapphi-red Sep 27, 2024
a9d5f4c
fix: define import.meta.env
sapphi-red Sep 27, 2024
a4034bd
chore: use advancedChunks instead of manualChunks
sapphi-red Oct 1, 2024
2268aec
chore: bump rolldown and resolve all relative path with native plugin
sapphi-red Oct 1, 2024
4a7c5d7
feat: convert `optimizeDeps.esbuildOptions` to `optimizeDeps.rollupOp…
sapphi-red Oct 4, 2024
3e2abc0
fix: optimizeDeps test pass on windows
sapphi-red Oct 9, 2024
4d5874b
chore: bump rolldown
sapphi-red Oct 9, 2024
e341fcb
chore: make some tests passing
sapphi-red Oct 9, 2024
47239cf
chore: make glob-import test pass with workarounds
sapphi-red Oct 9, 2024
82bb8e8
chore: run worker-es tests
sapphi-red Oct 9, 2024
b2c6113
fix: use preliminaryFileName for chunkMetadata key
sapphi-red Oct 10, 2024
a438d11
chore: bump rolldown
sapphi-red Oct 11, 2024
c188ada
feat: oxc tranformer (#60)
underfin Oct 11, 2024
6bc094f
feat: use `onlyRemoveTypeImports`
sapphi-red Oct 11, 2024
504ad37
chore: enable continuous release under rolldown-vite (#61)
yyx990803 Oct 12, 2024
727e891
feat: environment aware native plugins
sapphi-red Oct 15, 2024
cc411c2
feat: export transformWithOxc
underfin Oct 17, 2024
28e09b6
fix: build
underfin Oct 17, 2024
f6f9fbe
Merge pull request #62 from rolldown/export-transformWithOxc
underfin Oct 17, 2024
4fa494a
feat: add oxc jsxInclude and jsxExclude
underfin Oct 18, 2024
ae3c117
fix: ci
underfin Oct 18, 2024
e2b3bb0
fix: ci
underfin Oct 18, 2024
235186f
Update packages/vite/src/node/plugins/oxc.ts
underfin Oct 18, 2024
5e7d5c5
Update packages/vite/src/node/plugins/oxc.ts
underfin Oct 18, 2024
1d115b2
fix: format
underfin Oct 18, 2024
3a82b11
Merge pull request #63 from rolldown/add-oxc-jsx-include
underfin Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ jobs:
- name: Check formatting
run: pnpm prettier --check .

- name: Typecheck
run: pnpm run typecheck
# - name: Typecheck
# run: pnpm run typecheck

- name: Test docs
run: pnpm run test-docs
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ env:
on:
push:
branches:
- main
- rolldown-v6
issue_comment:
types: [created]

jobs:
build:
if: github.repository == 'vitejs/vite' && (github.event_name == 'push' || github.event.issue.pull_request && startsWith(github.event.comment.body, '/pkg-pr-new'))
if: github.repository == 'rolldown/vite' && (github.event_name == 'push' || github.event.issue.pull_request && startsWith(github.event.comment.body, '/pkg-pr-new'))
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -68,4 +68,4 @@ jobs:
working-directory: ./packages/vite
run: pnpm build

- run: pnpm dlx [email protected] publish --compact --pnpm ./packages/vite
- run: pnpm dlx [email protected] publish --pnpm ./packages/vite
13 changes: 13 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
build-vite:
pnpm --filter vite run build-bundle

test-serve:
pnpm run test-serve

test-build:
pnpm run test-build

test: test-serve test-build

fmt:
pnpm --filter vite run format
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"simple-git-hooks": "^2.11.1",
"tslib": "^2.7.0",
"tsx": "^4.19.1",
"typescript": "^5.5.3",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0",
"vite": "workspace:*",
"vitest": "^2.1.2"
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
},
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
Expand Down
83 changes: 0 additions & 83 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -500,35 +500,6 @@ Repository: rollup/plugins

---------------------------------------

## @rollup/plugin-commonjs
License: MIT
By: Rich Harris
Repository: rollup/plugins

> The MIT License (MIT)
>
> Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.

---------------------------------------

## @rollup/plugin-dynamic-import-vars
License: MIT
By: LarsDenBakker
Expand Down Expand Up @@ -788,38 +759,6 @@ Repository: git+https://github.com/paulmillr/chokidar.git

---------------------------------------

## commondir
License: MIT
By: James Halliday
Repository: http://github.com/substack/node-commondir.git

> The MIT License
>
> Copyright (c) 2013 James Halliday ([email protected])
>
> Permission is hereby granted, free of charge,
> to any person obtaining a copy of this software and
> associated documentation files (the "Software"), to
> deal in the Software without restriction, including
> without limitation the rights to use, copy, modify,
> merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom
> the Software is furnished to do so,
> subject to the following conditions:
>
> The above copyright notice and this permission notice
> shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
> ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---------------------------------------

## connect
License: MIT
By: TJ Holowaychuk, Douglas Christopher Wilson, Jonathan Ong, Tim Caswell
Expand Down Expand Up @@ -1327,21 +1266,6 @@ Repository: git+https://github.com/mcollina/fastq.git

---------------------------------------

## fdir
License: MIT
By: thecodrr
Repository: git+https://github.com/thecodrr/fdir.git

> Copyright 2023 Abdullah Atta
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---------------------------------------

## fill-range
License: MIT
By: Jon Schlinkert, Edo Rivai, Paul Miller, Rouven Weßling
Expand Down Expand Up @@ -1644,13 +1568,6 @@ Repository: jonschlinkert/is-number

---------------------------------------

## is-reference
License: MIT
By: Rich Harris
Repository: git+https://github.com/Rich-Harris/is-reference.git

---------------------------------------

## is-wsl
License: MIT
By: Sindre Sorhus
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"license": "MIT",
"author": "Evan You",
"description": "Native-ESM powered web dev build tool",
"description": "Vite on Rolldown preview",
"bin": {
"vite": "bin/vite.js"
},
Expand Down Expand Up @@ -87,6 +87,7 @@
"dependencies": {
"esbuild": "^0.24.0",
"postcss": "^8.4.47",
"rolldown": "https://pkg.pr.new/rolldown@e65437c",
"rollup": "^4.22.5"
},
"optionalDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/vite/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const nodeConfig = defineConfig({
'fsevents',
'lightningcss',
'rollup/parseAst',
'rolldown/experimental',
...Object.keys(pkg.dependencies),
],
plugins: [
Expand Down
15 changes: 10 additions & 5 deletions packages/vite/rollup.dts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const external = [
/^node:*/,
/^vite\//,
'rollup/parseAst',
'rolldown/experimental',
...Object.keys(pkg.dependencies),
// lightningcss types are bundled
...Object.keys(pkg.devDependencies).filter((d) => d !== 'lightningcss'),
Expand Down Expand Up @@ -46,11 +47,15 @@ const identifierWithTrailingDollarRE = /\b(\w+)\$\d+\b/g
* the module that imports the identifer as a named import alias
*/
const identifierReplacements: Record<string, Record<string, string>> = {
rollup: {
Plugin$1: 'rollup.Plugin',
PluginContext$1: 'rollup.PluginContext',
TransformPluginContext$1: 'rollup.TransformPluginContext',
TransformResult$2: 'rollup.TransformResult',
rolldown: {
Plugin$1: 'rolldown.Plugin',
PluginContext$1: 'rolldown.PluginContext',
TransformPluginContext$1: 'rolldown.TransformPluginContext',
TransformResult$3: 'rolldown.TransformResult',
},
'rolldown/experimental': {
TransformOptions$2: 'rolldown_experimental_TransformOptions',
TransformResult$2: 'rolldown_experimental_TransformResult',
},
esbuild: {
TransformResult$1: 'esbuild_TransformResult',
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/module-runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export class ModuleRunner {
dirname: isWindows ? toWindowsPath(dirname) : dirname,
url: href,
env: this.envProxy,
resolve(_id, _parent) {
resolve(_id, _parent?) {
throw new Error(
'[module runner] "import.meta.resolve" is not supported.',
)
Expand Down
22 changes: 11 additions & 11 deletions packages/vite/src/node/__tests__/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { basename, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import colors from 'picocolors'
import { describe, expect, test, vi } from 'vitest'
import type { OutputChunk, OutputOptions, RollupOutput } from 'rollup'
import type { OutputChunk, OutputOptions, RollupOutput } from 'rolldown'
import type { LibraryFormats, LibraryOptions } from '../build'
import {
build,
Expand Down Expand Up @@ -182,9 +182,9 @@ describe('resolveBuildOutputs', () => {
{
format: 'es',
},
{
format: 'umd',
},
// {
// format: 'umd',
// },
])
})

Expand Down Expand Up @@ -223,7 +223,7 @@ describe('resolveBuildOutputs', () => {
expect(resolveBuild).toThrowError(/Option "build\.lib\.name" is required/)
})

test('throws an error when lib.name is missing on umd format', () => {
test.skip('throws an error when lib.name is missing on umd format', () => {
const logger = createLogger()
const libOptions: LibraryOptions = { ...baseLibOptions, formats: ['umd'] }
const resolveBuild = () => resolveBuildOutputs(void 0, libOptions, logger)
Expand All @@ -242,7 +242,7 @@ describe('resolveBuildOutputs', () => {
)
})

test('throws an error when output.name is missing on umd format', () => {
test.skip('throws an error when output.name is missing on umd format', () => {
const logger = createLogger()
const libOptions: LibraryOptions = { ...baseLibOptions }
const outputs: OutputOptions[] = [{ format: 'umd' }]
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('resolveLibFilename', () => {
test('module package extensions', () => {
const formatsToFilenames: FormatsToFileNames = [
['es', 'my-lib.js'],
['umd', 'my-lib.umd.cjs'],
// ['umd', 'my-lib.umd.cjs'],
['cjs', 'my-lib.cjs'],
['iife', 'my-lib.iife.js'],
]
Expand Down Expand Up @@ -496,13 +496,13 @@ describe('resolveBuildOutputs', () => {

expect(resolveBuildOutputs(undefined, libOptions, {} as Logger)).toEqual([
{ format: 'es' },
{ format: 'umd' },
// { format: 'umd' },
])
expect(
resolveBuildOutputs({ name: 'A' }, libOptions, {} as Logger),
).toEqual([
{ format: 'es', name: 'A' },
{ format: 'umd', name: 'A' },
// { format: 'umd', name: 'A' },
])
expect(
resolveBuildOutputs([{ name: 'A' }], libOptions, {} as Logger),
Expand All @@ -529,7 +529,7 @@ describe('resolveBuildOutputs', () => {
).toEqual([{ name: 'A' }])
})

test('umd or iife: should not support multiple entries', () => {
test.skip('umd or iife: should not support multiple entries', () => {
;['umd', 'iife'].forEach((format) => {
expect(() =>
resolveBuildOutputs(
Expand All @@ -546,7 +546,7 @@ describe('resolveBuildOutputs', () => {
})
})

test('umd or iife: should define build.lib.name', () => {
test.skip('umd or iife: should define build.lib.name', () => {
;['umd', 'iife'].forEach((format) => {
expect(() =>
resolveBuildOutputs(
Expand Down
7 changes: 4 additions & 3 deletions packages/vite/src/node/__tests__/plugins/css.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs'
import path from 'node:path'
import { describe, expect, test, vi } from 'vitest'
import type { Plugin } from 'rolldown'
import { resolveConfig } from '../../config'
import type { InlineConfig } from '../../config'
import {
Expand Down Expand Up @@ -219,7 +220,7 @@ async function createCssPluginTransform(
const config = await resolveConfig(inlineConfig, 'serve')
const environment = new PartialEnvironment('client', config)

const { transform, buildStart } = cssPlugin(config)
const { transform, buildStart } = cssPlugin(config) as Plugin

// @ts-expect-error buildStart is function
await buildStart.call({})
Expand All @@ -233,8 +234,8 @@ async function createCssPluginTransform(

return {
async transform(code: string, id: string) {
// @ts-expect-error transform is function
return await transform.call(
// @ts-expect-error transform.handler is function
return await transform.handler.call(
{
addWatchFile() {
return
Expand Down
10 changes: 7 additions & 3 deletions packages/vite/src/node/__tests__/plugins/import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ describe('transformCjsImport', () => {
'',
config,
),
).toBe(
'import __vite__cjsImport0_react from "./node_modules/.vite/deps/react.js"; ' +
`const react = ((m) => m?.__esModule ? m : { ...typeof m === "object" && !Array.isArray(m) || typeof m === "function" ? m : {}, default: m })(__vite__cjsImport0_react)`,
).toMatchInlineSnapshot(
`
"import __vite__cjsImport0_react from "./node_modules/.vite/deps/react.js"; const react = ((m) => m?.__esModule ? m : {
...typeof m === "object" && !Array.isArray(m) || typeof m === "function" ? m : {},
default: m
})(__vite__cjsImport0_react)"
`,
)
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it } from 'vitest'
import type { ModuleFormat, RollupOutput } from 'rollup'
import type { ModuleFormat, RollupOutput } from 'rolldown'
import { build } from '../../../build'
import { modulePreloadPolyfillId } from '../../../plugins/modulePreloadPolyfill'

Expand Down Expand Up @@ -37,7 +37,7 @@ const buildProject = ({ format = 'es' as ModuleFormat } = {}) =>
}) as Promise<RollupOutput>

describe('load', () => {
it('loads modulepreload polyfill', async ({ expect }) => {
it.skip('loads modulepreload polyfill', async ({ expect }) => {
const { output } = await buildProject()
expect(output).toHaveLength(1)
expect(output[0].code).toMatchSnapshot()
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/__tests_dts__/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* This is a development only file for testing types.
*/
import type { Plugin as RollupPlugin } from 'rollup'
import type { Plugin as RollupPlugin } from 'rolldown'
import type { Equal, ExpectExtends, ExpectTrue } from '@type-challenges/utils'
import type { Plugin, PluginContextExtension } from '../plugin'
import type { ROLLUP_HOOKS } from '../constants'
Expand Down
Loading