diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 38f22d53a4576b..7af168e7f95044 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -17,6 +17,8 @@ "node", "typescript", "eslint-plugin-react-hooks", // prevent bumping to messy -rc-- + "@rollup/plugin-dynamic-import-vars", // prefer version using tinyglobby + "@types/express", // express latest is still on v4, so types should also be v4 // pinned "slash3", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b271bc0178a38..02b8316a6bccee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,9 +69,9 @@ jobs: include: # Active LTS + other OS - os: macos-latest - node_version: 20 + node_version: 22 - os: windows-latest - node_version: 20 + node_version: 22 fail-fast: false name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}" @@ -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 diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml new file mode 100644 index 00000000000000..06f7d4ce81ed3d --- /dev/null +++ b/.github/workflows/preview-release.yml @@ -0,0 +1,38 @@ +name: Preview release + +env: + # install playwright binary manually (because pnpm only runs install script once) + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" + +permissions: + pull-requests: write + +on: + push: + branches: + - rolldown-v6 + pull_request: + types: [opened, synchronize, labeled] + +jobs: + preview: + if: > + 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 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4.0.0 + + - name: Install dependencies + run: pnpm install + + - name: Build + working-directory: ./packages/vite + run: pnpm build + + - run: pnpm dlx pkg-pr-new@0.0 publish --pnpm ./packages/vite diff --git a/.github/workflows/publish-commit.yml b/.github/workflows/publish-commit.yml deleted file mode 100644 index c409979c033157..00000000000000 --- a/.github/workflows/publish-commit.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Publish Any Commit - -env: - # install playwright binary manually (because pnpm only runs install script once) - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" - -on: - push: - branches: - - main - 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')) - runs-on: ubuntu-latest - - steps: - - if: github.event.issue.pull_request - uses: actions/github-script@v7 - with: - script: | - const user = context.payload.sender.login - console.log(`Validate user: ${user}`) - - let hasTriagePermission = false - try { - const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ - owner: context.repo.owner, - repo: context.repo.repo, - username: user, - }); - hasTriagePermission = data.user.permissions.triage - } catch (e) { - console.warn(e) - } - - if (hasTriagePermission) { - console.log('Allowed') - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: '+1', - }) - } else { - console.log('Not allowed') - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: '-1', - }) - throw new Error('not allowed') - } - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install pnpm - uses: pnpm/action-setup@v4.0.0 - - - name: Install dependencies - run: pnpm install - - - name: Build - working-directory: ./packages/vite - run: pnpm build - - - run: pnpm dlx pkg-pr-new@0.0 publish --compact --pnpm ./packages/vite diff --git a/.npmrc b/.npmrc index ff6f1665b13102..3c758b7ba41b57 100644 --- a/.npmrc +++ b/.npmrc @@ -1,4 +1,3 @@ -hoist-pattern[]=ts-node # package/vite: postcss-load-config hoist-pattern[]=postcss # package/vite hoist-pattern[]=pug # playground/tailwind: @vue/compiler-sfc shell-emulator=true diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 8c706a92aa725a..45337665e198ba 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -141,8 +141,9 @@ export default defineConfig({ }, socialLinks: [ + { icon: 'bluesky', link: 'https://bsky.app/profile/vite.dev' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@vite' }, - { icon: 'twitter', link: 'https://twitter.com/vite_js' }, + { icon: 'x', link: 'https://x.com/vite_js' }, { icon: 'discord', link: 'https://chat.vite.dev' }, { icon: 'github', link: 'https://github.com/vitejs/vite' }, ], @@ -178,13 +179,17 @@ export default defineConfig({ { text: 'Releases', link: '/releases' }, { items: [ + { + text: 'Bluesky', + link: 'https://bsky.app/profile/vite.dev', + }, { text: 'Mastodon', link: 'https://elk.zone/m.webtoo.ls/@vite', }, { - text: 'Twitter', - link: 'https://twitter.com/vite_js', + text: 'X', + link: 'https://x.com/vite_js', }, { text: 'Discord Chat', @@ -456,19 +461,13 @@ export default defineConfig({ }, }), ], - environments: { - client: { - dev: { - optimizeDeps: { - include: [ - '@shikijs/vitepress-twoslash/client', - 'gsap', - 'gsap/dist/ScrollTrigger', - 'gsap/dist/MotionPathPlugin', - ], - }, - }, - }, + optimizeDeps: { + include: [ + '@shikijs/vitepress-twoslash/client', + 'gsap', + 'gsap/dist/ScrollTrigger', + 'gsap/dist/MotionPathPlugin', + ], }, }, buildEnd, diff --git a/docs/.vitepress/theme/styles/landing.css b/docs/.vitepress/theme/styles/landing.css index c3582f2095f5aa..cc612c24ba4e57 100644 --- a/docs/.vitepress/theme/styles/landing.css +++ b/docs/.vitepress/theme/styles/landing.css @@ -4,13 +4,16 @@ html:has(.landing) { background-color: #101010; - --vp-c-bg: #101010; body { background-color: #101010; } } +html.dark:has(.landing) { + --vp-c-bg: #101010; +} + .landing { overflow-x: hidden; background-color: #101010; @@ -37,9 +40,14 @@ html:has(.landing) { .content-body { background: none !important; + transition: none; } } + .VPNavBar *:not(.wrapper *) { + transition: none; + } + .VPFooter { border-top: 1px solid #262626 !important; background: radial-gradient(circle at top center, #0f151a 30%, #000000 80%); @@ -58,6 +66,10 @@ html:has(.landing) { display: none; } + .VPMenu .translations + .group { + display: none; + } + .VPNavScreenAppearance { visibility: hidden; } diff --git a/docs/_data/team.js b/docs/_data/team.js index 8a1425b2446a62..30c70e05425947 100644 --- a/docs/_data/team.js +++ b/docs/_data/team.js @@ -8,7 +8,8 @@ export const core = [ desc: 'Independent open source developer, creator of Vue.js and Vite.', links: [ { icon: 'github', link: 'https://github.com/yyx990803' }, - { icon: 'twitter', link: 'https://twitter.com/youyuxi' }, + { icon: 'x', link: 'https://x.com/youyuxi' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/evanyou.me' }, ], sponsor: 'https://github.com/sponsors/yyx990803', }, @@ -21,8 +22,9 @@ export const core = [ desc: 'Core team member of Vite. Team member of Vue.', links: [ { icon: 'github', link: 'https://github.com/patak-dev' }, - { icon: 'twitter', link: 'https://twitter.com/patak_dev' }, + { icon: 'x', link: 'https://x.com/patak_dev' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@patak' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/patak.dev' }, ], sponsor: 'https://github.com/sponsors/patak-dev', }, @@ -35,8 +37,9 @@ export const core = [ desc: 'Core team member of Vite & Vue. Working at NuxtLabs.', links: [ { icon: 'github', link: 'https://github.com/antfu' }, - { icon: 'twitter', link: 'https://twitter.com/antfu7' }, + { icon: 'x', link: 'https://x.com/antfu7' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@antfu' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/antfu.me' }, ], sponsor: 'https://github.com/sponsors/antfu', }, @@ -47,8 +50,9 @@ export const core = [ desc: 'Astro core residency. Svelte and Vite core team member.', links: [ { icon: 'github', link: 'https://github.com/bluwy' }, - { icon: 'twitter', link: 'https://twitter.com/bluwyoo' }, + { icon: 'x', link: 'https://x.com/bluwyoo' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@bluwy' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/bluwy.me' }, ], sponsor: 'https://bjornlu.com/sponsor', }, @@ -59,7 +63,7 @@ export const core = [ desc: 'Vite core team member. Call me sapphi or green or midori ;)', links: [ { icon: 'github', link: 'https://github.com/sapphi-red' }, - { icon: 'twitter', link: 'https://twitter.com/sapphi_red' }, + { icon: 'x', link: 'https://x.com/sapphi_red' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@sapphi_red' }, ], sponsor: 'https://github.com/sponsors/sapphi-red', @@ -71,8 +75,12 @@ export const core = [ desc: 'Passionate by tooling around TypeScript and React.', links: [ { icon: 'github', link: 'https://github.com/ArnaudBarre' }, - { icon: 'twitter', link: 'https://twitter.com/_ArnaudBarre' }, + { icon: 'x', link: 'https://x.com/_ArnaudBarre' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@ArnaudBarre' }, + { + icon: 'bluesky', + link: 'https://bsky.app/profile/arnaud-barre.bsky.social', + }, ], sponsor: 'https://github.com/sponsors/ArnaudBarre', }, @@ -94,8 +102,9 @@ export const core = [ desc: 'An open source fullstack developer', links: [ { icon: 'github', link: 'https://github.com/sheremet-va' }, + { icon: 'x', link: 'https://x.com/sheremet_va' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@sheremet_va' }, - { icon: 'twitter', link: 'https://twitter.com/sheremet_va' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/erus.dev' }, ], sponsor: 'https://github.com/sponsors/sheremet-va', }, @@ -106,7 +115,7 @@ export const core = [ desc: 'Open source enthusiast', links: [ { icon: 'github', link: 'https://github.com/hi-ogawa' }, - { icon: 'twitter', link: 'https://twitter.com/hiroshi_18181' }, + { icon: 'x', link: 'https://x.com/hiroshi_18181' }, ], sponsor: 'https://github.com/sponsors/hi-ogawa', }, @@ -120,7 +129,11 @@ export const emeriti = [ desc: 'Dabbling in social ecommerce, meta frameworks, and board games', links: [ { icon: 'github', link: 'https://github.com/aleclarson' }, - { icon: 'twitter', link: 'https://twitter.com/retropragma' }, + { icon: 'x', link: 'https://x.com/retropragma' }, + { + icon: 'bluesky', + link: 'https://bsky.app/profile/retropragma.bsky.social', + }, ], }, { @@ -130,7 +143,7 @@ export const emeriti = [ desc: 'Frontend. Vite team member.', links: [ { icon: 'github', link: 'https://github.com/poyoho' }, - { icon: 'twitter', link: 'https://twitter.com/yoho_po' }, + { icon: 'x', link: 'https://x.com/yoho_po' }, ], }, { @@ -140,7 +153,7 @@ export const emeriti = [ desc: 'Web Developer. Vue & Vite team member', links: [ { icon: 'github', link: 'https://github.com/ygj6' }, - { icon: 'twitter', link: 'https://twitter.com/ygj_66' }, + { icon: 'x', link: 'https://x.com/ygj_66' }, ], }, { @@ -151,7 +164,8 @@ export const emeriti = [ desc: 'weeb/javascript lover.', links: [ { icon: 'github', link: 'https://github.com/Niputi' }, - { icon: 'twitter', link: 'https://twitter.com/Niputi_' }, + { icon: 'x', link: 'https://x.com/Niputi_' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/niputi.bsky.social' }, ], }, { @@ -164,7 +178,10 @@ export const emeriti = [ avatar: 'https://github.com/GrygrFlzr.png', name: 'GrygrFlzr', title: 'Developer', - links: [{ icon: 'github', link: 'https://github.com/GrygrFlzr' }], + links: [ + { icon: 'github', link: 'https://github.com/GrygrFlzr' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/bsky.cybeast.dev' }, + ], }, { avatar: 'https://github.com/nihalgonsalves.png', @@ -193,8 +210,9 @@ export const emeriti = [ desc: 'Vue/Vite team member. Full-time open sourcerer.', links: [ { icon: 'github', link: 'https://github.com/sodatea' }, - { icon: 'twitter', link: 'https://twitter.com/haoqunjiang' }, + { icon: 'x', link: 'https://x.com/haoqunjiang' }, { icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@haoqun' }, + { icon: 'bluesky', link: 'https://bsky.app/profile/haoqun.dev' }, ], sponsor: 'https://github.com/sponsors/sodatea', }, diff --git a/docs/changes/per-environment-apis.md b/docs/changes/per-environment-apis.md index 93ec216a6459e3..4ff27380b1b96a 100644 --- a/docs/changes/per-environment-apis.md +++ b/docs/changes/per-environment-apis.md @@ -4,16 +4,12 @@ Give us feedback at [Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358) ::: -Multiple APIs from ViteDevServer related to module graph has replaced with more isolated Environment APIs. - -- `server.moduleGraph` -> [`environment.moduleGraph`](/guide/api-environment#separate-module-graphs) -- `server.transformRequest` -> `environment.transformRequest` -- `server.warmupRequest` -> `environment.warmupRequest` +Multiple APIs from `ViteDevServer` related to module graph and modules transforms have been moved to the `DevEnvironment` instances. Affect scope: `Vite Plugin Authors` ::: warning Future Deprecation -The Environment instance was first introduced at `v6.0`. The deprecation of `server.moduleGraph` and other methods that are now in environments is planned for `v7.0`. We don't recommend moving away from server methods yet. To identify your usage, set these in your vite config. +The `Environment` instance was first introduced at `v6.0`. The deprecation of `server.moduleGraph` and other methods that are now in environments is planned for `v7.0`. We don't recommend moving away from server methods yet. To identify your usage, set these in your vite config. ```ts future: { @@ -26,8 +22,12 @@ future: { ## Motivation -// TODO: +In Vite v5 and before, a single Vite dev server always had two environments (`client` and `ssr`). The `server.moduleGraph` had mixed modules from both of these environments. Nodes were connected through `clientImportedModules` and `ssrImportedModules` lists (but a single `importers` list was maintained for each). A transformed module was represented by an `id` and a `ssr` boolean. This boolean needed to be passed to APIs, for example `server.moduleGraph.getModuleByUrl(url, ssr)` and `server.transformRequest(url, { ssr })`. + +In Vite v6, it is now possible to create any number of custom environments (`client`, `ssr`, `edge`, etc). A single `ssr` boolean isn't enough anymore. Instead of changing the APIs to be of the form `server.transformRequest(url, { environment })`, we moved these methods to the environment instance allowing them to be called without a Vite dev server. ## Migration Guide -// TODO: +- `server.moduleGraph` -> [`environment.moduleGraph`](/guide/api-environment#separate-module-graphs) +- `server.transformRequest(url, ssr)` -> `environment.transformRequest(url)` +- `server.warmupRequest(url, ssr)` -> `environment.warmupRequest(url)` diff --git a/docs/changes/shared-plugins-during-build.md b/docs/changes/shared-plugins-during-build.md index 3c9fc99f698a61..7cebea65df2c7b 100644 --- a/docs/changes/shared-plugins-during-build.md +++ b/docs/changes/shared-plugins-during-build.md @@ -4,7 +4,6 @@ Give us feedback at [Environment API feedback discussion](https://github.com/vitejs/vite/discussions/16358) ::: -// TODO: See [Shared plugins during build](/guide/api-environment.md#shared-plugins-during-build). Affect scope: `Vite Plugin Authors` @@ -15,8 +14,68 @@ Affect scope: `Vite Plugin Authors` ## Motivation -// TODO: +Align dev and build plugin pipelines. ## Migration Guide -// TODO: +To be able to share plugins across environments, plugin state must be keyed by the current environment. A plugin of the following form will count the number of transformed modules across all environments. + +```js +function CountTransformedModulesPlugin() { + let transformedModules + return { + name: 'count-transformed-modules', + buildStart() { + transformedModules = 0 + }, + transform(id) { + transformedModules++ + }, + buildEnd() { + console.log(transformedModules) + }, + } +} +``` + +If we instead want to count the number of transformed modules for each environment, we need to keep a map: + +```js +function PerEnvironmentCountTransformedModulesPlugin() { + const state = new Map() + return { + name: 'count-transformed-modules', + perEnvironmentStartEndDuringDev: true, + buildStart() { + state.set(this.environment, { count: 0 }) + } + transform(id) { + state.get(this.environment).count++ + }, + buildEnd() { + console.log(this.environment.name, state.get(this.environment).count) + } + } +} +``` + +To simplify this pattern, internally in Vite, we use a `usePerEnvironmentState` helper: + +```js +function PerEnvironmentCountTransformedModulesPlugin() { + const state = usePerEnvironmentState<{ count: number }>(() => ({ count: 0 })) + return { + name: 'count-transformed-modules', + perEnvironmentStartEndDuringDev: true, + buildStart() { + state(this).count = 0 + } + transform(id) { + state(this).count++ + }, + buildEnd() { + console.log(this.environment.name, state(this).count) + } + } +} +``` diff --git a/docs/config/build-options.md b/docs/config/build-options.md index 9bff0380a6a02c..3419070bd474a6 100644 --- a/docs/config/build-options.md +++ b/docs/config/build-options.md @@ -130,7 +130,7 @@ In this case, you need to set `build.cssTarget` to `chrome61` to prevent vite fr ## build.cssMinify - **Type:** `boolean | 'esbuild' | 'lightningcss'` -- **Default:** the same as [`build.minify`](#build-minify) +- **Default:** the same as [`build.minify`](#build-minify) for client, `'esbuild'` for SSR This option allows users to override CSS minification specifically instead of defaulting to `build.minify`, so you can configure minification for JS and CSS separately. Vite uses `esbuild` by default to minify CSS. Set the option to `'lightningcss'` to use [Lightning CSS](https://lightningcss.dev/minification.html) instead. If selected, it can be configured using [`css.lightningcss`](./shared-options.md#css-lightningcss). @@ -162,10 +162,28 @@ Options to pass on to [@rollup/plugin-dynamic-import-vars](https://github.com/ro ## build.lib -- **Type:** `{ entry: string | string[] | { [entryAlias: string]: string }, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat, entryName: string) => string) }` +- **Type:** `{ entry: string | string[] | { [entryAlias: string]: string }, name?: string, formats?: ('es' | 'cjs' | 'umd' | 'iife')[], fileName?: string | ((format: ModuleFormat, entryName: string) => string), cssFileName?: string }` - **Related:** [Library Mode](/guide/build#library-mode) -Build as a library. `entry` is required since the library cannot use HTML as entry. `name` is the exposed global variable and is required when `formats` includes `'umd'` or `'iife'`. Default `formats` are `['es', 'umd']`, or `['es', 'cjs']`, if multiple entries are used. `fileName` is the name of the package file output, default `fileName` is the name option of package.json, it can also be defined as function taking the `format` and `entryName` as arguments. +Build as a library. `entry` is required since the library cannot use HTML as entry. `name` is the exposed global variable and is required when `formats` includes `'umd'` or `'iife'`. Default `formats` are `['es', 'umd']`, or `['es', 'cjs']`, if multiple entries are used. + +`fileName` is the name of the package file output, which defaults to the `"name"` in `package.json`. It can also be defined as a function taking the `format` and `entryName` as arguments, and returning the file name. + +If your package imports CSS, `cssFileName` can be used to specify the name of the CSS file output. It defaults to the same value as `fileName` if it's set a string, otherwise it also falls back to the `"name"` in `package.json`. + +```js twoslash [vite.config.js] +import { defineConfig } from 'vite' + +export default defineConfig({ + build: { + lib: { + entry: ['src/main.js'], + fileName: (format, entryName) => `my-lib-${entryName}.${format}.js`, + cssFileName: 'my-lib-style', + }, + }, +}) +``` ## build.manifest diff --git a/docs/config/index.md b/docs/config/index.md index a70cb03e255de6..b380b4b5988230 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -103,9 +103,10 @@ Note that Vite doesn't load `.env` files by default as the files to load can onl ```js twoslash import { defineConfig, loadEnv } from 'vite' -export default defineConfig(({ command, mode }) => { +export default defineConfig(({ mode }) => { // Load env file based on `mode` in the current working directory. - // Set the third parameter to '' to load all env regardless of the `VITE_` prefix. + // Set the third parameter to '' to load all env regardless of the + // `VITE_` prefix. const env = loadEnv(mode, process.cwd(), '') return { // vite config diff --git a/docs/config/server-options.md b/docs/config/server-options.md index f31e1cc0a93d81..83524b8b11e11d 100644 --- a/docs/config/server-options.md +++ b/docs/config/server-options.md @@ -101,15 +101,21 @@ In some cases, you might also want to configure the underlying dev server (e.g. export default defineConfig({ server: { proxy: { - // string shorthand: http://localhost:5173/foo -> http://localhost:4567/foo + // string shorthand: + // http://localhost:5173/foo + // -> http://localhost:4567/foo '/foo': 'http://localhost:4567', - // with options: http://localhost:5173/api/bar-> http://jsonplaceholder.typicode.com/bar + // with options: + // http://localhost:5173/api/bar + // -> http://jsonplaceholder.typicode.com/bar '/api': { target: 'http://jsonplaceholder.typicode.com', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), }, - // with RegExp: http://localhost:5173/fallback/ -> http://jsonplaceholder.typicode.com/ + // with RegExp: + // http://localhost:5173/fallback/ + // -> http://jsonplaceholder.typicode.com/ '^/fallback/.*': { target: 'http://jsonplaceholder.typicode.com', changeOrigin: true, @@ -123,8 +129,11 @@ export default defineConfig({ // proxy will be an instance of 'http-proxy' }, }, - // Proxying websockets or socket.io: ws://localhost:5173/socket.io -> ws://localhost:5174/socket.io - // Exercise caution using `rewriteWsOrigin` as it can leave the proxying open to CSRF attacks. + // Proxying websockets or socket.io: + // ws://localhost:5173/socket.io + // -> ws://localhost:5174/socket.io + // Exercise caution using `rewriteWsOrigin` as it can leave the + // proxying open to CSRF attacks. '/socket.io': { target: 'ws://localhost:5174', ws: true, @@ -205,11 +214,11 @@ export default defineConfig({ - **Type:** `object | null` -File system watcher options to pass on to [chokidar](https://github.com/paulmillr/chokidar#api). +File system watcher options to pass on to [chokidar](https://github.com/paulmillr/chokidar#getting-started). If the `ignored` option is passed, Vite will also automatically convert any strings as [picomatch patterns](https://github.com/micromatch/picomatch#globbing-features). The Vite server watcher watches the `root` and skips the `.git/`, `node_modules/`, and Vite's `cacheDir` and `build.outDir` directories by default. When updating a watched file, Vite will apply HMR and update the page only if needed. -If set to `null`, no files will be watched. `server.watcher` will provide a compatible event emitter, but calling `add` or `unwatch` will have no effect. +If set to `null`, no files will be watched. `server.watcher` will not watch any files and calling `add` will have no effect. ::: warning Watching files in `node_modules` @@ -251,15 +260,16 @@ async function createServer() { // Create Vite server in middleware mode const vite = await createViteServer({ server: { middlewareMode: true }, - appType: 'custom', // don't include Vite's default HTML handling middlewares + // don't include Vite's default HTML handling middlewares + appType: 'custom', }) // Use vite's connect instance as middleware app.use(vite.middlewares) app.use('*', async (req, res) => { // Since `appType` is `'custom'`, should serve response here. - // Note: if `appType` is `'spa'` or `'mpa'`, Vite includes middlewares to handle - // HTML requests and 404s so user middlewares should be added + // Note: if `appType` is `'spa'` or `'mpa'`, Vite includes middlewares + // to handle HTML requests and 404s so user middlewares should be added // before Vite's middlewares to take effect instead }) } @@ -329,14 +339,6 @@ export default defineConfig({ Blocklist for sensitive files being restricted to be served by Vite dev server. This will have higher priority than [`server.fs.allow`](#server-fs-allow). [picomatch patterns](https://github.com/micromatch/picomatch#globbing-features) are supported. -## server.fs.cachedChecks - -- **Type:** `boolean` -- **Default:** `false` -- **Experimental** - -Caches filenames of accessed directories to avoid repeated filesystem operations. Particularly in Windows, this could result in a performance boost. It is disabled by default due to edge cases when writing a file in a cached folder and immediately importing it. - ## server.origin - **Type:** `string` diff --git a/docs/config/shared-options.md b/docs/config/shared-options.md index b803e36cc166ca..f375d060e9ace3 100644 --- a/docs/config/shared-options.md +++ b/docs/config/shared-options.md @@ -117,6 +117,7 @@ For SSR builds, deduplication does not work for ESM build outputs configured fro ## resolve.conditions - **Type:** `string[]` +- **Default:** `['module', 'browser', 'development|production']` Additional allowed conditions when resolving [Conditional Exports](https://nodejs.org/api/packages.html#packages_conditional_exports) from a package. @@ -135,7 +136,9 @@ A package with conditional exports may have the following `exports` field in its Here, `import` and `require` are "conditions". Conditions can be nested and should be specified from most specific to least specific. -Vite has a list of "allowed conditions" and will match the first condition that is in the allowed list. The default allowed conditions are: `import`, `module`, `browser`, `default`, and `production/development` based on current mode. The `resolve.conditions` config option allows specifying additional allowed conditions. +`development|production` is a special value that is replaced with `production` or `development` depending on the value of `process.env.NODE_ENV`. It is replaced with `production` when `process.env.NODE_ENV === 'production'` and `development` otherwise. + +Note that `import`, `require`, `default` conditions are always applied if the requirements are met. :::warning Resolving subpath exports Export keys ending with "/" is deprecated by Node and may not work well. Please contact the package author to use [`*` subpath patterns](https://nodejs.org/api/packages.html#package-entry-points) instead. @@ -217,7 +220,7 @@ Inline PostCSS config or a custom directory to search PostCSS config from (defau For inline PostCSS config, it expects the same format as `postcss.config.js`. But for `plugins` property, only [array format](https://github.com/postcss/postcss-load-config/blob/main/README.md#array) can be used. -The search is done using [postcss-load-config](https://github.com/postcss/postcss-load-config) and only the supported config file names are loaded. +The search is done using [postcss-load-config](https://github.com/postcss/postcss-load-config) and only the supported config file names are loaded. Config files outside the workspace root (or the [project root](/guide/#index-html-and-project-root) if no workspace is found) are not searched by default. You can specify a custom path outside of the root to load the specific config file instead if needed. Note if an inline config is provided, Vite will not search for other PostCSS config sources. @@ -225,11 +228,14 @@ Note if an inline config is provided, Vite will not search for other PostCSS con - **Type:** `Record` -Specify options to pass to CSS pre-processors. The file extensions are used as keys for the options. The supported options for each preprocessors can be found in their respective documentation: +Specify options to pass to CSS pre-processors. The file extensions are used as keys for the options. The supported options for each preprocessor can be found in their respective documentation: -- `sass`/`scss` - top level option `api: "legacy" | "modern" | "modern-compiler"` (default `"legacy"`) allows switching which sass API to use. For the best performance, it's recommended to use `api: "modern-compiler"` with `sass-embedded` package. [Options (legacy)](https://sass-lang.com/documentation/js-api/interfaces/LegacyStringOptions), [Options (modern)](https://sass-lang.com/documentation/js-api/interfaces/stringoptions/). -- `less` - [Options](https://lesscss.org/usage/#less-options). -- `styl`/`stylus` - Only [`define`](https://stylus-lang.com/docs/js.html#define-name-node) is supported, which can be passed as an object. +- `sass`/`scss`: + - Select the sass API to use with `api: "modern-compiler" | "modern" | "legacy"` (default `"modern-compiler"` if `sass-embedded` is installed, otherwise `"modern"`). For the best performance, it's recommended to use `api: "modern-compiler"` with the `sass-embedded` package. The `"legacy"` API is deprecated and will be removed in Vite 7. + - [Options (modern)](https://sass-lang.com/documentation/js-api/interfaces/stringoptions/) + - [Options (legacy)](https://sass-lang.com/documentation/js-api/interfaces/LegacyStringOptions). +- `less`: [Options](https://lesscss.org/usage/#less-options). +- `styl`/`stylus`: Only [`define`](https://stylus-lang.com/docs/js.html#define-name-node) is supported, which can be passed as an object. **Example:** diff --git a/docs/config/ssr-options.md b/docs/config/ssr-options.md index 8cb7fb9a41b348..7e7d8983928fc0 100644 --- a/docs/config/ssr-options.md +++ b/docs/config/ssr-options.md @@ -34,15 +34,14 @@ Build target for the SSR server. ## ssr.resolve.conditions - **Type:** `string[]` +- **Default:** `['module', 'node', 'development|production']` (`['module', 'browser', 'development|production']` for `ssr.target === 'webworker'`) - **Related:** [Resolve Conditions](./shared-options.md#resolve-conditions) -Defaults to the root [`resolve.conditions`](./shared-options.md#resolve-conditions). - These conditions are used in the plugin pipeline, and only affect non-externalized dependencies during the SSR build. Use `ssr.resolve.externalConditions` to affect externalized imports. ## ssr.resolve.externalConditions - **Type:** `string[]` -- **Default:** `[]` +- **Default:** `['node']` Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies. diff --git a/docs/guide/api-environment-frameworks.md b/docs/guide/api-environment-frameworks.md index e95d046577d688..6a41a31ed7edae 100644 --- a/docs/guide/api-environment-frameworks.md +++ b/docs/guide/api-environment-frameworks.md @@ -22,7 +22,8 @@ export class RunnableDevEnvironment extends DevEnvironment { class ModuleRunner { /** - * URL to execute. Accepts file path, server path, or id relative to the root. + * URL to execute. + * Accepts file path, server path, or id relative to the root. * Returns an instantiated module (same as in ssrLoadModule) */ public async import(url: string): Promise> @@ -52,20 +53,21 @@ const server = await createServer({ appType: 'custom', environments: { server: { - // by default, the modules are run in the same process as the vite dev server during dev + // by default, modules are run in the same process as the vite server }, }, }) -// You might need to cast this to RunnableDevEnvironment in TypeScript or use -// the "isRunnableDevEnvironment" function to guard the access to the runner +// You might need to cast this to RunnableDevEnvironment in TypeScript or +// use isRunnableDevEnvironment to guard the access to the runner const environment = server.environments.node app.use('*', async (req, res, next) => { const url = req.originalUrl // 1. Read index.html - let template = fs.readFileSync(path.resolve(__dirname, 'index.html'), 'utf-8') + const indexHtmlPath = path.resolve(__dirname, 'index.html') + let template = fs.readFileSync(indexHtmlPath, 'utf-8') // 2. Apply Vite HTML transforms. This injects the Vite HMR client, // and also applies HTML transforms from Vite plugins, e.g. global @@ -112,7 +114,7 @@ const server = createServer() const ssrEnvironment = server.environment.ssr const input = {} -const { createHandler } = await ssrEnvironment.runner.import('./entrypoint.js') +const { createHandler } = await ssrEnvironment.runner.import('./entry.js') const handler = createHandler(input) const response = handler(new Request('/')) @@ -186,10 +188,10 @@ function vitePluginVirtualIndexHtml(): Plugin { let html: string if (server) { this.addWatchFile('index.html') - html = await fs.promises.readFile('index.html', 'utf-8') + html = fs.readFileSync('index.html', 'utf-8') html = await server.transformIndexHtml('/', html) } else { - html = await fs.promises.readFile('dist/client/index.html', 'utf-8') + html = fs.readFileSync('dist/client/index.html', 'utf-8') } return `export default ${JSON.stringify(html)}` } diff --git a/docs/guide/api-environment-instances.md b/docs/guide/api-environment-instances.md index dac4039d2eb7bb..52768a9f1f4a09 100644 --- a/docs/guide/api-environment-instances.md +++ b/docs/guide/api-environment-instances.md @@ -74,9 +74,9 @@ class DevEnvironment { /** * Register a request to be processed with low priority. This is useful - * to avoid waterfalls. The Vite server has information about the imported - * modules by other requests, so it can warmup the module graph so the - * modules are already processed when they are requested. + * to avoid waterfalls. The Vite server has information about the + * imported modules by other requests, so it can warmup the module graph + * so the modules are already processed when they are requested. */ async warmupRequest(url: string): void } diff --git a/docs/guide/api-environment-plugins.md b/docs/guide/api-environment-plugins.md index f415cfc03af440..d6a1ee580a529c 100644 --- a/docs/guide/api-environment-plugins.md +++ b/docs/guide/api-environment-plugins.md @@ -135,14 +135,15 @@ const UnoCssPlugin = () => { // shared global state return { buildStart() { - // init per environment state with WeakMap, this.environment + // init per environment state with WeakMap + // using this.environment }, configureServer() { // use global hooks normally }, applyToEnvironment(environment) { // return true if this plugin should be active in this environment - // if the function isn't provided, the plugin is active in all environments + // if the hook is not used, the plugin is active in all environments }, resolveId(id, importer) { // only called for environments this plugin apply to diff --git a/docs/guide/api-environment-runtimes.md b/docs/guide/api-environment-runtimes.md index 4514b99d743d34..57f73c15d29131 100644 --- a/docs/guide/api-environment-runtimes.md +++ b/docs/guide/api-environment-runtimes.md @@ -84,7 +84,11 @@ One of the goals of this feature is to provide a customizable API to process and ```ts import { DevEnvironment, RemoteEnvironmentTransport } from 'vite' -function createWorkerdDevEnvironment(name: string, config: ResolvedConfig, context: DevEnvironmentContext) { +function createWorkerdDevEnvironment( + name: string, + config: ResolvedConfig, + context: DevEnvironmentContext +) { const hot = /* ... */ const connection = /* ... */ const transport = new RemoteEnvironmentTransport({ @@ -120,7 +124,8 @@ export class ModuleRunner { private debug?: ModuleRunnerDebugger, ) {} /** - * URL to execute. Accepts file path, server path, or id relative to the root. + * URL to execute. + * Accepts file path, server path, or id relative to the root. */ public async import(url: string): Promise /** @@ -128,12 +133,12 @@ export class ModuleRunner { */ public clearCache(): void /** - * Clears all caches, removes all HMR listeners, and resets source map support. + * Clear all caches, remove all HMR listeners, reset sourcemap support. * This method doesn't stop the HMR connection. */ public async close(): Promise /** - * Returns `true` if the runner has been closed by calling `close()` method. + * Returns `true` if the runner has been closed by calling `close()`. */ public isClosed(): boolean } @@ -174,9 +179,12 @@ export interface ModuleRunnerOptions { */ transport: RunnerTransport /** - * Configure how source maps are resolved. Prefers `node` if `process.setSourceMapsEnabled` is available. - * Otherwise it will use `prepareStackTrace` by default which overrides `Error.prepareStackTrace` method. - * You can provide an object to configure how file contents and source maps are resolved for files that were not processed by Vite. + * Configure how source maps are resolved. + * Prefers `node` if `process.setSourceMapsEnabled` is available. + * Otherwise it will use `prepareStackTrace` by default which overrides + * `Error.prepareStackTrace` method. + * You can provide an object to configure how file contents and + * source maps are resolved for files that were not processed by Vite. */ sourcemapInterceptor?: | false @@ -190,7 +198,7 @@ export interface ModuleRunnerOptions { | false | { /** - * Configure how HMR communicates between the client and the server. + * Configure how HMR communicates between client and server. */ connection: ModuleRunnerHMRConnection /** @@ -199,7 +207,8 @@ export interface ModuleRunnerOptions { logger?: false | HMRLogger } /** - * Custom module cache. If not provided, it creates a separate module cache for each module runner instance. + * Custom module cache. If not provided, it creates a separate module + * cache for each module runner instance. */ evaluatedModules?: EvaluatedModules } @@ -344,7 +353,8 @@ export interface ModuleRunnerHMRConnection { send(payload: HotPayload): void /** * Configure how HMR is handled when this connection triggers an update. - * This method expects that the connection will start listening for HMR updates and call this callback when it's received. + * This method expects that the connection will start listening for HMR + * updates and call this callback when it's received. */ onUpdate(callback: (payload: HotPayload) => void): void } diff --git a/docs/guide/api-environment.md b/docs/guide/api-environment.md index d6d33b2e39352a..fd63475f39bda8 100644 --- a/docs/guide/api-environment.md +++ b/docs/guide/api-environment.md @@ -13,64 +13,77 @@ Please share with us your feedback as you test the proposal. ## Formalizing Environments -Vite 6 formalizes the concept of Environments. Until Vite 5, there were two implicit Environments (`client` and `ssr`). The new Environment API allows users to create as many environments as needed to map the way their apps work in production. This new capabilities required a big internal refactoring, but a big effort has been placed on backward compatibility. The initial goal of Vite 6 is to move the ecosystem to the new major as smoothly as possible, delaying the adoption of these new experimental APIs until enough users have migrated and frameworks and plugin authors have validated the new design. +Vite 6 formalizes the concept of Environments. Until Vite 5, there were two implicit Environments (`client`, and optionally `ssr`). The new Environment API allows users and framework authors to create as many environments as needed to map the way their apps work in production. This new capability required a big internal refactoring, but a lot of effort has been placed on backward compatibility. The initial goal of Vite 6 is to move the ecosystem to the new major as smoothly as possible, delaying the adoption of these new experimental APIs until enough users have migrated and frameworks and plugin authors have validated the new design. ## Closing the gap between build and dev -For a simple SPA, there is a single environment. The app will run in the user browser. During dev, except for Vite's requiring a modern browser, the environment matches closely the production runtime. In Vite 6, it would still be possible to use Vite without users knowing about environments. The usual vite config works for the default client environment in this case. +For a simple SPA/MPA, no new APIs around environments are exposed to the config. Internally, Vite will apply the options to a `client` environment, but it's not necessary to know of this concept when configuring Vite. The config and behavior from Vite 5 should work seamlessly here. -In a typical server side rendered Vite app, there are two environments. The client environment is running the app in the browser, and the node environment runs the server that performs SSR. When running Vite in dev mode, the server code is executed in the same Node process as the Vite dev server giving a close approximation of the production environment. But an app can run servers in other JS runtimes, like [Cloudflare's workerd](https://github.com/cloudflare/workerd). And it is also common for modern apps to have more than two environments (for example, an app could be running by a browser, a node server, and an edge server). Vite 5 didn't allow for these cases to be properly represented. +When we move to a typical server side rendered (SSR) app, we'll have two environments: -Vite 6 allows users to configure their app during build and dev to map all of its environments. During dev, a single Vite dev server can now be used to run code in multiple different environments concurrently. The app source code is still transformed by Vite dev server. On top of the shared HTTP server, middlewares, resolved config, and plugins pipeline, the Vite server now has a set of independent dev environments. Each of them is configured to match the production environment as closely as possible, and is connected to a dev runtime where the code is executed (for workerd, the server code can now run in miniflare locally). In the client, the browser imports and executes the code. In other environments, a module runner fetches and evaluates the transformed code. +- `client`: runs the app in the browser. +- `server`: runs the app in node (or other server runtimes) which renders pages before sending them to the browser. + +In dev, Vite executes the server code in the same Node process as the Vite dev server, giving a close approximation to the production environment. However, it is also possible for servers to run in other JS runtimes, like [Cloudflare's workerd](https://github.com/cloudflare/workerd) which have different constrains. Modern apps may also run in more than two environments, e.g. a browser, a node server, and an edge server. Vite 5 didn't allow to properly represent these environments. + +Vite 6 allows users to configure their app during build and dev to map all of its environments. During dev, a single Vite dev server can now be used to run code in multiple different environments concurrently. The app source code is still transformed by Vite dev server. On top of the shared HTTP server, middlewares, resolved config, and plugins pipeline, the Vite dev server now has a set of independent dev environments. Each of them is configured to match the production environment as closely as possible, and is connected to a dev runtime where the code is executed (for workerd, the server code can now run in miniflare locally). In the client, the browser imports and executes the code. In other environments, a module runner fetches and evaluates the transformed code. ![Vite Environments](../images/vite-environments.svg) -## Environment Configuration +## Environments Configuration -Environments are explicitly configured with the `environments` config option. +For an SPA/MPA, the configuration will look similar to Vite 5. Internally these options are used to configure the `client` environment. ```js -export default { - environments: { - client: { - resolve: { - conditions: [], // configure the Client environment - }, - }, - ssr: { - dev: { - optimizeDeps: {}, // configure the SSR environment - }, - }, - rsc: { - resolve: { - noExternal: true, // configure a custom environment - }, - }, +export default defineConfig({ + build: { + sourcemap: false, }, -} + optimizeDeps: { + include: ['lib'], + }, +}) ``` -All environment configs extend from user's root config, allowing users add defaults for all environments at the root level. This is quite useful for the common use case of configuring a Vite client only app, that can be done without going through `environments.client`. +This is important because we'd like to keep Vite approachable and avoid exposing new concepts until they are needed. + +If the app is composed of several environments, then these environments can be configured explicitly with the `environments` config option. ```js export default { - resolve: { - conditions: [], // configure a default for all environments + build: { + sourcemap: false, + }, + optimizeDeps: { + include: ['lib'], + }, + environments: { + server: {}, + edge: { + resolve: { + noExternal: true, + }, + }, }, } ``` -The `EnvironmentOptions` interface exposes all the per-environment options. There are `SharedEnvironmentOptions` that apply to both `build` and `dev`, like `resolve`. And there are `DevEnvironmentOptions` and `BuildEnvironmentOptions` for dev and build specific options (like `dev.optimizeDeps` or `build.outDir`). +When not explicitly documented, environment inherit the configured top-level config options (for example, the new `server` and `edge` environments will inherit the `build.sourcemap: false` option). A small number of top-level options, like `optimizeDeps`, only apply to the `client` environment, as they don't work well when applied as a default to server environments. The `client` environment can also be configured explicitly through `environments.client`, but we recommend to do it with the top-level options so the client config remains unchanged when adding new environments. + +The `EnvironmentOptions` interface exposes all the per-environment options. There are environment options that apply to both `build` and `dev`, like `resolve`. And there are `DevEnvironmentOptions` and `BuildEnvironmentOptions` for dev and build specific options (like `dev.warmup` or `build.outDir`). Some options like `optimizeDeps` only applies to dev, but is kept as top level instead of nested in `dev` for backward compatibility. ```ts -interface EnvironmentOptions extends SharedEnvironmentOptions { +interface EnvironmentOptions { + define?: Record + resolve?: EnvironmentResolveOptions + optimizeDeps: DepOptimizationOptions + consumer?: 'client' | 'server' dev: DevOptions build: BuildOptions } ``` -As we explained, Environment specific options defined at the root level of user config are used for the default client environment (the `UserConfig` interface extends from the `EnvironmentOptions` interface). And environments can be configured explicitly using the `environments` record. The `client` and `ssr` environments are always present during dev, even if an empty object is set to `environments`. This allows backward compatibility with `server.ssrLoadModule(url)` and `server.moduleGraph`. During build, the `client` environment is always present, and the `ssr` environment is only present if it is explicitly configured (using `environments.ssr` or for backward compatibility `build.ssr`). +The `UserConfig` interface extends from the `EnvironmentOptions` interface, allowing to configure the client and defaults for other environments, configured through the `environments` option. The `client` and a server environment named `ssr` are always present during dev. This allows backward compatibility with `server.ssrLoadModule(url)` and `server.moduleGraph`. During build, the `client` environment is always present, and the `ssr` environment is only present if it is explicitly configured (using `environments.ssr` or for backward compatibility `build.ssr`). An app doesn't need to use the `ssr` name for their SSR environment, it could name it `server` for example. ```ts interface UserConfig extends EnvironmentOptions { @@ -79,27 +92,21 @@ interface UserConfig extends EnvironmentOptions { } ``` -::: info - -The `ssr` top level property has many options in common with `EnvironmentOptions`. This option was created for the same use case as `environments` but only allowed configuration of a small number of options. We're going to deprecate it in favour of a unified way to define environment configuration. - -::: +Note that the `ssr` top-level property is going to be deprecated once the Environment API is stable. This option has the same role as `environments`, but for the default `ssr` environment and only allowed configuring of a small set of options. ## Custom environment instances -Low level configuration APIs are available so runtime providers can provide environments for their runtimes. +Low level configuration APIs are available so runtime providers can provide environments with proper defaults for their runtimes. These environments can also spawn other processes or threads to run the modules during dev in a closer runtime to the production environment. ```js -import { createCustomEnvironment } from 'vite-environment-provider' +import { customEnvironment } from 'vite-environment-provider' export default { + build: { + outDir: '/dist/client', + }, environments: { - client: { - build: { - outDir: '/dist/client', - }, - } - ssr: createCustomEnvironment({ + ssr: customEnvironment({ build: { outDir: '/dist/ssr', }, diff --git a/docs/guide/api-javascript.md b/docs/guide/api-javascript.md index c0a7a3d508fa33..a5bb3487f65a1c 100644 --- a/docs/guide/api-javascript.md +++ b/docs/guide/api-javascript.md @@ -110,8 +110,8 @@ interface ViteDevServer { httpServer: http.Server | null /** * Chokidar watcher instance. If `config.server.watch` is set to `null`, - * returns a noop event emitter. - * https://github.com/paulmillr/chokidar#api + * it will not watch any files and calling `add` will have no effect. + * https://github.com/paulmillr/chokidar#getting-started */ watcher: FSWatcher /** diff --git a/docs/guide/assets.md b/docs/guide/assets.md index e291f18aac1508..bef286c07969ea 100644 --- a/docs/guide/assets.md +++ b/docs/guide/assets.md @@ -55,6 +55,17 @@ import workletURL from 'extra-scalloped-border/worklet.js?url' CSS.paintWorklet.addModule(workletURL) ``` +### Explicit Inline Handling + +Assets can be explicitly imported with inlining or no inlining using the `?inline` or `?no-inline` suffix respectively. + +```js twoslash +import 'vite/client' +// ---cut--- +import imgUrl1 from './img.svg?no-inline' +import imgUrl2 from './img.png?inline' +``` + ### Importing Asset as String Assets can be imported as strings using the `?raw` suffix. diff --git a/docs/guide/backend-integration.md b/docs/guide/backend-integration.md index 1bf6265f8267bd..5a6cb5ce73a88f 100644 --- a/docs/guide/backend-integration.md +++ b/docs/guide/backend-integration.md @@ -61,15 +61,15 @@ If you need a custom integration, you can follow the steps in this guide to conf ```json [.vite/manifest.json] { - "_shared-!~{003}~.js": { - "file": "assets/shared-ChJ_j-JJ.css", - "src": "_shared-!~{003}~.js" - }, "_shared-B7PI925R.js": { "file": "assets/shared-B7PI925R.js", "name": "shared", "css": ["assets/shared-ChJ_j-JJ.css"] }, + "_shared-ChJ_j-JJ.css": { + "file": "assets/shared-ChJ_j-JJ.css", + "src": "_shared-ChJ_j-JJ.css" + }, "baz.js": { "file": "assets/baz-B2H3sXNv.js", "name": "baz", diff --git a/docs/guide/build.md b/docs/guide/build.md index 6472e6a1f4f64d..d0c1da79bdab28 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -200,7 +200,12 @@ import Bar from './Bar.vue' export { Foo, Bar } ``` -Running `vite build` with this config uses a Rollup preset that is oriented towards shipping libraries and produces two bundle formats: `es` and `umd` (configurable via `build.lib`): +Running `vite build` with this config uses a Rollup preset that is oriented towards shipping libraries and produces two bundle formats: + +- `es` and `umd` (for single entry) +- `es` and `cjs` (for multiple entries) + +The formats can be configured with the [`build.lib.formats`](/config/build-options.md#build-lib) option. ``` $ vite build @@ -251,6 +256,29 @@ Recommended `package.json` for your lib: ::: +### CSS support + +If your library imports any CSS, it will be bundled as a single CSS file besides the built JS files, e.g. `dist/my-lib.css`. The name defaults to `build.lib.fileName`, but can also be changed with [`build.lib.cssFileName`](/config/build-options.md#build-lib). + +You can export the CSS file in your `package.json` to be imported by users: + +```json {12} +{ + "name": "my-lib", + "type": "module", + "files": ["dist"], + "main": "./dist/my-lib.umd.cjs", + "module": "./dist/my-lib.js", + "exports": { + ".": { + "import": "./dist/my-lib.js", + "require": "./dist/my-lib.umd.cjs" + }, + "./style.css": "./dist/my-lib.css" + } +} +``` + ::: tip File Extensions If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.cjs` will become `.js`. ::: @@ -309,7 +337,9 @@ experimental: { if (type === 'public') { return 'https://www.domain.com/' + filename } else if (path.extname(hostId) === '.js') { - return { runtime: `window.__assetsPath(${JSON.stringify(filename)})` } + return { + runtime: `window.__assetsPath(${JSON.stringify(filename)})` + } } else { return 'https://cdn.domain.com/assets/' + filename } diff --git a/docs/guide/features.md b/docs/guide/features.md index dfd8c57f715ded..6575f489941d67 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -160,6 +160,50 @@ For example, to make the default import of `*.svg` a React component: ::: +## HTML + +HTML files stand [front-and-center](/guide/#index-html-and-project-root) of a Vite project, serving as the entry points for your application, making it simple to build single-page and [multi-page applications](/guide/build.html#multi-page-app). + +Any HTML files in your project root can be directly accessed by its respective directory path: + +- `/index.html` -> `http://localhost:5173/` +- `/about.html` -> `http://localhost:5173/about.html` +- `/blog/index.html` -> `http://localhost:5173/blog/index.html` + +Assets referenced by HTML elements such as ` + + +``` + +To opt-out of HTML processing on certain elements, you can add the `vite-ignore` attribute on the element, which can be useful when referencing external assets or CDN. + ## Vue Vite provides first-class Vue support: diff --git a/docs/guide/migration.md b/docs/guide/migration.md index 97277aab9c3b07..771aa2e4b75e5a 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -12,6 +12,23 @@ The experimental Vite Runtime API evolved into the Module Runner API, released i ## General Changes +### Default value for `resolve.conditions` + +This change does not affect users that did not configure [`resolve.conditions`](/config/shared-options#resolve-conditions) / [`ssr.resolve.conditions`](/config/ssr-options#ssr-resolve-conditions) / [`ssr.resolve.externalConditions`](/config/ssr-options#ssr-resolve-externalconditions). + +In Vite 5, the default value for `resolve.conditions` was `[]` and some conditions were added internally. The default value for `ssr.resolve.conditions` was the value of `resolve.conditions`. + +From Vite 6, some of the conditions are no longer added internally and need to be included in the config values. +The conditions that are no longer added internally for + +- `resolve.conditions` are `['module', 'browser', 'development|production']` +- `ssr.resolve.conditions` are `['module', 'node', 'development|production']` + +The default values for those options are updated to the corresponding values and `ssr.resolve.conditions` no longer uses `resolve.conditions` as the default value. Note that `development|production` is a special variable that is replaced with `production` or `development` depending on the value of `process.env.NODE_ENV`. + +If you specified a custom value for `resolve.conditions` or `ssr.resolve.conditions`, you need to update it to include the new conditions. +For example, if you previously specified `['custom']` for `resolve.conditions`, you need to specify `['custom', 'module', 'browser', 'development|production']` instead. + ### JSON stringify In Vite 5, when [`json.stringify: true`](/config/shared-options#json-stringify) is set, [`json.namedExports`](/config/shared-options#json-namedexports) was disabled. @@ -20,14 +37,64 @@ From Vite 6, even when `json.stringify: true` is set, `json.namedExports` is not Vite 6 also introduces a new default value for `json.stringify` which is `'auto'`, which will only stringify large JSON files. To disable this behavior, set `json.stringify: false`. +### Extended support of asset references in HTML elements + +In Vite 5, only a few supported HTML elements were able to reference assets that will be processed and bundled by Vite, such as ``, ``, etc. + +Vite 6 extends the support to even more HTML elements. The full list can be found at the [HTML features](/guide/features.html#html) docs. + +To opt-out of HTML processing on certain elements, you can add the `vite-ignore` attribute on the element. + +### postcss-load-config + +[`postcss-load-config`](https://npmjs.com/package/postcss-load-config) has been updated to v6 from v4. [`tsx`](https://www.npmjs.com/package/tsx) or [`jiti`](https://www.npmjs.com/package/jiti) is now required to load TypeScript postcss config files instead of [`ts-node`](https://www.npmjs.com/package/ts-node). Also [`yaml`](https://www.npmjs.com/package/yaml) is now required to load YAML postcss config files. + +### Sass now uses modern API by default + +In Vite 5, the legacy API was used by default for Sass. Vite 5.4 added support for the modern API. + +From Vite 6, the modern API is used by default for Sass. If you wish to still use the legacy API, you can set [`css.preprocessorOptions.sass.api: 'legacy'` / `css.preprocessorOptions.scss.api: 'legacy'`](/config/shared-options#css-preprocessoroptions). But note that the legacy API support will be removed in Vite 7. + +To migrate to the modern API, see [the Sass documentation](https://sass-lang.com/documentation/breaking-changes/legacy-js-api/). + +### Customize CSS output file name in library mode + +In Vite 5, the CSS output file name in library mode was always `style.css` and cannot be easily changed through the Vite config. + +From Vite 6, the default file name now uses `"name"` in `package.json` similar to the JS output files. If [`build.lib.fileName`](/config/build-options.md#build-lib) is set with a string, the value will also be used for the CSS output file name. To explicitly set a different CSS file name, you can use the new [`build.lib.cssFileName`](/config/build-options.md#build-lib) to configure it. + +To migrate, if you had relied on the `style.css` file name, you should update references to it to the new name based on your package name. For example: + +```json [package.json] +{ + "name": "my-lib", + "exports": { + "./style.css": "./dist/style.css" // [!code --] + "./style.css": "./dist/my-lib.css" // [!code ++] + } +} +``` + +If you prefer to stick with `style.css` like in Vite 5, you can set `build.lib.cssFileName: 'style'` instead. + ## Advanced There are other breaking changes which only affect few users. +- [[#15637] fix!: default `build.cssMinify` to `'esbuild'` for SSR](https://github.com/vitejs/vite/pull/15637) + - [`build.cssMinify`](/config/build-options#build-cssminify) is now enabled by default even for SSR builds. +- [[#18070] feat!: proxy bypass with WebSocket](https://github.com/vitejs/vite/pull/18070) + - `server.proxy[path].bypass` is now called for WebSocket upgrade requests and in that case, the `res` parameter will be `undefined`. - [[#18209] refactor!: bump minimal terser version to 5.16.0](https://github.com/vitejs/vite/pull/18209) - Minimal supported terser version for [`build.minify: 'terser'`](/config/build-options#build-minify) was bumped to 5.16.0 from 5.4.0. +- [[#18231] chore(deps): update dependency @rollup/plugin-commonjs to v28](https://github.com/vitejs/vite/pull/18231) + - [`commonjsOptions.strictRequires`](https://github.com/rollup/plugins/blob/master/packages/commonjs/README.md#strictrequires) is now `true` by default (was `'auto'` before). + - This may lead to larger bundle sizes but will result in more deterministic builds. + - If you are specifying a CommonJS file as an entry point, you may need additional steps. Read [the commonjs plugin documentation](https://github.com/rollup/plugins/blob/master/packages/commonjs/README.md#using-commonjs-files-as-entry-points) for more details. - [[#18243] chore(deps)!: migrate `fast-glob` to `tinyglobby`](https://github.com/vitejs/vite/pull/18243) - Range braces (`{01..03}` ⇒ `['01', '02', '03']`) and incremental braces (`{2..8..2}` ⇒ `['2', '4', '6', '8']`) are no longer supported in globs. +- [[#18493] refactor!: remove fs.cachedChecks option](https://github.com/vitejs/vite/pull/18493) + - This opt-in optimization was removed due to edge cases when writing a file in a cached folder and immediately importing it. ## Migration from v4 diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index 2b8bd313e137ba..1e2ea3be7d6bd7 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -67,7 +67,7 @@ This is statically replaced during build so it will allow tree-shaking of unused ## Setting Up the Dev Server -When building an SSR app, you likely want to have full control over your main server and decouple Vite from the production environment. It is therefore recommended to use Vite in middleware mode. Here is an example with [express](https://expressjs.com/): +When building an SSR app, you likely want to have full control over your main server and decouple Vite from the production environment. It is therefore recommended to use Vite in middleware mode. Here is an example with [express](https://expressjs.com/) (v4): ```js{15-18} twoslash [server.js] import fs from 'node:fs' diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md index 7386a7cead4b21..1804b589ceb3ed 100644 --- a/docs/guide/troubleshooting.md +++ b/docs/guide/troubleshooting.md @@ -54,11 +54,12 @@ When importing a ESM only package by `require`, the following error happens. > Failed to resolve "foo". This package is ESM only but it was tried to load by `require`. -> "foo" resolved to an ESM file. ESM file cannot be loaded by `require`. +> Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/dependency.js from /path/to/vite.config.js not supported. +> Instead change the require of index.js in /path/to/vite.config.js to a dynamic import() which is available in all CommonJS modules. -ESM files cannot be loaded by [`require`](). +In Node.js <=22, ESM files cannot be loaded by [`require`](https://nodejs.org/docs/latest-v22.x/api/esm.html#require) by default. -We recommend converting your config to ESM by either: +While it may work using [`--experimental-require-module`](https://nodejs.org/docs/latest-v22.x/api/modules.html#loading-ecmascript-modules-using-require), or Node.js >22, or in other runtimes, we still recommend converting your config to ESM by either: - adding `"type": "module"` to the nearest `package.json` - renaming `vite.config.js`/`vite.config.ts` to `vite.config.mjs`/`vite.config.mts` diff --git a/docs/package.json b/docs/package.json index b7567fb2a9d1da..f605319f619124 100644 --- a/docs/package.json +++ b/docs/package.json @@ -8,10 +8,10 @@ "docs-serve": "vitepress serve" }, "devDependencies": { - "@shikijs/vitepress-twoslash": "^1.22.0", + "@shikijs/vitepress-twoslash": "^1.22.2", "@types/express": "^4.17.21", "feed": "^4.2.2", - "vitepress": "1.4.1", + "vitepress": "^1.5.0", "vitepress-plugin-group-icons": "^1.3.0", "vue": "^3.5.12" } diff --git a/eslint.config.js b/eslint.config.js index 0c936aa7986ff1..968a7a89b5e1a4 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -85,7 +85,15 @@ export default tseslint.config( 'n/no-extraneous-import': [ 'error', { - allowModules: ['vite', 'less', 'sass', 'vitest', 'unbuild'], + allowModules: [ + 'vite', + 'less', + 'sass', + 'sass-embedded', + 'lightningcss', + 'vitest', + 'unbuild', + ], }, ], 'n/no-extraneous-require': [ @@ -196,7 +204,6 @@ export default tseslint.config( 'playground/**/*dep*/**', 'playground/resolve/browser-module-field2/index.web.js', 'playground/resolve/browser-field/**', - 'playground/tailwind/**', // blocked by https://github.com/postcss/postcss-load-config/issues/239 ], rules: { 'import-x/no-commonjs': 'error', diff --git a/justfile b/justfile new file mode 100644 index 00000000000000..d4ae9ad619939c --- /dev/null +++ b/justfile @@ -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 diff --git a/package.json b/package.json index a48ecc09c66669..8606cd558c4bb7 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "ci-docs": "pnpm build && pnpm docs-build" }, "devDependencies": { - "@eslint/js": "^9.13.0", + "@eslint/js": "^9.14.0", "@type-challenges/utils": "^0.1.1", "@types/babel__core": "^7.20.5", "@types/babel__preset-env": "^7.9.7", @@ -50,34 +50,33 @@ "@types/estree": "^1.0.6", "@types/etag": "^1.8.3", "@types/less": "^3.0.6", - "@types/micromatch": "^4.0.9", - "@types/node": "^20.16.13", + "@types/node": "^22.8.7", "@types/picomatch": "^3.0.1", "@types/stylus": "^0.48.43", - "@types/ws": "^8.5.12", + "@types/ws": "^8.5.13", "@vitejs/release-scripts": "^1.3.2", "conventional-changelog-cli": "^5.0.0", - "eslint": "^9.13.0", - "eslint-plugin-import-x": "^4.3.1", - "eslint-plugin-n": "^17.11.1", + "eslint": "^9.14.0", + "eslint-plugin-import-x": "^4.4.0", + "eslint-plugin-n": "^17.12.0", "eslint-plugin-regexp": "^2.6.0", - "execa": "^9.4.1", + "execa": "^9.5.1", "globals": "^15.11.0", "gsap": "^3.12.5", "lint-staged": "^15.2.10", "picocolors": "^1.1.1", - "playwright-chromium": "^1.48.1", + "playwright-chromium": "^1.48.2", + "premove": "^4.0.0", "prettier": "3.3.3", - "rimraf": "^5.0.10", - "rollup": "^4.22.5", + "rollup": "^4.23.0", "rollup-plugin-esbuild": "^6.1.1", "simple-git-hooks": "^2.11.1", - "tslib": "^2.8.0", - "tsx": "^4.19.1", + "tslib": "^2.8.1", + "tsx": "^4.19.2", "typescript": "~5.6.2", - "typescript-eslint": "^8.10.0", + "typescript-eslint": "^8.12.2", "vite": "workspace:*", - "vitest": "^2.1.3" + "vitest": "^2.1.4" }, "simple-git-hooks": { "pre-commit": "pnpm exec lint-staged --concurrent false" @@ -96,16 +95,14 @@ "eslint --cache --fix" ] }, - "packageManager": "pnpm@9.12.2", + "packageManager": "pnpm@9.12.3", "pnpm": { "overrides": { "vite": "workspace:*" }, "patchedDependencies": { - "chokidar@3.6.0": "patches/chokidar@3.6.0.patch", "http-proxy@1.18.1": "patches/http-proxy@1.18.1.patch", - "sirv@3.0.0": "patches/sirv@3.0.0.patch", - "acorn@8.13.0": "patches/acorn@8.13.0.patch" + "sirv@3.0.0": "patches/sirv@3.0.0.patch" }, "peerDependencyRules": { "allowedVersions": { @@ -116,6 +113,18 @@ "postcss", "search-insights" ] + }, + "packageExtensions": { + "sass-embedded": { + "peerDependencies": { + "source-map-js": "*" + }, + "peerDependenciesMeta": { + "source-map-js": { + "optional": true + } + } + } } }, "stackblitz": { diff --git a/packages/create-vite/CHANGELOG.md b/packages/create-vite/CHANGELOG.md index 64523c97fade05..9c65036a997e03 100644 --- a/packages/create-vite/CHANGELOG.md +++ b/packages/create-vite/CHANGELOG.md @@ -1,3 +1,11 @@ +## 5.5.5 (2024-10-30) + +* chore: upgrade to unbuild v3 rc (#18502) ([ddd5c5d](https://github.com/vitejs/vite/commit/ddd5c5d00ff7894462a608841560883f9c771f22)), closes [#18502](https://github.com/vitejs/vite/issues/18502) +* fix(create-vite): add tsBuildInfoFile option (#18435) ([0a4427f](https://github.com/vitejs/vite/commit/0a4427fc44b9b2075225bf8a9f1d88a8a428a217)), closes [#18435](https://github.com/vitejs/vite/issues/18435) +* fix(deps): update all non-major dependencies (#18484) ([2ec12df](https://github.com/vitejs/vite/commit/2ec12df98d07eb4c986737e86a4a9f8066724658)), closes [#18484](https://github.com/vitejs/vite/issues/18484) + + + ## 5.5.4 (2024-10-23) * chore: change Angular customCommand (#18425) ([b53db53](https://github.com/vitejs/vite/commit/b53db53df17c43602d61a24e9bf579267ee8eb6b)), closes [#18425](https://github.com/vitejs/vite/issues/18425) diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts index b23f881a34b123..473cd5184ad728 100644 --- a/packages/create-vite/__tests__/cli.spec.ts +++ b/packages/create-vite/__tests__/cli.spec.ts @@ -8,6 +8,7 @@ const CLI_PATH = path.join(__dirname, '..') const projectName = 'test-app' const genPath = path.join(__dirname, projectName) +const genPathWithSubfolder = path.join(__dirname, 'subfolder', projectName) const run = ( args: string[], @@ -17,12 +18,13 @@ const run = ( } // Helper to create a non-empty directory -const createNonEmptyDir = () => { +const createNonEmptyDir = (overrideFolder?: string) => { // Create the temporary directory - fs.mkdirSync(genPath, { recursive: true }) + const newNonEmptyFolder = overrideFolder || genPath + fs.mkdirSync(newNonEmptyFolder, { recursive: true }) // Create a package.json file - const pkgJson = path.join(genPath, 'package.json') + const pkgJson = path.join(newNonEmptyFolder, 'package.json') fs.writeFileSync(pkgJson, '{ "foo": "bar" }') } @@ -33,8 +35,24 @@ const templateFiles = fs .map((filePath) => (filePath === '_gitignore' ? '.gitignore' : filePath)) .sort() -beforeAll(() => fs.rmSync(genPath, { recursive: true, force: true })) -afterEach(() => fs.rmSync(genPath, { recursive: true, force: true })) +// React starter template +const templateFilesReact = fs + .readdirSync(path.join(CLI_PATH, 'template-react')) + // _gitignore is renamed to .gitignore + .map((filePath) => (filePath === '_gitignore' ? '.gitignore' : filePath)) + .sort() + +const clearAnyPreviousFolders = () => { + if (fs.existsSync(genPath)) { + fs.rmSync(genPath, { recursive: true, force: true }) + } + if (fs.existsSync(genPathWithSubfolder)) { + fs.rmSync(genPathWithSubfolder, { recursive: true, force: true }) + } +} + +beforeAll(() => clearAnyPreviousFolders()) +afterEach(() => clearAnyPreviousFolders()) test('prompts for the project name if none supplied', () => { const { stdout } = run([]) @@ -70,6 +88,14 @@ test('asks to overwrite non-empty target directory', () => { expect(stdout).toContain(`Target directory "${projectName}" is not empty.`) }) +test('asks to overwrite non-empty target directory with subfolder', () => { + createNonEmptyDir(genPathWithSubfolder) + const { stdout } = run([`subfolder/${projectName}`], { cwd: __dirname }) + expect(stdout).toContain( + `Target directory "subfolder/${projectName}" is not empty.`, + ) +}) + test('asks to overwrite non-empty current directory', () => { createNonEmptyDir() const { stdout } = run(['.'], { cwd: genPath }) @@ -87,6 +113,17 @@ test('successfully scaffolds a project based on vue starter template', () => { expect(templateFiles).toEqual(generatedFiles) }) +test('successfully scaffolds a project with subfolder based on react starter template', () => { + const { stdout } = run([`subfolder/${projectName}`, '--template', 'react'], { + cwd: __dirname, + }) + const generatedFiles = fs.readdirSync(genPathWithSubfolder).sort() + + // Assertions + expect(stdout).toContain(`Scaffolding project in ${genPathWithSubfolder}`) + expect(templateFilesReact).toEqual(generatedFiles) +}) + test('works with the -t alias', () => { const { stdout } = run([projectName, '-t', 'vue'], { cwd: __dirname, diff --git a/packages/create-vite/build.config.ts b/packages/create-vite/build.config.ts index 9a58c2127ff803..1d32facdff7f2a 100644 --- a/packages/create-vite/build.config.ts +++ b/packages/create-vite/build.config.ts @@ -23,7 +23,6 @@ export default defineBuildConfig({ 'rollup:options'(_ctx, options) { options.plugins = [ options.plugins, - // @ts-expect-error TODO: unbuild uses rollup v3 and Vite uses rollup v4 licensePlugin( path.resolve(__dirname, './LICENSE'), 'create-vite license', diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 6f083cf4a0dc3d..e222a87a421ddb 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -1,6 +1,6 @@ { "name": "create-vite", - "version": "5.5.4", + "version": "5.5.5", "type": "module", "license": "MIT", "author": "Evan You", @@ -39,6 +39,6 @@ "minimist": "^1.2.8", "picocolors": "^1.1.1", "prompts": "^2.4.2", - "unbuild": "^2.0.0" + "unbuild": "^3.0.0-rc.11" } } diff --git a/packages/create-vite/src/index.ts b/packages/create-vite/src/index.ts index 03fde7a3b9cebc..0c67d3c41fe5ce 100755 --- a/packages/create-vite/src/index.ts +++ b/packages/create-vite/src/index.ts @@ -310,8 +310,7 @@ async function init() { } let targetDir = argTargetDir || defaultTargetDir - const getProjectName = () => - targetDir === '.' ? path.basename(path.resolve()) : targetDir + const getProjectName = () => path.basename(path.resolve(targetDir)) let result: prompts.Answers< 'projectName' | 'overwrite' | 'packageName' | 'framework' | 'variant' diff --git a/packages/create-vite/template-lit-ts/package.json b/packages/create-vite/template-lit-ts/package.json index 7e6e27dc806c3b..eced679f808b0e 100644 --- a/packages/create-vite/template-lit-ts/package.json +++ b/packages/create-vite/template-lit-ts/package.json @@ -13,6 +13,6 @@ }, "devDependencies": { "typescript": "~5.6.2", - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-lit/package.json b/packages/create-vite/template-lit/package.json index 914e53c6d9d894..b1812ad8b50ba6 100644 --- a/packages/create-vite/template-lit/package.json +++ b/packages/create-vite/template-lit/package.json @@ -12,6 +12,6 @@ "lit": "^3.2.1" }, "devDependencies": { - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-preact-ts/package.json b/packages/create-vite/template-preact-ts/package.json index 66a6847b413487..880c03ef643208 100644 --- a/packages/create-vite/template-preact-ts/package.json +++ b/packages/create-vite/template-preact-ts/package.json @@ -14,6 +14,6 @@ "devDependencies": { "@preact/preset-vite": "^2.9.1", "typescript": "~5.6.2", - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-preact-ts/tsconfig.app.json b/packages/create-vite/template-preact-ts/tsconfig.app.json index 634dfa3cfcf6de..00a7cc1e9e6de0 100644 --- a/packages/create-vite/template-preact-ts/tsconfig.app.json +++ b/packages/create-vite/template-preact-ts/tsconfig.app.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", diff --git a/packages/create-vite/template-preact-ts/tsconfig.node.json b/packages/create-vite/template-preact-ts/tsconfig.node.json index 9dad70185e2dda..abcd7f0dacddc7 100644 --- a/packages/create-vite/template-preact-ts/tsconfig.node.json +++ b/packages/create-vite/template-preact-ts/tsconfig.node.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "target": "ES2022", "lib": ["ES2023"], "module": "ESNext", diff --git a/packages/create-vite/template-preact/package.json b/packages/create-vite/template-preact/package.json index 8900fe20a0a754..a063e92176b36b 100644 --- a/packages/create-vite/template-preact/package.json +++ b/packages/create-vite/template-preact/package.json @@ -13,6 +13,6 @@ }, "devDependencies": { "@preact/preset-vite": "^2.9.1", - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-qwik-ts/package.json b/packages/create-vite/template-qwik-ts/package.json index 1b75ef3c54cd32..558bb6bc51ddf1 100644 --- a/packages/create-vite/template-qwik-ts/package.json +++ b/packages/create-vite/template-qwik-ts/package.json @@ -11,7 +11,7 @@ "devDependencies": { "serve": "^14.2.4", "typescript": "~5.6.2", - "vite": "^5.4.9" + "vite": "^5.4.10" }, "dependencies": { "@builder.io/qwik": "^1.9.1" diff --git a/packages/create-vite/template-qwik-ts/tsconfig.app.json b/packages/create-vite/template-qwik-ts/tsconfig.app.json index 0052c0d84a6c61..0d65579a463d96 100644 --- a/packages/create-vite/template-qwik-ts/tsconfig.app.json +++ b/packages/create-vite/template-qwik-ts/tsconfig.app.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", diff --git a/packages/create-vite/template-qwik-ts/tsconfig.node.json b/packages/create-vite/template-qwik-ts/tsconfig.node.json index 9dad70185e2dda..abcd7f0dacddc7 100644 --- a/packages/create-vite/template-qwik-ts/tsconfig.node.json +++ b/packages/create-vite/template-qwik-ts/tsconfig.node.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "target": "ES2022", "lib": ["ES2023"], "module": "ESNext", diff --git a/packages/create-vite/template-qwik/package.json b/packages/create-vite/template-qwik/package.json index cc4e3f99282f05..2fd6460663f333 100644 --- a/packages/create-vite/template-qwik/package.json +++ b/packages/create-vite/template-qwik/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "serve": "^14.2.4", - "vite": "^5.4.9" + "vite": "^5.4.10" }, "dependencies": { "@builder.io/qwik": "^1.9.1" diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index 2a4a6e19218bd9..22405c61da2d9a 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -14,16 +14,16 @@ "react-dom": "^18.3.1" }, "devDependencies": { - "@eslint/js": "^9.13.0", - "@types/react": "^18.3.11", + "@eslint/js": "^9.14.0", + "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^4.3.3", - "eslint": "^9.13.0", + "eslint": "^9.14.0", "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.13", + "eslint-plugin-react-refresh": "^0.4.14", "globals": "^15.11.0", "typescript": "~5.6.2", - "typescript-eslint": "^8.10.0", - "vite": "^5.4.9" + "typescript-eslint": "^8.12.2", + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-react-ts/tsconfig.app.json b/packages/create-vite/template-react-ts/tsconfig.app.json index 5a2def4b7a3dd0..f867de0dd1a838 100644 --- a/packages/create-vite/template-react-ts/tsconfig.app.json +++ b/packages/create-vite/template-react-ts/tsconfig.app.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], diff --git a/packages/create-vite/template-react-ts/tsconfig.node.json b/packages/create-vite/template-react-ts/tsconfig.node.json index 9dad70185e2dda..abcd7f0dacddc7 100644 --- a/packages/create-vite/template-react-ts/tsconfig.node.json +++ b/packages/create-vite/template-react-ts/tsconfig.node.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "target": "ES2022", "lib": ["ES2023"], "module": "ESNext", diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index 22c0e5f5986bc6..09cfad29bc8210 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -14,15 +14,15 @@ "react-dom": "^18.3.1" }, "devDependencies": { - "@eslint/js": "^9.13.0", - "@types/react": "^18.3.11", + "@eslint/js": "^9.14.0", + "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^4.3.3", - "eslint": "^9.13.0", - "eslint-plugin-react": "^7.37.1", + "eslint": "^9.14.0", + "eslint-plugin-react": "^7.37.2", "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.13", + "eslint-plugin-react-refresh": "^0.4.14", "globals": "^15.11.0", - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-solid-ts/package.json b/packages/create-vite/template-solid-ts/package.json index 7410d37fd435a9..4deb5555aecc78 100644 --- a/packages/create-vite/template-solid-ts/package.json +++ b/packages/create-vite/template-solid-ts/package.json @@ -9,11 +9,11 @@ "preview": "vite preview" }, "dependencies": { - "solid-js": "^1.9.2" + "solid-js": "^1.9.3" }, "devDependencies": { "typescript": "~5.6.2", - "vite": "^5.4.9", + "vite": "^5.4.10", "vite-plugin-solid": "^2.10.2" } } diff --git a/packages/create-vite/template-solid-ts/tsconfig.app.json b/packages/create-vite/template-solid-ts/tsconfig.app.json index c6ab232ad54098..c811fcbb39008c 100644 --- a/packages/create-vite/template-solid-ts/tsconfig.app.json +++ b/packages/create-vite/template-solid-ts/tsconfig.app.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", diff --git a/packages/create-vite/template-solid-ts/tsconfig.node.json b/packages/create-vite/template-solid-ts/tsconfig.node.json index 9dad70185e2dda..abcd7f0dacddc7 100644 --- a/packages/create-vite/template-solid-ts/tsconfig.node.json +++ b/packages/create-vite/template-solid-ts/tsconfig.node.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "target": "ES2022", "lib": ["ES2023"], "module": "ESNext", diff --git a/packages/create-vite/template-solid/package.json b/packages/create-vite/template-solid/package.json index 25827c6f253169..08c53b8e10ebf3 100644 --- a/packages/create-vite/template-solid/package.json +++ b/packages/create-vite/template-solid/package.json @@ -9,10 +9,10 @@ "preview": "vite preview" }, "dependencies": { - "solid-js": "^1.9.2" + "solid-js": "^1.9.3" }, "devDependencies": { - "vite": "^5.4.9", + "vite": "^5.4.10", "vite-plugin-solid": "^2.10.2" } } diff --git a/packages/create-vite/template-svelte-ts/package.json b/packages/create-vite/template-svelte-ts/package.json index 378e8a1e3e22aa..bb890983838037 100644 --- a/packages/create-vite/template-svelte-ts/package.json +++ b/packages/create-vite/template-svelte-ts/package.json @@ -12,10 +12,10 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "^4.0.0", "@tsconfig/svelte": "^5.0.4", - "svelte": "^5.0.3", + "svelte": "^5.1.9", "svelte-check": "^4.0.5", - "tslib": "^2.8.0", + "tslib": "^2.8.1", "typescript": "~5.6.2", - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-svelte/package.json b/packages/create-vite/template-svelte/package.json index 957c9b713bbbef..7f5cdf964652b7 100644 --- a/packages/create-vite/template-svelte/package.json +++ b/packages/create-vite/template-svelte/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^4.0.0", - "svelte": "^5.0.3", - "vite": "^5.4.9" + "svelte": "^5.1.9", + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-vanilla-ts/package.json b/packages/create-vite/template-vanilla-ts/package.json index 035daaaa9bb7c7..097fd443d9ca0c 100644 --- a/packages/create-vite/template-vanilla-ts/package.json +++ b/packages/create-vite/template-vanilla-ts/package.json @@ -10,6 +10,6 @@ }, "devDependencies": { "typescript": "~5.6.2", - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-vanilla/package.json b/packages/create-vite/template-vanilla/package.json index 0582c8fc5a4182..25ce0ee8f96763 100644 --- a/packages/create-vite/template-vanilla/package.json +++ b/packages/create-vite/template-vanilla/package.json @@ -9,6 +9,6 @@ "preview": "vite preview" }, "devDependencies": { - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index 1a1f10bc9c0221..c70ea5462092f3 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -14,7 +14,7 @@ "devDependencies": { "@vitejs/plugin-vue": "^5.1.4", "typescript": "~5.6.2", - "vite": "^5.4.9", - "vue-tsc": "^2.1.6" + "vite": "^5.4.10", + "vue-tsc": "^2.1.10" } } diff --git a/packages/create-vite/template-vue-ts/tsconfig.app.json b/packages/create-vite/template-vue-ts/tsconfig.app.json index 909eec5c6cf9c4..cb88a5a6c26b25 100644 --- a/packages/create-vite/template-vue-ts/tsconfig.app.json +++ b/packages/create-vite/template-vue-ts/tsconfig.app.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", diff --git a/packages/create-vite/template-vue-ts/tsconfig.node.json b/packages/create-vite/template-vue-ts/tsconfig.node.json index 9dad70185e2dda..abcd7f0dacddc7 100644 --- a/packages/create-vite/template-vue-ts/tsconfig.node.json +++ b/packages/create-vite/template-vue-ts/tsconfig.node.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "target": "ES2022", "lib": ["ES2023"], "module": "ESNext", diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index 1226201afd9108..73abde63941bf5 100644 --- a/packages/create-vite/template-vue/package.json +++ b/packages/create-vite/template-vue/package.json @@ -13,6 +13,6 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^5.1.4", - "vite": "^5.4.9" + "vite": "^5.4.10" } } diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index ee0a4a7e8bdf62..51c322575dd105 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,19 @@ +## 5.4.3 (2024-10-25) + +* chore: enable some eslint rules (#18084) ([e9a2746](https://github.com/vitejs/vite/commit/e9a2746ca77473b1814fd05db3d299c074135fe5)), closes [#18084](https://github.com/vitejs/vite/issues/18084) +* chore: remove stale TODOs (#17866) ([e012f29](https://github.com/vitejs/vite/commit/e012f296df583bd133d26399397bd4ae49de1497)), closes [#17866](https://github.com/vitejs/vite/issues/17866) +* chore: update license copyright (#18278) ([56eb869](https://github.com/vitejs/vite/commit/56eb869a67551a257d20cba00016ea59b1e1a2c4)), closes [#18278](https://github.com/vitejs/vite/issues/18278) +* chore(deps): update all non-major dependencies (#17945) ([cfb621e](https://github.com/vitejs/vite/commit/cfb621e7a5a3e24d710a9af156e6855e73caf891)), closes [#17945](https://github.com/vitejs/vite/issues/17945) +* chore(deps): update all non-major dependencies (#18050) ([7cac03f](https://github.com/vitejs/vite/commit/7cac03fa5197a72d2e2422bd0243a85a9a18abfc)), closes [#18050](https://github.com/vitejs/vite/issues/18050) +* chore(deps): update all non-major dependencies (#18404) ([802839d](https://github.com/vitejs/vite/commit/802839d48335a69eb15f71f2cd816d0b6e4d3556)), closes [#18404](https://github.com/vitejs/vite/issues/18404) +* fix(deps): update all non-major dependencies (#18170) ([c8aea5a](https://github.com/vitejs/vite/commit/c8aea5ae0af90dc6796ef3bdd612d1eb819f157b)), closes [#18170](https://github.com/vitejs/vite/issues/18170) +* fix(deps): update all non-major dependencies (#18292) ([5cac054](https://github.com/vitejs/vite/commit/5cac0544dca2764f0114aac38e9922a0c13d7ef4)), closes [#18292](https://github.com/vitejs/vite/issues/18292) +* fix(deps): update all non-major dependencies (#18345) ([5552583](https://github.com/vitejs/vite/commit/5552583a2272cd4208b30ad60e99d984e34645f0)), closes [#18345](https://github.com/vitejs/vite/issues/18345) +* fix(legacy): generate sourcemap for polyfill chunks (#18250) ([f311ff3](https://github.com/vitejs/vite/commit/f311ff3c2b19636457c3023095ef32ab9a96b84a)), closes [#18250](https://github.com/vitejs/vite/issues/18250) +* perf: use `crypto.hash` when available (#18317) ([2a14884](https://github.com/vitejs/vite/commit/2a148844cf2382a5377b75066351f00207843352)), closes [#18317](https://github.com/vitejs/vite/issues/18317) + + + ## 5.4.2 (2024-08-15) * chore: extend commit hash (#17709) ([4fc9b64](https://github.com/vitejs/vite/commit/4fc9b6424c27aca8004c368b69991a56264e4fdb)), closes [#17709](https://github.com/vitejs/vite/issues/17709) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 3b8cda837bc889..8da3da8ad1306e 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,7 @@ { "name": "@vitejs/plugin-legacy", - "version": "5.4.2", + "version": "5.4.3", + "type": "module", "license": "MIT", "author": "Evan You", "files": [ @@ -23,7 +24,6 @@ }, "scripts": { "dev": "unbuild --stub", - "build": "unbuild && pnpm run patch-cjs", "patch-cjs": "tsx ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, @@ -41,11 +41,11 @@ "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme", "funding": "https://github.com/vitejs/vite?sponsor=1", "dependencies": { - "@babel/core": "^7.25.8", - "@babel/preset-env": "^7.25.8", - "browserslist": "^4.24.0", + "@babel/core": "^7.26.0", + "@babel/preset-env": "^7.26.0", + "browserslist": "^4.24.2", "browserslist-to-esbuild": "^2.1.1", - "core-js": "^3.38.1", + "core-js": "^3.39.0", "magic-string": "^0.30.12", "regenerator-runtime": "^0.14.1", "systemjs": "^6.15.1" @@ -55,9 +55,9 @@ "vite": "^5.0.0" }, "devDependencies": { - "acorn": "^8.13.0", + "acorn": "^8.14.0", "picocolors": "^1.1.1", - "unbuild": "^2.0.0", + "unbuild": "^3.0.0-rc.11", "vite": "workspace:*" } } diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index ea6d5e972ddfec..7098f18bd2710b 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,85 @@ +## 6.0.0-beta.8 (2024-11-01) + +* fix: allow nested dependency selector to be used for `optimizeDeps.include` for SSR (#18506) ([826c81a](https://github.com/vitejs/vite/commit/826c81a40bb25914d55cd2e96b548f1a2c384a19)), closes [#18506](https://github.com/vitejs/vite/issues/18506) +* fix: asset `new URL(,import.meta.url)` match (#18194) ([5286a90](https://github.com/vitejs/vite/commit/5286a90a3c1b693384f99903582a1f70b7b44945)), closes [#18194](https://github.com/vitejs/vite/issues/18194) +* fix: close watcher if it's disabled (#18521) ([85bd0e9](https://github.com/vitejs/vite/commit/85bd0e9b0dc637c7645f2b56f93071d6e1ec149c)), closes [#18521](https://github.com/vitejs/vite/issues/18521) +* fix(config): write temporary vite config to node_modules (#18509) ([72eaef5](https://github.com/vitejs/vite/commit/72eaef5300d20b7163050461733c3208a4013e1e)), closes [#18509](https://github.com/vitejs/vite/issues/18509) +* fix(css): `cssCodeSplit` uses the current environment configuration (#18486) ([eefe895](https://github.com/vitejs/vite/commit/eefe8957167681b85f0e1b07bc5feefa307cccb0)), closes [#18486](https://github.com/vitejs/vite/issues/18486) +* fix(json): don't `json.stringify` arrays (#18541) ([fa50b03](https://github.com/vitejs/vite/commit/fa50b03390dae280293174f65f850522599b9ab7)), closes [#18541](https://github.com/vitejs/vite/issues/18541) +* fix(less): prevent rebasing `@import url(...)` (#17857) ([aec5fdd](https://github.com/vitejs/vite/commit/aec5fdd72e3aeb2aa26796001b98f3f330be86d1)), closes [#17857](https://github.com/vitejs/vite/issues/17857) +* fix(lib): only resolve css bundle name if have styles (#18530) ([5d6dc49](https://github.com/vitejs/vite/commit/5d6dc491b6bb78613694eaf686e2e305b71af5e1)), closes [#18530](https://github.com/vitejs/vite/issues/18530) +* fix(scss): improve error logs (#18522) ([3194a6a](https://github.com/vitejs/vite/commit/3194a6a60714a3978f5e4b39d6223f32a8dc01ef)), closes [#18522](https://github.com/vitejs/vite/issues/18522) +* feat(html)!: support more asset sources (#11138) ([8a7af50](https://github.com/vitejs/vite/commit/8a7af50b5ddf72f21098406e9668bc609b323899)), closes [#11138](https://github.com/vitejs/vite/issues/11138) +* feat(resolve)!: allow removing conditions (#18395) ([d002e7d](https://github.com/vitejs/vite/commit/d002e7d05a0f23110f9185b39222819bcdfffc16)), closes [#18395](https://github.com/vitejs/vite/issues/18395) +* refactor!: remove fs.cachedChecks option (#18493) ([94b0857](https://github.com/vitejs/vite/commit/94b085735372588d5f92c7f4a8cf68e8291f2db0)), closes [#18493](https://github.com/vitejs/vite/issues/18493) +* refactor: client-only top-level warmup (#18524) ([a50ff60](https://github.com/vitejs/vite/commit/a50ff6000bca46a6fe429f2c3a98c486ea5ebc8e)), closes [#18524](https://github.com/vitejs/vite/issues/18524) + + + +## 6.0.0-beta.7 (2024-10-30) + +* chore: fix moduleSideEffects in build script on Windows (#18518) ([25fe9e3](https://github.com/vitejs/vite/commit/25fe9e3b48e29d49e90d6aed5ec3825dceafec18)), closes [#18518](https://github.com/vitejs/vite/issues/18518) +* chore: use premove instead of rimraf (#18499) ([f97a578](https://github.com/vitejs/vite/commit/f97a57893b3a7ddf11ca4c126b6be33cd2d9283b)), closes [#18499](https://github.com/vitejs/vite/issues/18499) +* feat!: proxy bypass with WebSocket (#18070) ([3c9836d](https://github.com/vitejs/vite/commit/3c9836d96f118ff5748916241bc3871a54247ad1)), closes [#18070](https://github.com/vitejs/vite/issues/18070) +* feat!: support `file://` resolution (#18422) ([6a7e313](https://github.com/vitejs/vite/commit/6a7e313754dce5faa5cd7c1e2343448cd7f3a2a2)), closes [#18422](https://github.com/vitejs/vite/issues/18422) +* feat!: update to chokidar v4 (#18453) ([192d555](https://github.com/vitejs/vite/commit/192d555f88bba7576e8a40cc027e8a11e006079c)), closes [#18453](https://github.com/vitejs/vite/issues/18453) +* feat(lib)!: use package name for css output file name (#18488) ([61cbf6f](https://github.com/vitejs/vite/commit/61cbf6f2cfcd5afc91fe0a0ad56abfc36a32f1ab)), closes [#18488](https://github.com/vitejs/vite/issues/18488) +* fix(css)!: remove default import in ssr dev (#17922) ([eccf663](https://github.com/vitejs/vite/commit/eccf663e35a17458425860895bb30b3b0613ea96)), closes [#17922](https://github.com/vitejs/vite/issues/17922) +* fix: `define` in environment config was not working (#18515) ([052799e](https://github.com/vitejs/vite/commit/052799e8939cfcdd7a7ff48daf45a766bf6cc546)), closes [#18515](https://github.com/vitejs/vite/issues/18515) +* fix: consider URLs with any protocol to be external (#17369) ([a0336bd](https://github.com/vitejs/vite/commit/a0336bd5197bb4427251be4c975e30fb596c658f)), closes [#17369](https://github.com/vitejs/vite/issues/17369) +* fix: use picomatch to align with tinyglobby (#18503) ([437795d](https://github.com/vitejs/vite/commit/437795db8307ce4491d066bcaaa5bd9432193773)), closes [#18503](https://github.com/vitejs/vite/issues/18503) +* fix(build): apply resolve.external/noExternal to server environments (#18495) ([5a967cb](https://github.com/vitejs/vite/commit/5a967cb596c7c4b0548be1d9025bc1e34b36169a)), closes [#18495](https://github.com/vitejs/vite/issues/18495) +* fix(config): remove error if require resolve to esm (#18437) ([f886f75](https://github.com/vitejs/vite/commit/f886f75396cdb5a43ec5377bbbaaffc0e8ae03e9)), closes [#18437](https://github.com/vitejs/vite/issues/18437) +* feat: log complete config in debug mode (#18289) ([04f6736](https://github.com/vitejs/vite/commit/04f6736fd7ac3da22141929c01a151f5a6fe4e45)), closes [#18289](https://github.com/vitejs/vite/issues/18289) +* feat(html): support `vite-ignore` attribute to opt-out of processing (#18494) ([d951310](https://github.com/vitejs/vite/commit/d9513104e21175e1d23e0f614df55cd53291ab4e)), closes [#18494](https://github.com/vitejs/vite/issues/18494) +* refactor: separate tsconfck caches per config in a weakmap (#17317) ([b9b01d5](https://github.com/vitejs/vite/commit/b9b01d57fdaf5d291c78a8156e17b534c8c51eb4)), closes [#17317](https://github.com/vitejs/vite/issues/17317) +* docs: add jsdocs to flags in BuilderOptions (#18516) ([1507068](https://github.com/vitejs/vite/commit/1507068b6d460cf54336fe7e8d3539fdb4564bfb)), closes [#18516](https://github.com/vitejs/vite/issues/18516) +* docs: missing changes guides (#18491) ([5da78a6](https://github.com/vitejs/vite/commit/5da78a6859f3b5c677d896144b915381e4497432)), closes [#18491](https://github.com/vitejs/vite/issues/18491) +* docs: update fs.deny default in JSDoc (#18514) ([1fcc83d](https://github.com/vitejs/vite/commit/1fcc83dd7ade429f889e4ce19d5c67b3e5b46419)), closes [#18514](https://github.com/vitejs/vite/issues/18514) +* build: reduce package size (#18517) ([b83f60b](https://github.com/vitejs/vite/commit/b83f60b159f3b6f4a61db180fa03cc5b20bd110f)), closes [#18517](https://github.com/vitejs/vite/issues/18517) + + + +## 6.0.0-beta.6 (2024-10-28) + +* fix: handle warmup glob hang (#18462) ([409fa5c](https://github.com/vitejs/vite/commit/409fa5c9dee0e394bcdc3b111f5b2e4261131ca0)), closes [#18462](https://github.com/vitejs/vite/issues/18462) +* fix: return the same instance of ModuleNode for the same EnvironmentModuleNode (#18455) ([5ead461](https://github.com/vitejs/vite/commit/5ead461b374d76ceb134063477eaf3f97fe3da97)), closes [#18455](https://github.com/vitejs/vite/issues/18455) +* fix: set scripts imported by HTML moduleSideEffects=true (#18411) ([2ebe4b4](https://github.com/vitejs/vite/commit/2ebe4b44430dd311028f72520ac977bb202ce50b)), closes [#18411](https://github.com/vitejs/vite/issues/18411) +* fix: use websocket to test server liveness before client reload (#17891) ([7f9f8c6](https://github.com/vitejs/vite/commit/7f9f8c6851d1eb49a72dcb6c134873148a2e81eb)), closes [#17891](https://github.com/vitejs/vite/issues/17891) +* fix(css): `cssCodeSplit` in `environments.xxx.build` is invalid (#18464) ([993e71c](https://github.com/vitejs/vite/commit/993e71c4cb227bd8c347b918f52ccd83f85a645a)), closes [#18464](https://github.com/vitejs/vite/issues/18464) +* fix(css): make sass types work with sass-embedded (#18459) ([89f8303](https://github.com/vitejs/vite/commit/89f8303e727791aa7be6f35833a708b6a50e9120)), closes [#18459](https://github.com/vitejs/vite/issues/18459) +* fix(deps): update all non-major dependencies (#18484) ([2ec12df](https://github.com/vitejs/vite/commit/2ec12df98d07eb4c986737e86a4a9f8066724658)), closes [#18484](https://github.com/vitejs/vite/issues/18484) +* fix(manifest): non entry CSS chunk src was wrong (#18133) ([c148676](https://github.com/vitejs/vite/commit/c148676c90dc4823bc6bdeb8ba1e36386c5d9654)), closes [#18133](https://github.com/vitejs/vite/issues/18133) +* fix(module-runner): delay function eval until module runner instantiation (#18480) ([472afbd](https://github.com/vitejs/vite/commit/472afbd010db3f1c7a59826c7bf4067191b7f48a)), closes [#18480](https://github.com/vitejs/vite/issues/18480) +* fix(plugins): noop if config hook returns same config reference (#18467) ([bd540d5](https://github.com/vitejs/vite/commit/bd540d52eb609ca12dad8e2f3fe8011821bda878)), closes [#18467](https://github.com/vitejs/vite/issues/18467) +* refactor: optimizeDeps back to top level (#18465) ([1ac22de](https://github.com/vitejs/vite/commit/1ac22de41cf5a8647847070eadeac3231c94c3ed)), closes [#18465](https://github.com/vitejs/vite/issues/18465) +* refactor: top-level createEnvironment is client-only (#18475) ([6022fc2](https://github.com/vitejs/vite/commit/6022fc2c87e0f59c3e6ccfa307a352a378d8273a)), closes [#18475](https://github.com/vitejs/vite/issues/18475) +* refactor(css): hide internal preprocessor types and expose types used for options (#18458) ([c32837c](https://github.com/vitejs/vite/commit/c32837cf868f0fdb97a22a0be8c95c433f4069c8)), closes [#18458](https://github.com/vitejs/vite/issues/18458) +* feat: allow custom `console` in `createLogger` (#18379) ([0c497d9](https://github.com/vitejs/vite/commit/0c497d9cb63bd4a6bb8e01c0e3b843890a239d23)), closes [#18379](https://github.com/vitejs/vite/issues/18379) +* feat: read `sec-fetch-dest` header to detect JS in transform (#9981) ([e51dc40](https://github.com/vitejs/vite/commit/e51dc40b5907cf14d7aefaaf01fb8865a852ef15)), closes [#9981](https://github.com/vitejs/vite/issues/9981) +* feat(css): add more stricter typing of lightningcss (#18460) ([b9b925e](https://github.com/vitejs/vite/commit/b9b925eb3f911ab63972124dc8ab0455449b925d)), closes [#18460](https://github.com/vitejs/vite/issues/18460) +* chore(deps)!: update postcss-load-config to v6 (#15235) ([3a27f62](https://github.com/vitejs/vite/commit/3a27f627df278f6c9778a55f44cb347665b65204)), closes [#15235](https://github.com/vitejs/vite/issues/15235) +* feat(css)!: change default sass api to modern/modern-compiler (#17937) ([d4e0442](https://github.com/vitejs/vite/commit/d4e0442f9d6adc70b72ea0713dc8abb4b1f75ae4)), closes [#17937](https://github.com/vitejs/vite/issues/17937) +* perf(css): skip style.css extraction if code-split css (#18470) ([34fdb6b](https://github.com/vitejs/vite/commit/34fdb6bef558724330d2411b9666facef669b3a0)), closes [#18470](https://github.com/vitejs/vite/issues/18470) + + + +## 6.0.0-beta.5 (2024-10-24) + +* fix: add typing to `CSSOptions.preprocessorOptions` (#18001) ([7eeb6f2](https://github.com/vitejs/vite/commit/7eeb6f2f97abf5dfc71c225b9cff9779baf2ed2f)), closes [#18001](https://github.com/vitejs/vite/issues/18001) +* fix(dev): prevent double URL encoding in server.open on macOS (#18443) ([56b7176](https://github.com/vitejs/vite/commit/56b71768f3ee498962fba898804086299382bb59)), closes [#18443](https://github.com/vitejs/vite/issues/18443) +* fix(preview): set resolvedUrls null after close (#18445) ([65014a3](https://github.com/vitejs/vite/commit/65014a32ef618619c5a34b729d67340d9253bdd5)), closes [#18445](https://github.com/vitejs/vite/issues/18445) +* fix(ssr): inject identity function at the top (#18449) ([0ab20a3](https://github.com/vitejs/vite/commit/0ab20a3ee26eacf302415b3087732497d0a2f358)), closes [#18449](https://github.com/vitejs/vite/issues/18449) +* fix(ssr): preserve source maps for hoisted imports (fix #16355) (#16356) ([8e382a6](https://github.com/vitejs/vite/commit/8e382a6a1fed2cd41051b81f9cd9c94b484352a5)), closes [#16355](https://github.com/vitejs/vite/issues/16355) [#16356](https://github.com/vitejs/vite/issues/16356) +* feat(css)!: load postcss config within workspace root only (#18440) ([d23a493](https://github.com/vitejs/vite/commit/d23a493cc4b54a2e2b2c1337b3b1f0c9b1be311e)), closes [#18440](https://github.com/vitejs/vite/issues/18440) +* feat(json)!: add `json.stringify: 'auto'` and make that the default (#18303) ([b80daa7](https://github.com/vitejs/vite/commit/b80daa7c0970645dca569d572892648f66c6799c)), closes [#18303](https://github.com/vitejs/vite/issues/18303) +* fix!: default `build.cssMinify` to `'esbuild'` for SSR (#15637) ([f1d3bf7](https://github.com/vitejs/vite/commit/f1d3bf74cc7f12e759442fd7111d07e2c0262a67)), closes [#15637](https://github.com/vitejs/vite/issues/15637) +* refactor: use `originalFileNames`/`names` (#18240) ([f2957c8](https://github.com/vitejs/vite/commit/f2957c84f69c14c882809889fbd0fc66b97ca3e9)), closes [#18240](https://github.com/vitejs/vite/issues/18240) +* test: fix test conflict (#18446) ([94cd1e6](https://github.com/vitejs/vite/commit/94cd1e6f95e2434d2b52b5c16d50fe0472214634)), closes [#18446](https://github.com/vitejs/vite/issues/18446) +* chore(deps): update dependency picomatch to v4 (#15876) ([3774881](https://github.com/vitejs/vite/commit/377488178a7ef372d9b76526bb01fd60b97f51df)), closes [#15876](https://github.com/vitejs/vite/issues/15876) + + + ## 6.0.0-beta.4 (2024-10-23) * refactor: use builder in `build` (#18432) ([cc61d16](https://github.com/vitejs/vite/commit/cc61d169a4826996f7b2289618c383f8c5c6d470)), closes [#18432](https://github.com/vitejs/vite/issues/18432) diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index cccba70e5d37d9..c9e9fd8f756949 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -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 @@ -418,29 +414,6 @@ Repositories: chalk/ansi-regex, sindresorhus/bundle-name, sindresorhus/default-b --------------------------------------- -## anymatch -License: ISC -By: Elan Shanker -Repository: https://github.com/micromatch/anymatch - -> The ISC License -> -> Copyright (c) 2019 Elan Shanker, Paul Miller (https://paulmillr.com) -> -> Permission to use, copy, modify, and/or distribute this software for any -> purpose with or without fee is hereby granted, provided that the above -> copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -> ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -> IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - ## artichokie License: MIT By: sapphi-red, Evan You @@ -471,91 +444,6 @@ Repository: git+https://github.com/sapphi-red/artichokie.git --------------------------------------- -## astring -License: MIT -By: David Bonnet -Repository: https://github.com/davidbonnet/astring.git - -> Copyright (c) 2015, David Bonnet -> -> 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. - ---------------------------------------- - -## binary-extensions, is-binary-path -License: MIT -By: Sindre Sorhus -Repositories: sindresorhus/binary-extensions, sindresorhus/is-binary-path - -> MIT License -> -> Copyright (c) 2019 Sindre Sorhus (https://sindresorhus.com), Paul Miller (https://paulmillr.com) -> -> 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. - ---------------------------------------- - -## braces, fill-range, is-number, micromatch -License: MIT -By: Jon Schlinkert, Brian Woodward, Elan Shanker, Eugene Sharygin, hemanth.hm -Repository: micromatch/braces - -License: MIT -By: Jon Schlinkert, Edo Rivai, Paul Miller, Rouven Weßling -Repository: jonschlinkert/fill-range - -License: MIT -By: Jon Schlinkert, Olsten Larck, Rouven Weßling -Repository: jonschlinkert/is-number - -License: MIT -By: Jon Schlinkert, Amila Welihinda, Bogdan Chadkin, Brian Woodward, Devon Govett, Elan Shanker, Fabrício Matté, Martin Kolárik, Olsten Larck, Paul Miller, Tom Byrer, Tyler Akins, Peter Bright, Kuba Juszczyk -Repository: micromatch/micromatch - -> The MIT License (MIT) -> -> Copyright (c) 2014-present, Jon Schlinkert. -> -> 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. - ---------------------------------------- - ## cac License: MIT By: egoist @@ -587,12 +475,12 @@ Repository: egoist/cac ## chokidar License: MIT -By: Paul Miller, Elan Shanker +By: Paul Miller Repository: git+https://github.com/paulmillr/chokidar.git > The MIT License (MIT) > -> Copyright (c) 2012-2019 Paul Miller (https://paulmillr.com), Elan Shanker +> Copyright (c) 2012 Paul Miller (https://paulmillr.com), Elan Shanker > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the “Software”), to deal @@ -614,38 +502,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 (mail@substack.net) -> -> 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 @@ -1186,29 +1042,6 @@ Repository: git+https://github.com/css-modules/generic-names.git --------------------------------------- -## glob-parent -License: ISC -By: Gulp Team, Elan Shanker, Blaine Bublitz -Repository: gulpjs/glob-parent - -> The ISC License -> -> Copyright (c) 2015, 2019 Elan Shanker -> -> Permission to use, copy, modify, and/or distribute this software for any -> purpose with or without fee is hereby granted, provided that the above -> copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -> ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -> IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - ## http-proxy License: MIT By: Charlie Robbins, jcrugzz @@ -1253,71 +1086,6 @@ Repository: git+https://github.com/css-modules/icss-utils.git --------------------------------------- -## is-extglob -License: MIT -By: Jon Schlinkert -Repository: jonschlinkert/is-extglob - -> The MIT License (MIT) -> -> Copyright (c) 2014-2016, Jon Schlinkert -> -> 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. - ---------------------------------------- - -## is-glob -License: MIT -By: Jon Schlinkert, Brian Woodward, Daniel Perez -Repository: micromatch/is-glob - -> The MIT License (MIT) -> -> Copyright (c) 2014-2017, Jon Schlinkert. -> -> 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. - ---------------------------------------- - -## 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 @@ -1611,39 +1379,10 @@ Repository: vercel/ms --------------------------------------- -## normalize-path -License: MIT -By: Jon Schlinkert, Blaine Bublitz -Repository: jonschlinkert/normalize-path - -> The MIT License (MIT) -> -> Copyright (c) 2014-2018, Jon Schlinkert. -> -> 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. - ---------------------------------------- - -## object-assign, pify +## object-assign License: MIT By: Sindre Sorhus -Repositories: sindresorhus/object-assign, sindresorhus/pify +Repository: sindresorhus/object-assign > The MIT License (MIT) > @@ -2056,34 +1795,6 @@ Repository: https://github.com/TrySound/postcss-value-parser.git --------------------------------------- -## read-cache -License: MIT -By: Bogdan Chadkin -Repository: git+https://github.com/TrySound/read-cache.git - -> The MIT License (MIT) -> -> Copyright 2016 Bogdan Chadkin -> -> 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. - ---------------------------------------- - ## readdirp License: MIT By: Thorsten Lorenz, Paul Miller @@ -2188,6 +1899,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 (mail@substack.net) +> +> 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 @@ -2290,35 +2033,6 @@ Repository: git+https://github.com/SuperchupuDev/tinyglobby.git --------------------------------------- -## to-regex-range -License: MIT -By: Jon Schlinkert, Rouven Weßling -Repository: micromatch/to-regex-range - -> The MIT License (MIT) -> -> Copyright (c) 2015-present, Jon Schlinkert. -> -> 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. - ---------------------------------------- - ## tsconfck License: MIT By: dominikg @@ -2518,24 +2232,3 @@ Repository: git+https://github.com/websockets/ws.git > 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. - ---------------------------------------- - -## yaml -License: ISC -By: Eemeli Aro -Repository: github:eemeli/yaml - -> Copyright Eemeli Aro -> -> Permission to use, copy, modify, and/or distribute this software for any purpose -> with or without fee is hereby granted, provided that the above copyright notice -> and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -> REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -> FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -> INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -> OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -> TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -> THIS SOFTWARE. diff --git a/packages/vite/client.d.ts b/packages/vite/client.d.ts index b2dd55965f384e..d9ef59cb9488d1 100644 --- a/packages/vite/client.d.ts +++ b/packages/vite/client.d.ts @@ -247,6 +247,16 @@ declare module '*?inline' { export default src } +declare module '*?no-inline' { + const src: string + export default src +} + +declare module '*?url&inline' { + const src: string + export default src +} + declare interface VitePreloadErrorEvent extends Event { payload: Error } diff --git a/packages/vite/package.json b/packages/vite/package.json index 672b89b7eee8f9..7a725d4723d052 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,10 +1,10 @@ { "name": "vite", - "version": "6.0.0-beta.4", + "version": "6.0.0-beta.8", "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" }, @@ -40,6 +40,7 @@ "./types/*": { "types": "./types/*" }, + "./types/internal/*": null, "./package.json": "./package.json" }, "typesVersions": { @@ -72,11 +73,11 @@ "funding": "https://github.com/vitejs/vite?sponsor=1", "scripts": { "dev": "tsx scripts/dev.ts", - "build": "rimraf dist && pnpm build-bundle && pnpm build-types", + "build": "premove dist && pnpm build-bundle && pnpm build-types", "build-bundle": "rollup --config rollup.config.ts --configPlugin esbuild", "build-types": "pnpm build-types-temp && pnpm build-types-roll && pnpm build-types-check", "build-types-temp": "tsc --emitDeclarationOnly --outDir temp -p src/node", - "build-types-roll": "rollup --config rollup.dts.config.ts --configPlugin esbuild && rimraf temp", + "build-types-roll": "rollup --config rollup.dts.config.ts --configPlugin esbuild && premove temp", "build-types-check": "tsc --project tsconfig.check.json", "typecheck": "tsc --noEmit && tsc --noEmit -p src/node", "lint": "eslint --cache --ext .ts src/**", @@ -87,27 +88,26 @@ "dependencies": { "esbuild": "^0.24.0", "postcss": "^8.4.47", - "rollup": "^4.22.5" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" + "react-refresh": "^0.14.2", + "rolldown": "0.13.2-snapshot-a292401-20241105072341", + "rollup": "^4.23.0" }, "devDependencies": { "@ampproject/remapping": "^2.3.0", - "@babel/parser": "^7.25.8", + "@babel/parser": "^7.26.2", "@jridgewell/trace-mapping": "^0.3.25", "@polka/compression": "^1.0.0-next.25", "@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-commonjs": "^28.0.1", - "@rollup/plugin-dynamic-import-vars": "^2.1.4", + "@rollup/plugin-dynamic-import-vars": "2.1.4", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "15.3.0", - "@rollup/pluginutils": "^5.1.2", + "@rollup/pluginutils": "^5.1.3", "@types/escape-html": "^1.0.4", "@types/pnpapi": "^0.0.5", "artichokie": "^0.2.1", "cac": "^6.7.14", - "chokidar": "^3.6.0", + "chokidar": "^4.0.1", "connect": "^3.7.0", "convert-source-map": "^2.0.0", "cors": "^2.8.5", @@ -122,52 +122,57 @@ "etag": "^1.8.1", "http-proxy": "^1.18.1", "launch-editor-middleware": "^2.9.1", - "lightningcss": "^1.27.0", + "lightningcss": "^1.28.1", "magic-string": "^0.30.12", - "micromatch": "^4.0.8", "mlly": "^1.7.2", "mrmime": "^2.0.0", - "nanoid": "^5.0.7", + "nanoid": "^5.0.8", "open": "^10.1.0", - "parse5": "^7.2.0", + "parse5": "^7.2.1", "pathe": "^1.1.2", "periscopic": "^4.0.2", "picocolors": "^1.1.1", "picomatch": "^4.0.2", "postcss-import": "^16.1.0", - "postcss-load-config": "^4.0.2", + "postcss-load-config": "^6.0.1", "postcss-modules": "^6.0.0", "resolve.exports": "^2.0.2", "rollup-plugin-dts": "^6.1.1", "rollup-plugin-esbuild": "^6.1.1", "rollup-plugin-license": "^3.5.3", - "sass": "^1.80.3", - "sass-embedded": "^1.80.3", + "sass": "^1.80.6", + "sass-embedded": "^1.80.6", "sirv": "^3.0.0", "source-map-support": "^0.5.21", "strip-ansi": "^7.1.0", "strip-literal": "^2.1.0", - "tinyglobby": "^0.2.9", + "tinyglobby": "^0.2.10", "tsconfck": "^3.1.4", - "tslib": "^2.8.0", + "tslib": "^2.8.1", "types": "link:./types", "ufo": "^1.5.4", "ws": "^8.18.0" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", + "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", - "terser": "^5.16.0" + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" }, "peerDependenciesMeta": { "@types/node": { "optional": true }, + "jiti": { + "optional": true + }, "sass": { "optional": true }, @@ -188,6 +193,12 @@ }, "terser": { "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true } } } diff --git a/packages/vite/rollup.config.ts b/packages/vite/rollup.config.ts index fd5c406e70644f..78dbdcc3cbc413 100644 --- a/packages/vite/rollup.config.ts +++ b/packages/vite/rollup.config.ts @@ -43,7 +43,18 @@ const clientConfig = defineConfig({ const sharedNodeOptions = defineConfig({ treeshake: { - moduleSideEffects: 'no-external', + moduleSideEffects(id, external) { + id = id.replaceAll('\\', '/') + // These nested dependencies should be considered side-effect free + // as it's not set within their package.json + if ( + id.includes('node_modules/astring') || + id.includes('node_modules/acorn') + ) { + return false + } + return !external + }, propertyReadSideEffects: false, tryCatchDeoptimization: false, }, @@ -96,9 +107,13 @@ const nodeConfig = defineConfig({ }, external: [ /^vite\//, - 'fsevents', 'lightningcss', 'rollup/parseAst', + // postcss-load-config + 'yaml', + 'jiti', + /^tsx(\/|$)/, + 'rolldown/experimental', ...Object.keys(pkg.dependencies), ], plugins: [ @@ -106,36 +121,49 @@ const nodeConfig = defineConfig({ // generate code that force require them upfront for side effects. // Shim them with eval() so rollup can skip these calls. shimDepsPlugin({ - // chokidar -> fsevents - 'fsevents-handler.js': { - src: `require('fsevents')`, - replacement: `__require('fsevents')`, - }, // postcss-import -> sugarss - 'process-content.js': { - src: 'require("sugarss")', - replacement: `__require('sugarss')`, - }, - 'lilconfig/src/index.js': { - pattern: /: require;/g, - replacement: `: __require;`, - }, - // postcss-load-config calls require after register ts-node - 'postcss-load-config/src/index.js': { - pattern: /require(?=\((configFile|'ts-node')\))/g, - replacement: `__require`, - }, + 'process-content.js': [ + { + src: 'require("sugarss")', + replacement: `__require('sugarss')`, + }, + ], + 'lilconfig/src/index.js': [ + { + pattern: /: require;/g, + replacement: ': __require;', + }, + ], + 'postcss-load-config/src/req.js': [ + { + src: "const { pathToFileURL } = require('node:url')", + replacement: `const { fileURLToPath, pathToFileURL } = require('node:url')`, + }, + { + src: '__filename', + replacement: 'fileURLToPath(import.meta.url)', + }, + ], // postcss-import uses the `resolve` dep if the `resolve` option is not passed. - // However, we always pass the `resolve` option. Remove this import to avoid - // bundling the `resolve` dep. - 'postcss-import/index.js': { - src: 'const resolveId = require("./lib/resolve-id")', - replacement: 'const resolveId = (id) => id', - }, - 'postcss-import/lib/parse-styles.js': { - src: 'const resolveId = require("./resolve-id")', - replacement: 'const resolveId = (id) => id', - }, + // However, we always pass the `resolve` option. It also uses `read-cache` if + // the `load` option is not passed, but we also always pass the `load` option. + // Remove these two imports to avoid bundling them. + 'postcss-import/index.js': [ + { + src: 'const resolveId = require("./lib/resolve-id")', + replacement: 'const resolveId = (id) => id', + }, + { + src: 'const loadContent = require("./lib/load-content")', + replacement: 'const loadContent = () => ""', + }, + ], + 'postcss-import/lib/parse-styles.js': [ + { + src: 'const resolveId = require("./resolve-id")', + replacement: 'const resolveId = (id) => id', + }, + ], }), ...createSharedNodePlugins({}), licensePlugin( @@ -153,7 +181,6 @@ const moduleRunnerConfig = defineConfig({ 'module-runner': path.resolve(__dirname, 'src/module-runner/index.ts'), }, external: [ - 'fsevents', 'lightningcss', 'rollup/parseAst', ...Object.keys(pkg.dependencies), @@ -179,7 +206,7 @@ const cjsConfig = defineConfig({ freeze: false, sourcemap: false, }, - external: ['fsevents', ...Object.keys(pkg.dependencies)], + external: Object.keys(pkg.dependencies), plugins: [...createSharedNodePlugins({}), bundleSizeLimit(175)], }) @@ -199,7 +226,7 @@ interface ShimOptions { pattern?: RegExp } -function shimDepsPlugin(deps: Record): Plugin { +function shimDepsPlugin(deps: Record): Plugin { const transformed: Record = {} return { @@ -207,38 +234,45 @@ function shimDepsPlugin(deps: Record): Plugin { transform(code, id) { for (const file in deps) { if (id.replace(/\\/g, '/').endsWith(file)) { - const { src, replacement, pattern } = deps[file] - - const magicString = new MagicString(code) - if (src) { - const pos = code.indexOf(src) - if (pos < 0) { - this.error( - `Could not find expected src "${src}" in file "${file}"`, - ) - } - transformed[file] = true - magicString.overwrite(pos, pos + src.length, replacement) - console.log(`shimmed: ${file}`) - } + for (const { src, replacement, pattern } of deps[file]) { + const magicString = new MagicString(code) - if (pattern) { - let match - while ((match = pattern.exec(code))) { + if (src) { + const pos = code.indexOf(src) + if (pos < 0) { + this.error( + `Could not find expected src "${src}" in file "${file}"`, + ) + } transformed[file] = true - const start = match.index - const end = start + match[0].length - magicString.overwrite(start, end, replacement) + magicString.overwrite(pos, pos + src.length, replacement) } - if (!transformed[file]) { - this.error( - `Could not find expected pattern "${pattern}" in file "${file}"`, - ) + + if (pattern) { + let match + while ((match = pattern.exec(code))) { + transformed[file] = true + const start = match.index + const end = start + match[0].length + let _replacement = replacement + for (let i = 1; i <= match.length; i++) { + _replacement = _replacement.replace(`$${i}`, match[i] || '') + } + magicString.overwrite(start, end, _replacement) + } + if (!transformed[file]) { + this.error( + `Could not find expected pattern "${pattern}" in file "${file}"`, + ) + } } - console.log(`shimmed: ${file}`) + + code = magicString.toString() } - return magicString.toString() + console.log(`shimmed: ${file}`) + + return code } } }, diff --git a/packages/vite/rollup.dts.config.ts b/packages/vite/rollup.dts.config.ts index 73379bffa70a41..2b74e8a6c5fd97 100644 --- a/packages/vite/rollup.dts.config.ts +++ b/packages/vite/rollup.dts.config.ts @@ -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'), @@ -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> = { - 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', diff --git a/packages/vite/scripts/dev.ts b/packages/vite/scripts/dev.ts index 546f17f404108f..4e9e9ac73b7092 100644 --- a/packages/vite/scripts/dev.ts +++ b/packages/vite/scripts/dev.ts @@ -24,7 +24,6 @@ const serverOptions: BuildOptions = { external: [ ...Object.keys(packageJSON.dependencies), ...Object.keys(packageJSON.peerDependencies), - ...Object.keys(packageJSON.optionalDependencies), ...Object.keys(packageJSON.devDependencies), ], } diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index 3563454f72761a..046110cafc09cc 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -91,9 +91,19 @@ function setupWebSocket( handleMessage(JSON.parse(data)) }) + let willUnload = false + window.addEventListener( + 'beforeunload', + () => { + willUnload = true + }, + { once: true }, + ) + // ping server - socket.addEventListener('close', async ({ wasClean }) => { - if (wasClean) return + socket.addEventListener('close', async () => { + // ignore close caused by top-level navigation + if (willUnload) return if (!isOpened && onCloseWithoutOpen) { onCloseWithoutOpen() @@ -331,24 +341,28 @@ async function waitForSuccessfulPing( hostAndPath: string, ms = 1000, ) { - const pingHostProtocol = socketProtocol === 'wss' ? 'https' : 'http' - - const ping = async () => { - // A fetch on a websocket URL will return a successful promise with status 400, - // but will reject a networking error. - // When running on middleware mode, it returns status 426, and a cors error happens if mode is not no-cors - try { - await fetch(`${pingHostProtocol}://${hostAndPath}`, { - mode: 'no-cors', - headers: { - // Custom headers won't be included in a request with no-cors so (ab)use one of the - // safelisted headers to identify the ping request - Accept: 'text/x-vite-ping', - }, - }) - return true - } catch {} - return false + async function ping() { + const socket = new WebSocket( + `${socketProtocol}://${hostAndPath}`, + 'vite-ping', + ) + return new Promise((resolve) => { + function onOpen() { + resolve(true) + close() + } + function onError() { + resolve(false) + close() + } + function close() { + socket.removeEventListener('open', onOpen) + socket.removeEventListener('error', onError) + socket.close() + } + socket.addEventListener('open', onOpen) + socket.addEventListener('error', onError) + }) } if (await ping()) { diff --git a/packages/vite/src/module-runner/esmEvaluator.ts b/packages/vite/src/module-runner/esmEvaluator.ts index 7266fc870612dd..f7f8c8ab52de80 100644 --- a/packages/vite/src/module-runner/esmEvaluator.ts +++ b/packages/vite/src/module-runner/esmEvaluator.ts @@ -1,6 +1,6 @@ import { AsyncFunction, - asyncFunctionDeclarationPaddingLineCount, + getAsyncFunctionDeclarationPaddingLineCount, } from '../shared/utils' import { ssrDynamicImportKey, @@ -12,7 +12,7 @@ import { import type { ModuleEvaluator, ModuleRunnerContext } from './types' export class ESModulesEvaluator implements ModuleEvaluator { - startOffset = asyncFunctionDeclarationPaddingLineCount + startOffset = getAsyncFunctionDeclarationPaddingLineCount() async runInlinedModule( context: ModuleRunnerContext, diff --git a/packages/vite/src/node/__tests__/assetSource.spec.ts b/packages/vite/src/node/__tests__/assetSource.spec.ts new file mode 100644 index 00000000000000..2c05d90e57b265 --- /dev/null +++ b/packages/vite/src/node/__tests__/assetSource.spec.ts @@ -0,0 +1,97 @@ +import { describe, expect, test } from 'vitest' +import { type DefaultTreeAdapterMap, parseFragment } from 'parse5' +import { getNodeAssetAttributes } from '../assetSource' + +describe('getNodeAssetAttributes', () => { + const getNode = (html: string) => { + const ast = parseFragment(html, { sourceCodeLocationInfo: true }) + return ast.childNodes[0] as DefaultTreeAdapterMap['element'] + } + + test('handles img src', () => { + const node = getNode('') + const attrs = getNodeAssetAttributes(node) + expect(attrs).toHaveLength(1) + expect(attrs[0]).toHaveProperty('type', 'src') + expect(attrs[0]).toHaveProperty('key', 'src') + expect(attrs[0]).toHaveProperty('value', 'foo.jpg') + expect(attrs[0].attributes).toEqual({ src: 'foo.jpg' }) + expect(attrs[0].location).toHaveProperty('startOffset', 5) + expect(attrs[0].location).toHaveProperty('endOffset', 18) + }) + + test('handles source srcset', () => { + const node = getNode('') + const attrs = getNodeAssetAttributes(node) + expect(attrs).toHaveLength(1) + expect(attrs[0]).toHaveProperty('type', 'srcset') + expect(attrs[0]).toHaveProperty('key', 'srcset') + expect(attrs[0]).toHaveProperty('value', 'foo.jpg 1x, bar.jpg 2x') + expect(attrs[0].attributes).toEqual({ srcset: 'foo.jpg 1x, bar.jpg 2x' }) + }) + + test('handles video src and poster', () => { + const node = getNode('