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

feat: use native plugin for create id resolver #68

Draft
wants to merge 66 commits into
base: rolldown-v6
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
0eddb11
feat: use rolldown in the dep optimizer
sapphi-red Sep 11, 2024
37ee073
feat: use rolldown for build
sapphi-red Sep 12, 2024
eaf89b8
chore: skip plugin-legacy build
sapphi-red Sep 12, 2024
bbbd83a
chore: skip typecheck for now
sapphi-red Sep 12, 2024
6bfed2d
chore: 🤖 add justfile for faster dev
IWANABETHATGUY Aug 15, 2024
c3576f6
feat: add experimental.enableNativePlugin (#41)
IWANABETHATGUY Sep 10, 2024
801bfab
feat: clone class plugins correctly
IWANABETHATGUY Sep 13, 2024
10bcd24
feat: native build plugins (#45) (#46)
IWANABETHATGUY Sep 12, 2024
095196a
perf: reduce pre alias plugin in build mode
IWANABETHATGUY Sep 12, 2024
35abe57
feat: 🎸 add an new option to disable build report
IWANABETHATGUY Sep 13, 2024
2dd31fa
feat: support native define
sapphi-red Sep 18, 2024
c4f89cf
feat: use filter for plugins (#49) (#50) (#51) (#52) (#53)
sapphi-red Sep 18, 2024
dbf006f
perf: ⚡️ use default resolver (#56)
IWANABETHATGUY Sep 14, 2024
1b9602c
fix: 🐛 lint (#58)
IWANABETHATGUY Sep 20, 2024
049058d
chore: bump rolldown
sapphi-red Sep 24, 2024
b68f46f
chore: skip data uri by load fallback plugin for native data uri hand…
sapphi-red Sep 24, 2024
477701b
feat: handle non-relative paths by Vite's resolver for enableNativePl…
sapphi-red Sep 19, 2024
68a94bc
chore: remove browser field edge case test
sapphi-red Sep 25, 2024
93fd15f
chore: use advancedChunks instead of manualChunks
sapphi-red Oct 1, 2024
404fccc
feat: convert `optimizeDeps.esbuildOptions` to `optimizeDeps.rollupOp…
sapphi-red Oct 4, 2024
72fb859
fix: optimizeDeps test pass on windows
sapphi-red Oct 9, 2024
b5034b2
chore: make some tests passing
sapphi-red Oct 9, 2024
0b9ce31
chore: make glob-import test pass with workarounds
sapphi-red Oct 9, 2024
b91ddef
chore: run worker-es tests
sapphi-red Oct 9, 2024
732d0eb
fix: use preliminaryFileName for chunkMetadata key
sapphi-red Oct 10, 2024
5f46885
feat: oxc tranformer (#60)
underfin Oct 11, 2024
d9e05ed
feat: use `onlyRemoveTypeImports`
sapphi-red Oct 11, 2024
4595c00
chore: enable continuous release under rolldown-vite (#61)
yyx990803 Oct 12, 2024
708eef3
feat: environment aware native plugins
sapphi-red Oct 15, 2024
bf628df
feat: export transformWithOxc (#62)
underfin Oct 17, 2024
19acd22
feat: add oxc jsxInclude and jsxExclude (#63)
underfin Oct 18, 2024
5705e75
chore: update some tests that relies on rollup's behavior
sapphi-red Oct 24, 2024
30b40e4
chore: skip environment-react-ssr for now
sapphi-red Oct 24, 2024
8356aaa
chore: bump rolldown
sapphi-red Oct 24, 2024
ae20803
chore: skip minifySyntax test as it relies on specific esbuild option
sapphi-red Oct 24, 2024
74b287e
chore: fix type errors
sapphi-red Oct 24, 2024
cd614c5
chore: skip sideeffects set for HTML scripts for now
sapphi-red Nov 6, 2024
574ccb4
chore: partial revert "refactor: use `originalFileNames`/`names` (#18…
sapphi-red Nov 6, 2024
f91e197
chore: tweak tests
sapphi-red Nov 6, 2024
c197275
chore: bump rolldown
sapphi-red Nov 6, 2024
9262331
chore: enable backend-integration test
sapphi-red Nov 6, 2024
c4be548
chore: skip error message test
sapphi-red Nov 13, 2024
487905e
chore: bump rolldown
sapphi-red Nov 13, 2024
b51ee7f
chore: bump rolldown
sapphi-red Nov 13, 2024
f39f6c0
feat: enable lib mode tests (#64)
sapphi-red Nov 13, 2024
65d9acc
chore: fix LICENSE
sapphi-red Nov 14, 2024
5303bcf
chore: bump rolldown
sapphi-red Nov 15, 2024
9ffd326
chore: uncomment things implemented on rolldown now
sapphi-red Nov 18, 2024
f646104
chore: bump rolldown
sapphi-red Nov 18, 2024
b312888
chore: bump rolldown
sapphi-red Nov 18, 2024
34ae495
chore: enable html sideeffects test
sapphi-red Nov 18, 2024
9afe273
chore: bump rolldown
sapphi-red Nov 18, 2024
0330bb1
chore: reduce diff
sapphi-red Nov 18, 2024
07ad00f
feat: use native Vite resolver (#65)
sapphi-red Nov 19, 2024
c78b553
chore: apply #18713
sapphi-red Nov 20, 2024
840de9b
chore: add workaround and make environment-react-ssr playground pass
sapphi-red Nov 21, 2024
e83a7e0
chore: add comment
sapphi-red Nov 21, 2024
061fc7e
chore: bump rolldown
sapphi-red Nov 21, 2024
437ff57
chore: fix oxc option convertion and reduce warnings
sapphi-red Nov 22, 2024
db71354
refactor: convert to callableBuiltinPlugin when creating environment …
sapphi-red Nov 22, 2024
f73bd85
refactor: pass env options to oxcResolvePlugin
sapphi-red Nov 22, 2024
639e2cf
feat: add skipMainField option
sapphi-red Nov 22, 2024
e52cfb9
feat: pass isRequire to the native plugin
sapphi-red Nov 22, 2024
ab70cc1
feat: use the native plugin for `createIdResolver`
sapphi-red Nov 22, 2024
4a72e08
fix: optimizer stall
sapphi-red Nov 22, 2024
8286c04
perf: pass finalizeOtherSpecifiers when only needed
sapphi-red Nov 22, 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 --write --log-level=warn . && git diff --exit-code

- 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/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ permissions:
on:
push:
branches:
- main
- rolldown-v6
pull_request:
types: [opened, synchronize, labeled]

jobs:
preview:
if: >
github.repository == 'vitejs/vite' &&
github.repository == 'rolldown/vite' &&
(github.event_name == 'push' ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger: preview')))
runs-on: ubuntu-latest
Expand All @@ -35,4 +35,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
1 change: 0 additions & 1 deletion packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
},
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
Expand Down
77 changes: 33 additions & 44 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,11 @@ Repository: lukeed/polka

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

## @rollup/plugin-alias, @rollup/plugin-commonjs, @rollup/plugin-dynamic-import-vars, @rollup/pluginutils
## @rollup/plugin-alias, @rollup/plugin-dynamic-import-vars, @rollup/pluginutils
License: MIT
By: Johannes Stein
Repository: rollup/plugins

License: MIT
By: Rich Harris
Repository: rollup/plugins

License: MIT
By: LarsDenBakker
Repository: rollup/plugins
Expand Down Expand Up @@ -584,38 +580,6 @@ Repository: git+https://github.com/paulmillr/chokidar.git

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

## commondir, shell-quote
License: MIT
By: James Halliday
Repositories: http://github.com/substack/node-commondir.git, http://github.com/ljharb/shell-quote.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 @@ -1298,13 +1262,6 @@ Repository: micromatch/is-glob

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

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

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

## isexe, which
License: ISC
By: Isaac Z. Schlueter
Expand Down Expand Up @@ -2147,6 +2104,38 @@ Repository: kevva/shebang-command

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

## shell-quote
License: MIT
By: James Halliday
Repository: http://github.com/ljharb/shell-quote.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.

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

## sirv
License: MIT
By: Luke Edwards
Expand Down
1 change: 1 addition & 0 deletions packages/vite/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const asyncFunctions = [
'createServer',
'preview',
'transformWithEsbuild',
'transformWithOxc',
'resolveConfig',
'optimizeDeps',
'formatPostcssSourceMap',
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 @@ -88,6 +88,7 @@
"dependencies": {
"esbuild": "^0.24.0",
"postcss": "^8.4.48",
"rolldown": "https://pkg.pr.new/rolldown@f65c876",
"rollup": "^4.23.0"
},
"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 @@ -112,6 +112,7 @@ const nodeConfig = defineConfig({
'fsevents',
'rollup/parseAst',
/^tsx\//,
'rolldown/experimental',
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
],
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),
...Object.keys(pkg.peerDependencies),
...Object.keys(pkg.devDependencies),
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
11 changes: 10 additions & 1 deletion packages/vite/src/module-runner/hmrHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { HotPayload } from 'types/hmrPayload'
import { slash, unwrapId } from '../shared/utils'
import { ERR_OUTDATED_OPTIMIZED_DEP } from '../shared/constants'
import type { ModuleRunner } from './runner'

// updates to HMR should go one after another. It is possible to trigger another update during the invalidation for example.
Expand Down Expand Up @@ -56,7 +57,15 @@ export async function handleHotPayload(
runner.evaluatedModules.clear()

for (const url of clearEntrypointUrls) {
await runner.import(url)
try {
await runner.import(url)
} catch (err) {
if (err.code !== ERR_OUTDATED_OPTIMIZED_DEP) {
hmrClient.logger.error(
`An error happened during full reload\n${err.message}\n${err.stack}`,
)
}
}
}
break
}
Expand Down
4 changes: 2 additions & 2 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 @@ -707,7 +707,7 @@ test('default sharedConfigBuild true on build api', async () => {
expect(counter).toBe(1)
})

test('adjust worker build error for worker.format', async () => {
test.skip('adjust worker build error for worker.format', async () => {
try {
await build({
root: resolve(__dirname, 'fixtures/worker-dynamic'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ async function createAssetImportMetaurlPluginTransform() {
const environment = new PartialEnvironment('client', config)

return async (code: string) => {
// @ts-expect-error transform should exist
const result = await instance.transform.call(
// @ts-expect-error transform.handler should exist
const result = await instance.transform.handler.call(
{ environment, parse: parseAst },
code,
'foo.ts',
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 path from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, expect, test } from 'vitest'
import type { Plugin } from 'rolldown'
import { resolveConfig } from '../../config'
import type { InlineConfig } from '../../config'
import {
Expand Down Expand Up @@ -210,15 +211,15 @@ async function createCssPluginTransform(inlineConfig: InlineConfig = {}) {
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({})

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,8 @@ const buildProject = ({ format = 'es' as ModuleFormat } = {}) =>
}) as Promise<RollupOutput>

describe('load', () => {
it('loads modulepreload polyfill', async ({ expect }) => {
// NOTE: due to https://github.com/rolldown/rolldown/issues/2828
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
Loading