diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 59a3579c80fc2e..bfdcd3d4f71cb8 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -8,13 +8,13 @@ module.exports = defineConfig({ 'eslint:recommended', 'plugin:node/recommended', 'plugin:@typescript-eslint/recommended', - 'plugin:regexp/recommended' + 'plugin:regexp/recommended', ], plugins: ['import', 'regexp'], parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module', - ecmaVersion: 2021 + ecmaVersion: 2021, }, rules: { eqeqeq: ['warn', 'always', { null: 'never' }], @@ -25,36 +25,36 @@ module.exports = defineConfig({ 'prefer-const': [ 'warn', { - destructuring: 'all' - } + destructuring: 'all', + }, ], 'node/no-missing-import': [ 'error', { allowModules: ['types', 'estree', 'less', 'sass', 'stylus'], - tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'] - } + tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], + }, ], 'node/no-missing-require': [ 'error', { // for try-catching yarn pnp allowModules: ['pnpapi', 'vite'], - tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'] - } + tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], + }, ], 'node/no-extraneous-import': [ 'error', { - allowModules: ['vite', 'less', 'sass', 'vitest'] - } + allowModules: ['vite', 'less', 'sass', 'vitest'], + }, ], 'node/no-extraneous-require': [ 'error', { - allowModules: ['vite'] - } + allowModules: ['vite'], + }, ], 'node/no-deprecated-api': 'off', 'node/no-unpublished-import': 'off', @@ -65,11 +65,11 @@ module.exports = defineConfig({ '@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR '@typescript-eslint/explicit-module-boundary-types': [ 'error', - { allowArgumentsExplicitlyTypedAsAny: true } + { allowArgumentsExplicitlyTypedAsAny: true }, ], '@typescript-eslint/no-empty-function': [ 'error', - { allow: ['arrowFunctions'] } + { allow: ['arrowFunctions'] }, ], '@typescript-eslint/no-empty-interface': 'off', '@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR @@ -80,12 +80,12 @@ module.exports = defineConfig({ '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/consistent-type-imports': [ 'error', - { prefer: 'type-imports' } + { prefer: 'type-imports' }, ], 'import/no-nodejs-modules': [ 'error', - { allow: builtinModules.map((mod) => `node:${mod}`) } + { allow: builtinModules.map((mod) => `node:${mod}`) }, ], 'import/no-duplicates': 'error', 'import/order': 'error', @@ -96,19 +96,24 @@ module.exports = defineConfig({ ignoreDeclarationSort: true, ignoreMemberSort: false, memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], - allowSeparatedGroups: false - } + allowSeparatedGroups: false, + }, ], - 'regexp/no-contradiction-with-assertion': 'error' + 'regexp/no-contradiction-with-assertion': 'error', }, overrides: [ { files: ['packages/**'], excludedFiles: '**/__tests__/**', rules: { - 'no-restricted-globals': ['error', 'require', '__dirname', '__filename'] - } + 'no-restricted-globals': [ + 'error', + 'require', + '__dirname', + '__filename', + ], + }, }, { files: 'packages/vite/**/*.*', @@ -116,36 +121,36 @@ module.exports = defineConfig({ 'node/no-restricted-require': [ 'error', Object.keys( - require('./packages/vite/package.json').devDependencies + require('./packages/vite/package.json').devDependencies, ).map((d) => ({ name: d, message: `devDependencies can only be imported using ESM syntax so ` + `that they are included in the rollup bundle. If you are trying to ` + - `lazy load a dependency, use (await import('dependency')).default instead.` - })) - ] - } + `lazy load a dependency, use (await import('dependency')).default instead.`, + })), + ], + }, }, { files: ['packages/vite/src/node/**'], rules: { - 'no-console': ['error'] - } + 'no-console': ['error'], + }, }, { files: ['packages/vite/src/types/**', '*.spec.ts'], rules: { - 'node/no-extraneous-import': 'off' - } + 'node/no-extraneous-import': 'off', + }, }, { files: ['packages/create-vite/template-*/**', '**/build.config.ts'], rules: { 'no-undef': 'off', 'node/no-missing-import': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off' - } + '@typescript-eslint/explicit-module-boundary-types': 'off', + }, }, { files: ['playground/**'], @@ -158,17 +163,17 @@ module.exports = defineConfig({ 'node/no-unsupported-features/es-builtins': [ 'error', { - version: '^14.18.0 || >=16.0.0' - } + version: '^14.18.0 || >=16.0.0', + }, ], 'node/no-unsupported-features/node-builtins': [ 'error', { - version: '^14.18.0 || >=16.0.0' - } + version: '^14.18.0 || >=16.0.0', + }, ], - '@typescript-eslint/explicit-module-boundary-types': 'off' - } + '@typescript-eslint/explicit-module-boundary-types': 'off', + }, }, { files: ['playground/**'], @@ -177,21 +182,21 @@ module.exports = defineConfig({ 'no-undef': 'off', 'no-empty': 'off', 'no-constant-condition': 'off', - '@typescript-eslint/no-empty-function': 'off' - } + '@typescript-eslint/no-empty-function': 'off', + }, }, { files: ['*.js', '*.mjs', '*.cjs'], rules: { - '@typescript-eslint/explicit-module-boundary-types': 'off' - } + '@typescript-eslint/explicit-module-boundary-types': 'off', + }, }, { files: ['*.d.ts'], rules: { - '@typescript-eslint/triple-slash-reference': 'off' - } - } + '@typescript-eslint/triple-slash-reference': 'off', + }, + }, ], - reportUnusedDisableDirectives: true + reportUnusedDisableDirectives: true, }) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000000000..a4c31afed65932 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,4 @@ +# chore: enable prettier trailing commas (#11167) +134ce6817984bad0f5fb043481502531fee9b1db +# chore: rename test packages (#11172) +5170e44920458090b8b43ee9cfe5010c25dfe22b diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index c504c325f08040..f85f41ebbd3809 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,11 @@ blank_issues_enabled: false contact_links: + - name: Vite Plugin React Issues + url: https://github.com/vitejs/vite-plugin-react/issues/new/choose + about: React related issues should be reported on the vite-plugin-react repository. + - name: Vite Plugin Vue Issues + url: https://github.com/vitejs/vite-plugin-vue/issues/new/choose + about: Vue related issues should be reported on the vite-plugin-vue repository. - name: Discord Chat url: https://chat.vitejs.dev about: Ask questions and discuss with other Vite users in real time. diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 0014c768519180..ce03a1811793e8 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -8,8 +8,8 @@ "packageRules": [ { "depTypeList": ["peerDependencies"], - "enabled": false - } + "enabled": false, + }, ], "ignoreDeps": [ // manually bumping @@ -22,6 +22,6 @@ "source-map", // `source-map:v0.7.0+` needs more investigation "dotenv-expand", // `dotenv-expand:6.0.0+` has breaking changes (#6858) "kill-port", // `kill-port:^2.0.0 has perf issues (#8392) - "miniflare" // `miniflare:v2.0.0+` only supports node 16.7 - ] + "miniflare", // `miniflare:v2.0.0+` only supports node 16.7 + ], } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22a7fd5a4979cd..0628dc82dc23e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,9 +39,9 @@ jobs: include: # Active LTS + other OS - os: macos-latest - node_version: 16 + node_version: 18 - os: windows-latest - node_version: 16 + node_version: 18 fail-fast: false name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}" @@ -62,20 +62,26 @@ jobs: run: pnpm install # Install playwright's binary under custom directory to cache - - name: Set Playwright path (non-windows) + - name: (non-windows) Set Playwright path and Get playwright version if: runner.os != 'Windows' - run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV - - name: Set Playwright path (windows) + run: | + echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV + PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies["playwright-chromium"].version')" + echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV + - name: (windows) Set Playwright path and Get playwright version if: runner.os == 'Windows' - run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV + run: | + echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV + $env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright-chromium | jq --raw-output '.[0].devDependencies[\"playwright-chromium\"].version')" + echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV - name: Cache Playwright's binary uses: actions/cache@v3 with: - # Playwright removes unused browsers automatically - # So does not need to add playwright version to key - key: ${{ runner.os }}-playwright-bin-v1 + key: ${{ runner.os }}-playwright-bin-v1-${{ env.PLAYWRIGHT_VERSION }} path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }} + restore-keys: | + ${{ runner.os }}-playwright-bin-v1- - name: Install Playwright # does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved diff --git a/.github/workflows/ecosystem-ci-trigger.yml b/.github/workflows/ecosystem-ci-trigger.yml index 517fc1542e5129..f220329028bdee 100644 --- a/.github/workflows/ecosystem-ci-trigger.yml +++ b/.github/workflows/ecosystem-ci-trigger.yml @@ -26,7 +26,8 @@ jobs: 'poyoho', 'sapphi-red', 'ygj6', - 'Niputi' + 'Niputi', + 'dominikg' ]) if (allowedUsers.has(user)) { diff --git a/.prettierrc.json b/.prettierrc.json index 3a87ddf358fad4..568ce1a24732d8 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,7 +3,7 @@ "tabWidth": 2, "singleQuote": true, "printWidth": 80, - "trailingComma": "none", + "trailingComma": "all", "overrides": [ { "files": ["*.json5"], diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3065a63be5fc7a..bfc8dbd19f8c33 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,6 +18,15 @@ You can alternatively use [Vite.js Docker Dev](https://github.com/nystudio107/vi > Vite uses pnpm v7. If you are working on multiple projects with different versions of pnpm, it's recommended to enable [Corepack](https://github.com/nodejs/corepack) by running `corepack enable`. +### Ignoring commits when running `git blame` + +We have a `.git-blame-ignore-revs` file to ignore formatting changes. +To make this file used by `git blame`, you need to run the following command. + +```sh +git config --local blame.ignoreRevsFile .git-blame-ignore-revs +``` + ## Debugging To use breakpoints and explore code execution, you can use the ["Run and Debug"](https://code.visualstudio.com/docs/editor/debugging) feature from VS Code. @@ -147,6 +156,8 @@ test('?raw import', async () => { In many test cases, we need to mock dependencies using `link:` and `file:` protocols. `pnpm` treats `link:` as symlinks and `file:` as hardlinks. To test dependencies as if they were copied into `node_modules`, use the `file:` protocol. Otherwise, use the `link:` protocol. +For a mock dependency, make sure you add a `@vitejs/test-` prefix to the package name. This will avoid possible issues like false-positive alerts. + ## Debug Logging You can set the `DEBUG` environment variable to turn on debugging logs (e.g. `DEBUG="vite:resolve"`). To see all debug logs, you can set `DEBUG="vite:*"`, but be warned that it will be quite noisy. You can run `grep -r "createDebugger('vite:" packages/vite/src/` to see a list of available debug scopes. @@ -220,7 +231,7 @@ Vite aims to be fully usable as a dependency in a TypeScript project (e.g. it sh To get around this, we inline some of these dependencies' types in `packages/vite/src/types`. This way, we can still expose the typing but bundle the dependency's source code. -Use `pnpm run check-dist-types` to check that the bundled types do not rely on types in `devDependencies`. If you are adding `dependencies`, make sure to configure `tsconfig.check.json`. +Use `pnpm run build-types-check` to check that the bundled types do not rely on types in `devDependencies`. For types shared between client and node, they should be added into `packages/vite/types`. These types are not bundled and are published as is (though they are still considered internal). Dependency types within this directory (e.g. `packages/vite/types/chokidar.d.ts`) are deprecated and should be added to `packages/vite/src/types` instead. diff --git a/README.md b/README.md index 6fc1f49a80ee0f..db901f4af44917 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,11 @@ In addition, Vite is highly extensible via its [Plugin API](https://vitejs.dev/g ## Packages -| Package | Version (click for changelogs) | -| ------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- | -| [vite](packages/vite) | [![vite version](https://img.shields.io/npm/v/vite.svg?label=%20)](packages/vite/CHANGELOG.md) | -| [@vitejs/plugin-vue](packages/plugin-vue) | [![plugin-vue version](https://img.shields.io/npm/v/@vitejs/plugin-vue.svg?label=%20)](packages/plugin-vue/CHANGELOG.md) | -| [@vitejs/plugin-vue-jsx](packages/plugin-vue-jsx) | [![plugin-vue-jsx version](https://img.shields.io/npm/v/@vitejs/plugin-vue-jsx.svg?label=%20)](packages/plugin-vue-jsx/CHANGELOG.md) | -| [@vitejs/plugin-react](packages/plugin-react) | [![plugin-react version](https://img.shields.io/npm/v/@vitejs/plugin-react.svg?label=%20)](packages/plugin-react/CHANGELOG.md) | -| [@vitejs/plugin-legacy](packages/plugin-legacy) | [![plugin-legacy version](https://img.shields.io/npm/v/@vitejs/plugin-legacy.svg?label=%20)](packages/plugin-legacy/CHANGELOG.md) | -| [create-vite](packages/create-vite) | [![create-vite version](https://img.shields.io/npm/v/create-vite.svg?label=%20)](packages/create-vite/CHANGELOG.md) | +| Package | Version (click for changelogs) | +| ----------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- | +| [vite](packages/vite) | [![vite version](https://img.shields.io/npm/v/vite.svg?label=%20)](packages/vite/CHANGELOG.md) | +| [@vitejs/plugin-legacy](packages/plugin-legacy) | [![plugin-legacy version](https://img.shields.io/npm/v/@vitejs/plugin-legacy.svg?label=%20)](packages/plugin-legacy/CHANGELOG.md) | +| [create-vite](packages/create-vite) | [![create-vite version](https://img.shields.io/npm/v/create-vite.svg?label=%20)](packages/create-vite/CHANGELOG.md) | ## Contribution diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 678ca2790841d1..8fc6321f12212e 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -35,20 +35,28 @@ const versionLinks = ((): DefaultTheme.NavItemWithLink[] => { case 'local': return [ { - text: 'Vite 3 Docs (release)', - link: 'https://vitejs.dev' + text: 'Vite 4 Docs (release)', + link: 'https://vitejs.dev', + }, + { + text: 'Vite 3 Docs', + link: 'https://v3.vitejs.dev', }, { text: 'Vite 2 Docs', - link: 'https://v2.vitejs.dev' - } + link: 'https://v2.vitejs.dev', + }, ] case 'release': return [ + { + text: 'Vite 3 Docs', + link: 'https://v3.vitejs.dev', + }, { text: 'Vite 2 Docs', - link: 'https://v2.vitejs.dev' - } + link: 'https://v2.vitejs.dev', + }, ] } })() @@ -73,13 +81,13 @@ export default defineConfig({ src: 'https://cdn.usefathom.com/script.js', 'data-site': 'CBDFBSLI', 'data-spa': 'auto', - defer: '' - } - ] + defer: '', + }, + ], ], vue: { - reactivityTransform: true + reactivityTransform: true, }, themeConfig: { @@ -87,13 +95,13 @@ export default defineConfig({ editLink: { pattern: 'https://github.com/vitejs/vite/edit/main/docs/:path', - text: 'Suggest changes to this page' + text: 'Suggest changes to this page', }, socialLinks: [ { icon: 'twitter', link: 'https://twitter.com/vite_js' }, { icon: 'discord', link: 'https://chat.vitejs.dev' }, - { icon: 'github', link: 'https://github.com/vitejs/vite' } + { icon: 'github', link: 'https://github.com/vitejs/vite' }, ], algolia: { @@ -101,13 +109,13 @@ export default defineConfig({ apiKey: 'deaab78bcdfe96b599497d25acc6460e', indexName: 'vitejs', searchParameters: { - facetFilters: ['tags:en'] - } + facetFilters: ['tags:en'], + }, }, carbonAds: { code: 'CEBIEK3N', - placement: 'vitejsdev' + placement: 'vitejsdev', }, localeLinks: { @@ -115,13 +123,13 @@ export default defineConfig({ items: [ { text: '简体中文', link: 'https://cn.vitejs.dev' }, { text: '日本語', link: 'https://ja.vitejs.dev' }, - { text: 'Español', link: 'https://es.vitejs.dev' } - ] + { text: 'Español', link: 'https://es.vitejs.dev' }, + ], }, footer: { message: `Released under the MIT License. (${commitRef})`, - copyright: 'Copyright © 2019-present Evan You & Vite Contributors' + copyright: 'Copyright © 2019-present Evan You & Vite Contributors', }, nav: [ @@ -136,36 +144,36 @@ export default defineConfig({ items: [ { text: 'Twitter', - link: 'https://twitter.com/vite_js' + link: 'https://twitter.com/vite_js', }, { text: 'Discord Chat', - link: 'https://chat.vitejs.dev' + link: 'https://chat.vitejs.dev', }, { text: 'Awesome Vite', - link: 'https://github.com/vitejs/awesome-vite' + link: 'https://github.com/vitejs/awesome-vite', }, { text: 'DEV Community', - link: 'https://dev.to/t/vite' + link: 'https://dev.to/t/vite', }, { text: 'Rollup Plugins Compat', - link: 'https://vite-rollup-plugins.patak.dev/' + link: 'https://vite-rollup-plugins.patak.dev/', }, { text: 'Changelog', - link: 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md' - } - ] - } - ] + link: 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md', + }, + ], + }, + ], }, { text: 'Version', - items: versionLinks - } + items: versionLinks, + }, ], sidebar: { @@ -175,83 +183,87 @@ export default defineConfig({ items: [ { text: 'Why Vite', - link: '/guide/why' + link: '/guide/why', }, { text: 'Getting Started', - link: '/guide/' + link: '/guide/', }, { text: 'Features', - link: '/guide/features' + link: '/guide/features', + }, + { + text: 'CLI', + link: '/guide/cli', }, { text: 'Using Plugins', - link: '/guide/using-plugins' + link: '/guide/using-plugins', }, { text: 'Dependency Pre-Bundling', - link: '/guide/dep-pre-bundling' + link: '/guide/dep-pre-bundling', }, { text: 'Static Asset Handling', - link: '/guide/assets' + link: '/guide/assets', }, { text: 'Building for Production', - link: '/guide/build' + link: '/guide/build', }, { text: 'Deploying a Static Site', - link: '/guide/static-deploy' + link: '/guide/static-deploy', }, { text: 'Env Variables and Modes', - link: '/guide/env-and-mode' + link: '/guide/env-and-mode', }, { text: 'Server-Side Rendering (SSR)', - link: '/guide/ssr' + link: '/guide/ssr', }, { text: 'Backend Integration', - link: '/guide/backend-integration' + link: '/guide/backend-integration', }, { text: 'Comparisons', - link: '/guide/comparisons' + link: '/guide/comparisons', }, { text: 'Troubleshooting', - link: '/guide/troubleshooting' + link: '/guide/troubleshooting', }, { text: 'Migration from v2', - link: '/guide/migration' - } - ] + link: '/guide/migration', + }, + ], }, { text: 'APIs', items: [ { text: 'Plugin API', - link: '/guide/api-plugin' + link: '/guide/api-plugin', }, { text: 'HMR API', - link: '/guide/api-hmr' + link: '/guide/api-hmr', }, { text: 'JavaScript API', - link: '/guide/api-javascript' + link: '/guide/api-javascript', }, { text: 'Config Reference', - link: '/config/' - } - ] - } + link: '/config/', + }, + ], + }, ], '/config/': [ { @@ -259,39 +271,39 @@ export default defineConfig({ items: [ { text: 'Configuring Vite', - link: '/config/' + link: '/config/', }, { text: 'Shared Options', - link: '/config/shared-options' + link: '/config/shared-options', }, { text: 'Server Options', - link: '/config/server-options' + link: '/config/server-options', }, { text: 'Build Options', - link: '/config/build-options' + link: '/config/build-options', }, { text: 'Preview Options', - link: '/config/preview-options' + link: '/config/preview-options', }, { text: 'Dep Optimization Options', - link: '/config/dep-optimization-options' + link: '/config/dep-optimization-options', }, { text: 'SSR Options', - link: '/config/ssr-options' + link: '/config/ssr-options', }, { text: 'Worker Options', - link: '/config/worker-options' - } - ] - } - ] - } - } + link: '/config/worker-options', + }, + ], + }, + ], + }, + }, }) diff --git a/docs/.vitepress/theme/components/AsideSponsors.vue b/docs/.vitepress/theme/components/AsideSponsors.vue index 789f1e0e8addbf..90e6addab959a5 100644 --- a/docs/.vitepress/theme/components/AsideSponsors.vue +++ b/docs/.vitepress/theme/components/AsideSponsors.vue @@ -10,7 +10,7 @@ const sponsors = computed(() => { data?.value.map((sponsor) => { return { size: sponsor.size === 'big' ? 'mini' : 'xmini', - items: sponsor.items + items: sponsor.items, } }) ?? [] ) @@ -18,71 +18,5 @@ const sponsors = computed(() => { - - diff --git a/docs/.vitepress/theme/composables/sponsor.ts b/docs/.vitepress/theme/composables/sponsor.ts index b6a98ce18622bb..976dbcfb75103e 100644 --- a/docs/.vitepress/theme/composables/sponsor.ts +++ b/docs/.vitepress/theme/composables/sponsor.ts @@ -34,7 +34,7 @@ export function useSponsor() { }) return { - data + data, } } @@ -43,19 +43,19 @@ function mapSponsors(sponsors: Sponsors) { { tier: 'Platinum Sponsor', size: 'big', - items: mapImgPath(sponsors['platinum']) + items: mapImgPath(sponsors['platinum']), }, { tier: 'Gold Sponsors', size: 'medium', - items: mapImgPath(sponsors['gold']) - } + items: mapImgPath(sponsors['gold']), + }, ] } function mapImgPath(sponsors: Sponsor[]) { return sponsors.map((sponsor) => ({ ...sponsor, - img: `${dataHost}/images/${sponsor.img}` + img: `${dataHost}/images/${sponsor.img}`, })) } diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 39f1f2ffcae120..bef729b777e7c3 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -10,10 +10,10 @@ export default { Layout() { return h(Theme.Layout, null, { 'home-features-after': () => h(HomeSponsors), - 'aside-ads-before': () => h(AsideSponsors) + 'aside-ads-before': () => h(AsideSponsors), }) }, enhanceApp({ app }) { app.component('SvgImage', SvgImage) - } + }, } diff --git a/docs/_data/team.js b/docs/_data/team.js index fd386685af6bc1..a9f400378e90c3 100644 --- a/docs/_data/team.js +++ b/docs/_data/team.js @@ -8,9 +8,9 @@ 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: 'twitter', link: 'https://twitter.com/youyuxi' }, ], - sponsor: 'https://github.com/sponsors/yyx990803' + sponsor: 'https://github.com/sponsors/yyx990803', }, { avatar: 'https://www.github.com/patak-dev.png', @@ -21,9 +21,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: 'twitter', link: 'https://twitter.com/patak_dev' }, ], - sponsor: 'https://github.com/sponsors/patak-dev' + sponsor: 'https://github.com/sponsors/patak-dev', }, { avatar: 'https://www.github.com/antfu.png', @@ -34,9 +34,31 @@ 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: 'twitter', link: 'https://twitter.com/antfu7' }, ], - sponsor: 'https://github.com/sponsors/antfu' + sponsor: 'https://github.com/sponsors/antfu', + }, + { + avatar: 'https://github.com/bluwy.png', + name: 'Bjorn Lu', + title: 'Frontend Developer', + desc: 'Svelte and Vite team member. Something something opinions.', + links: [ + { icon: 'github', link: 'https://github.com/bluwy' }, + { icon: 'twitter', link: 'https://twitter.com/bluwyoo' }, + ], + sponsor: 'https://bjornlu.com/sponsor', + }, + { + avatar: 'https://github.com/sapphi-red.png', + name: 'green', + title: 'Web Developer', + desc: 'Vite 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' }, + ], + sponsor: 'https://github.com/sponsors/sapphi-red', }, { avatar: 'https://github.com/sodatea.png', @@ -47,9 +69,9 @@ export const core = [ desc: 'Vite/Vite core team member. Full-time open sourcerer.', links: [ { icon: 'github', link: 'https://github.com/sodatea' }, - { icon: 'twitter', link: 'https://twitter.com/haoqunjiang' } + { icon: 'twitter', link: 'https://twitter.com/haoqunjiang' }, ], - sponsor: 'https://github.com/sponsors/sodatea' + sponsor: 'https://github.com/sponsors/sodatea', }, { avatar: 'https://github.com/Shinigami92.png', @@ -60,9 +82,9 @@ export const core = [ desc: 'Passionate TypeScript enthusiast working extensively with Vue SPA and pug.', links: [ { icon: 'github', link: 'https://github.com/Shinigami92' }, - { icon: 'twitter', link: 'https://twitter.com/Shini_92' } + { icon: 'twitter', link: 'https://twitter.com/Shini_92' }, ], - sponsor: 'https://github.com/sponsors/Shinigami92' + sponsor: 'https://github.com/sponsors/Shinigami92', }, { avatar: 'https://i.imgur.com/KMed6rQ.jpeg', @@ -71,20 +93,9 @@ export const core = [ 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' } - ], - sponsor: 'https://github.com/sponsors/aleclarson' - }, - { - avatar: 'https://github.com/bluwy.png', - name: 'Bjorn Lu', - title: 'Frontend Developer', - desc: 'Svelte and Vite team member. Something something opinions.', - links: [ - { icon: 'github', link: 'https://github.com/bluwy' }, - { icon: 'twitter', link: 'https://twitter.com/bluwyoo' } + { icon: 'twitter', link: 'https://twitter.com/retropragma' }, ], - sponsor: 'https://bjornlu.com/sponsor' + sponsor: 'https://github.com/sponsors/aleclarson', }, { avatar: 'https://github.com/poyoho.png', @@ -93,20 +104,19 @@ export const core = [ desc: 'Frontend. Vite team member.', links: [ { icon: 'github', link: 'https://github.com/poyoho' }, - { icon: 'twitter', link: 'https://twitter.com/yoho_po' } - ] + { icon: 'twitter', link: 'https://twitter.com/yoho_po' }, + ], }, { - avatar: 'https://github.com/sapphi-red.png', - name: 'green', - title: 'Web Developer', - desc: 'Vite 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' } - ], - sponsor: 'https://github.com/sponsors/sapphi-red' + avatar: 'https://github.com/ArnaudBarre.png', + name: 'Arnaud Barré', + title: 'Frontend Developer', + desc: 'Passionate by tooling around TypeScript and React.', + links: [{ icon: 'github', link: 'https://github.com/ArnaudBarre' }], }, +] + +export const emeriti = [ { avatar: 'https://github.com/ygj6.png', name: 'ygj6', @@ -114,8 +124,8 @@ export const core = [ desc: 'Web Developer. Vue & Vite team member', links: [ { icon: 'github', link: 'https://github.com/ygj6' }, - { icon: 'twitter', link: 'https://twitter.com/ygj_66' } - ] + { icon: 'twitter', link: 'https://twitter.com/ygj_66' }, + ], }, { avatar: 'https://github.com/Niputi.png', @@ -125,28 +135,25 @@ export const core = [ desc: 'weeb/javascript lover.', links: [ { icon: 'github', link: 'https://github.com/Niputi' }, - { icon: 'twitter', link: 'https://twitter.com/Niputi_' } - ] - } -] - -export const emeriti = [ + { icon: 'twitter', link: 'https://twitter.com/Niputi_' }, + ], + }, { avatar: 'https://github.com/underfin.png', name: 'underfin', title: 'Developer', - links: [{ icon: 'github', link: 'https://github.com/underfin' }] + links: [{ icon: 'github', link: 'https://github.com/underfin' }], }, { 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' }], }, { avatar: 'https://github.com/nihalgonsalves.png', name: 'Nihal Gonsalves', title: 'Senior Software Engineer', - links: [{ icon: 'github', link: 'https://github.com/nihalgonsalves' }] - } + links: [{ icon: 'github', link: 'https://github.com/nihalgonsalves' }], + }, ] diff --git a/docs/blog/announcing-vite3.md b/docs/blog/announcing-vite3.md index 7f727f7307d767..1baf096d9ab6ac 100644 --- a/docs/blog/announcing-vite3.md +++ b/docs/blog/announcing-vite3.md @@ -239,7 +239,7 @@ While working towards Vite 3, we also improved the contributing experience for c - Vite upgraded to [pnpm 7](https://pnpm.io/), following the rest of the ecosystem. - Playgrounds have been moved to [`/playgrounds`](https://github.com/vitejs/vite/tree/main/playground) out of packages directory. - The packages and playgrounds are now `"type": "module"`. -- Plugins are now bundled using [unbuild](https://github.com/unjs/unbuild), and [plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) and [plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) were moved to TypeScript. +- Plugins are now bundled using [unbuild](https://github.com/unjs/unbuild), and [plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) and [plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) were moved to TypeScript. ## The Ecosystem is Ready for v3 diff --git a/docs/config/build-options.md b/docs/config/build-options.md index 2c60c838fa54ee..ce80c6cf1aaf94 100644 --- a/docs/config/build-options.md +++ b/docs/config/build-options.md @@ -42,7 +42,7 @@ type ResolveModulePreloadDependenciesFn = ( deps: string[], context: { importer: string - } + }, ) => (string | { runtime?: string })[] ``` diff --git a/docs/config/dep-optimization-options.md b/docs/config/dep-optimization-options.md index 729b6df7cac3f9..d4b74f26ec327e 100644 --- a/docs/config/dep-optimization-options.md +++ b/docs/config/dep-optimization-options.md @@ -22,8 +22,8 @@ CommonJS dependencies should not be excluded from optimization. If an ESM depend ```js export default defineConfig({ optimizeDeps: { - include: ['esm-dep > cjs-dep'] - } + include: ['esm-dep > cjs-dep'], + }, }) ``` diff --git a/docs/config/index.md b/docs/config/index.md index 965d5bdf60133b..56fbd4be10d853 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -98,8 +98,8 @@ export default defineConfig(({ command, mode }) => { return { // vite config define: { - __APP_ENV__: env.APP_ENV - } + __APP_ENV__: env.APP_ENV, + }, } }) ``` diff --git a/docs/config/preview-options.md b/docs/config/preview-options.md index 3604afb9576d42..2b4b9841b46bda 100644 --- a/docs/config/preview-options.md +++ b/docs/config/preview-options.md @@ -29,11 +29,11 @@ Specify server port. Note if the port is already being used, Vite will automatic ```js export default defineConfig({ server: { - port: 3030 + port: 3030, }, preview: { - port: 8080 - } + port: 8080, + }, }) ``` diff --git a/docs/config/server-options.md b/docs/config/server-options.md index 89287fe53cf98a..ebcbcbe95a3521 100644 --- a/docs/config/server-options.md +++ b/docs/config/server-options.md @@ -68,8 +68,8 @@ Automatically open the app in the browser on server start. When the value is a s ```js export default defineConfig({ server: { - open: '/docs/index.html' - } + open: '/docs/index.html', + }, }) ``` @@ -97,13 +97,13 @@ export default defineConfig({ '/api': { target: 'http://jsonplaceholder.typicode.com', changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, '') + rewrite: (path) => path.replace(/^\/api/, ''), }, // with RegEx: http://localhost:5173/fallback/ -> http://jsonplaceholder.typicode.com/ '^/fallback/.*': { target: 'http://jsonplaceholder.typicode.com', changeOrigin: true, - rewrite: (path) => path.replace(/^\/fallback/, '') + rewrite: (path) => path.replace(/^\/fallback/, ''), }, // Using the proxy instance '/api': { @@ -111,15 +111,15 @@ export default defineConfig({ changeOrigin: true, configure: (proxy, options) => { // proxy will be an instance of 'http-proxy' - } + }, }, // Proxying websockets or socket.io: ws://localhost:5173/socket.io -> ws://localhost:5174/socket.io '/socket.io': { target: 'ws://localhost:5174', - ws: true - } - } - } + ws: true, + }, + }, + }, }) ``` @@ -177,14 +177,14 @@ The Vite server watcher skips `.git/` and `node_modules/` directories by default export default defineConfig({ server: { watch: { - ignored: ['!**/node_modules/your-package-name/**'] - } + ignored: ['!**/node_modules/your-package-name/**'], + }, }, // The watched package must be excluded from optimization, // so that it can appear in the dependency graph and trigger hot reload. optimizeDeps: { - exclude: ['your-package-name'] - } + exclude: ['your-package-name'], + }, }) ``` @@ -222,7 +222,7 @@ 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 + appType: 'custom', // don't include Vite's default HTML handling middlewares }) // Use vite's connect instance as middleware app.use(vite.middlewares) @@ -271,9 +271,9 @@ export default defineConfig({ server: { fs: { // Allow serving files from one level up to the project root - allow: ['..'] - } - } + allow: ['..'], + }, + }, }) ``` @@ -289,10 +289,10 @@ export default defineConfig({ // search up for workspace root searchForWorkspaceRoot(process.cwd()), // your custom rules - '/path/to/custom/allow' - ] - } - } + '/path/to/custom/allow', + ], + }, + }, }) ``` @@ -312,7 +312,7 @@ Defines the origin of the generated asset URLs during development. ```js export default defineConfig({ server: { - origin: 'http://127.0.0.1:8080' - } + origin: 'http://127.0.0.1:8080', + }, }) ``` diff --git a/docs/config/shared-options.md b/docs/config/shared-options.md index 671ef6be8f9924..fe04872a8770e4 100644 --- a/docs/config/shared-options.md +++ b/docs/config/shared-options.md @@ -69,7 +69,7 @@ Example: ```js const obj = { __NAME__, // Don't define object shorthand property names - __KEY__: value // Don't define object key + __KEY__: value, // Don't define object key } ``` @@ -233,13 +233,13 @@ export default defineConfig({ css: { preprocessorOptions: { scss: { - additionalData: `$injectedColor: orange;` + additionalData: `$injectedColor: orange;`, }, styl: { - additionalData: `$injectedColor ?= orange` - } - } - } + additionalData: `$injectedColor ?= orange`, + }, + }, + }, }) ``` @@ -277,8 +277,8 @@ Enabling this disables named imports. export default defineConfig({ esbuild: { jsxFactory: 'h', - jsxFragment: 'Fragment' - } + jsxFragment: 'Fragment', + }, }) ``` @@ -289,8 +289,8 @@ In addition, you can also use `esbuild.jsxInject` to automatically inject JSX he ```js export default defineConfig({ esbuild: { - jsxInject: `import React from 'react'` - } + jsxInject: `import React from 'react'`, + }, }) ``` @@ -315,7 +315,7 @@ The built-in asset type list can be found [here](https://github.com/vitejs/vite/ ```js export default defineConfig({ - assetsInclude: ['**/*.gltf'] + assetsInclude: ['**/*.gltf'], }) ``` diff --git a/docs/guide/api-hmr.md b/docs/guide/api-hmr.md index 59a689c6ca2223..1f23fdf8626a67 100644 --- a/docs/guide/api-hmr.md +++ b/docs/guide/api-hmr.md @@ -25,18 +25,17 @@ interface ViteHotContext { accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void accept( deps: readonly string[], - cb: (mods: Array) => void + cb: (mods: Array) => void, ): void dispose(cb: (data: any) => void): void prune(cb: (data: any) => void): void - decline(): void invalidate(message?: string): void // `InferCustomEventPayload` provides types for built-in Vite events on( event: T, - cb: (payload: InferCustomEventPayload) => void + cb: (payload: InferCustomEventPayload) => void, ): void send(event: T, data?: InferCustomEventPayload): void } @@ -96,7 +95,7 @@ if (import.meta.hot) { ([newFooModule, newBarModule]) => { // The callback receives an array where only the updated module is non null // If the update was not succeful (syntax error for ex.), the array is empty - } + }, ) } ``` @@ -139,7 +138,7 @@ The `import.meta.hot.data` object is persisted across different instances of the ## `hot.decline()` -Calling `import.meta.hot.decline()` indicates this module is not hot-updatable, and the browser should perform a full reload if this module is encountered while propagating HMR updates. +This is currently a noop and is there for backward compatibility. This could change in the future if there is a new usage for it. To indicate that the module is not hot-updatable, use `hot.invalidate()`. ## `hot.invalidate(message?: string)` diff --git a/docs/guide/api-javascript.md b/docs/guide/api-javascript.md index 199507bc85b29e..935f509c5c1062 100644 --- a/docs/guide/api-javascript.md +++ b/docs/guide/api-javascript.md @@ -24,8 +24,8 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url)) configFile: false, root: __dirname, server: { - port: 1337 - } + port: 1337, + }, }) await server.listen() @@ -102,7 +102,7 @@ interface ViteDevServer { */ transformRequest( url: string, - options?: TransformOptions + options?: TransformOptions, ): Promise /** * Apply Vite built-in HTML transforms and any plugin HTML transforms. @@ -113,7 +113,7 @@ interface ViteDevServer { */ ssrLoadModule( url: string, - options?: { fixStacktrace?: boolean } + options?: { fixStacktrace?: boolean }, ): Promise> /** * Fix ssr error stacktrace. @@ -147,7 +147,7 @@ interface ViteDevServer { ```ts async function build( - inlineConfig?: InlineConfig + inlineConfig?: InlineConfig, ): Promise ``` @@ -167,8 +167,8 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url)) build: { rollupOptions: { // ... - } - } + }, + }, }) })() ``` @@ -190,8 +190,8 @@ import { preview } from 'vite' // any valid user config options, plus `mode` and `configFile` preview: { port: 8080, - open: true - } + open: true, + }, }) previewServer.printUrls() @@ -206,7 +206,7 @@ import { preview } from 'vite' async function resolveConfig( inlineConfig: InlineConfig, command: 'build' | 'serve', - defaultMode = 'development' + defaultMode = 'development', ): Promise ``` @@ -220,7 +220,7 @@ The `command` value is `serve` in dev (in the cli `vite`, `vite dev`, and `vite function mergeConfig( defaults: Record, overrides: Record, - isRoot = true + isRoot = true, ): Record ``` @@ -233,7 +233,7 @@ Deeply merge two Vite configs. `isRoot` represents the level within the Vite con ```ts function searchForWorkspaceRoot( current: string, - root = searchForPackageRoot(current) + root = searchForPackageRoot(current), ): string ``` @@ -254,7 +254,7 @@ Search for the root of the potential workspace if it meets the following conditi function loadEnv( mode: string, envDir: string, - prefixes: string | string[] = 'VITE_' + prefixes: string | string[] = 'VITE_', ): Record ``` @@ -283,7 +283,7 @@ async function transformWithEsbuild( code: string, filename: string, options?: EsbuildTransformOptions, - inMap?: object + inMap?: object, ): Promise ``` @@ -298,7 +298,7 @@ async function loadConfigFromFile( configEnv: ConfigEnv, configFile?: string, configRoot: string = process.cwd(), - logLevel?: LogLevel + logLevel?: LogLevel, ): Promise<{ path: string config: UserConfig diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md index c18c6daca3263f..2713a557fbc56b 100644 --- a/docs/guide/api-plugin.md +++ b/docs/guide/api-plugin.md @@ -48,7 +48,7 @@ import vitePlugin from 'vite-plugin-feature' import rollupPlugin from 'rollup-plugin-feature' export default defineConfig({ - plugins: [vitePlugin(), rollupPlugin()] + plugins: [vitePlugin(), rollupPlugin()], }) ``` @@ -72,7 +72,7 @@ import { defineConfig } from 'vite' import framework from 'vite-plugin-framework' export default defineConfig({ - plugins: [framework()] + plugins: [framework()], }) ``` @@ -95,10 +95,10 @@ export default function myPlugin() { if (fileRegex.test(id)) { return { code: compileFileToJS(src), - map: null // provide source map if available + map: null, // provide source map if available } } - } + }, } } ``` @@ -127,7 +127,7 @@ export default function myPlugin() { if (id === resolvedVirtualModuleId) { return `export const msg = "from virtual module"` } - } + }, } } ``` @@ -188,10 +188,10 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo config: () => ({ resolve: { alias: { - foo: 'bar' - } - } - }) + foo: 'bar', + }, + }, + }), }) // mutate the config directly (use only when merging doesn't work) @@ -201,7 +201,7 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo if (command === 'build') { config.root = 'foo' } - } + }, }) ``` @@ -237,7 +237,7 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo } else { // build: plugin invoked by Rollup } - } + }, } } ``` @@ -259,7 +259,7 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo server.middlewares.use((req, res, next) => { // custom handle request... }) - } + }, }) ``` @@ -278,7 +278,7 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo // custom handle request... }) } - } + }, }) ``` @@ -298,7 +298,7 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo if (server) { // use server... } - } + }, } } ``` @@ -323,13 +323,13 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo // custom handle request... }) } - } + }, }) ``` ### `transformIndexHtml` -- **Type:** `IndexHtmlTransformHook | { enforce?: 'pre' | 'post', transform: IndexHtmlTransformHook }` +- **Type:** `IndexHtmlTransformHook | { order?: 'pre' | 'post', handler: IndexHtmlTransformHook }` - **Kind:** `async`, `sequential` Dedicated hook for transforming HTML entry point files such as `index.html`. The hook receives the current HTML string and a transform context. The context exposes the [`ViteDevServer`](./api-javascript#vitedevserver) instance during dev, and exposes the Rollup output bundle during build. @@ -349,9 +349,9 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo transformIndexHtml(html) { return html.replace( /(.*?)<\/title>/, - `<title>Title replaced!` + `Title replaced!`, ) - } + }, } } ``` @@ -367,7 +367,7 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo server?: ViteDevServer bundle?: import('rollup').OutputBundle chunk?: import('rollup').OutputChunk - } + }, ) => | IndexHtmlTransformResult | void @@ -459,7 +459,7 @@ By default plugins are invoked for both serve and build. In cases where a plugin function myPlugin() { return { name: 'build-only', - apply: 'build' // or 'serve' + apply: 'build', // or 'serve' } } ``` @@ -496,9 +496,9 @@ export default defineConfig({ { ...example(), enforce: 'post', - apply: 'build' - } - ] + apply: 'build', + }, + ], }) ``` @@ -537,9 +537,9 @@ export default defineConfig({ // ... configureServer(server) { server.ws.send('my:greetings', { msg: 'hello' }) - } - } - ] + }, + }, + ], }) ``` @@ -583,9 +583,9 @@ export default defineConfig({ // reply only to the client (if needed) client.send('my:ack', { msg: 'Hi! I got your message!' }) }) - } - } - ] + }, + }, + ], }) ``` diff --git a/docs/guide/backend-integration.md b/docs/guide/backend-integration.md index 535ccbb3e6127b..16ca394ce769a4 100644 --- a/docs/guide/backend-integration.md +++ b/docs/guide/backend-integration.md @@ -16,9 +16,9 @@ If you need a custom integration, you can follow the steps in this guide to conf manifest: true, rollupOptions: { // overwrite default .html entry - input: '/path/to/main.js' - } - } + input: '/path/to/main.js', + }, + }, }) ``` diff --git a/docs/guide/build.md b/docs/guide/build.md index 41376b46e5f2f8..3ed66361803fc1 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -8,7 +8,7 @@ The production bundle assumes support for modern JavaScript. By default, Vite ta - Chrome >=87 - Firefox >=78 -- Safari >=13 +- Safari >=14 - Edge >=88 You can specify custom targets via the [`build.target` config option](/config/build-options.md#build-target), where the lowest target is `es2015`. @@ -39,8 +39,8 @@ export default defineConfig({ build: { rollupOptions: { // https://rollupjs.org/guide/en/#big-list-of-options - } - } + }, + }, }) ``` @@ -54,7 +54,7 @@ You can configure how chunks are split using `build.rollupOptions.output.manualC // vite.config.js import { splitVendorChunkPlugin } from 'vite' export default defineConfig({ - plugins: [splitVendorChunkPlugin()] + plugins: [splitVendorChunkPlugin()], }) ``` @@ -70,8 +70,8 @@ export default defineConfig({ build: { watch: { // https://rollupjs.org/guide/en/#watch-options - } - } + }, + }, }) ``` @@ -105,10 +105,10 @@ export default defineConfig({ rollupOptions: { input: { main: resolve(__dirname, 'index.html'), - nested: resolve(__dirname, 'nested/index.html') - } - } - } + nested: resolve(__dirname, 'nested/index.html'), + }, + }, + }, }) ``` @@ -132,7 +132,7 @@ export default defineConfig({ entry: resolve(__dirname, 'lib/main.js'), name: 'MyLib', // the proper extensions will be added - fileName: 'my-lib' + fileName: 'my-lib', }, rollupOptions: { // make sure to externalize deps that shouldn't be bundled @@ -142,11 +142,11 @@ export default defineConfig({ // Provide global variables to use in the UMD build // for externalized deps globals: { - vue: 'Vue' - } - } - } - } + vue: 'Vue', + }, + }, + }, + }, }) ``` diff --git a/docs/guide/cli.md b/docs/guide/cli.md new file mode 100644 index 00000000000000..3cf679211af8c2 --- /dev/null +++ b/docs/guide/cli.md @@ -0,0 +1,126 @@ +# Command Line Interface + +## Dev server + +### `vite` + +Start Vite dev server in the current directory. Will enter the watch mode in development environment and run mode in CI automatically. + +#### Usage + +```bash +vite [root] +``` + +#### Options + +| Options | | +| ------------------------ | ----------------------------------------------------------------- | +| `--host [host]` | Specify hostname (`string`) | +| `--port ` | Specify port (`number`) | +| `--https` | Use TLS + HTTP/2 (`boolean`) | +| `--open [path]` | Open browser on startup (`boolean \| string`) | +| `--cors` | Enable CORS (`boolean`) | +| `--strictPort` | Exit if specified port is already in use (`boolean`) | +| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | +| `-c, --config ` | Use specified config file (`string`) | +| `--base ` | Public base path (default: `/`) (`string`) | +| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | +| `-f, --filter ` | Filter debug logs (`string`) | +| `-m, --mode ` | Set env mode (`string`) | +| `-h, --help` | Display available CLI options | +| `-v, --version` | Display version number | + +## Build + +### `vite build` + +Build for production. + +#### Usage + +```bash +vite build [root] +``` + +#### Options + +| Options | | +| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | +| `--target ` | Transpile target (default: `"modules"`) (`string`) | +| `--outDir ` | Output directory (default: `dist`) (`string`) | +| `--assetsDir ` | Directory under outDir to place assets in (default: `"assets"`) (`string`) | +| `--assetsInlineLimit ` | Static asset base64 inline threshold in bytes (default: `4096`) (`number`) | +| `--ssr [entry]` | Build specified entry for server-side rendering (`string`) | +| `--sourcemap` | Output source maps for build (default: `false`) (`boolean`) | +| `--minify [minifier]` | Enable/disable minification, or specify minifier to use (default: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) | +| `--manifest [name]` | Emit build manifest json (`boolean \| string`) | +| `--ssrManifest [name]` | Emit ssr manifest json (`boolean \| string`) | +| `--force` | Force the optimizer to ignore the cache and re-bundle (experimental)(`boolean`) | +| `--emptyOutDir` | Force empty outDir when it's outside of root (`boolean`) | +| `-w, --watch` | Rebuilds when modules have changed on disk (`boolean`) | +| `-c, --config ` | Use specified config file (`string`) | +| `--base ` | Public base path (default: `/`) (`string`) | +| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | +| `-f, --filter ` | Filter debug logs (`string`) | +| `-m, --mode ` | Set env mode (`string`) | +| `-h, --help` | Display available CLI options | + +## Others + +### `vite optimize` + +Pre-bundle dependencies. + +#### Usage + +```bash +vite optimize [root] +``` + +#### Options + +| Options | | +| ------------------------ | ----------------------------------------------------------------- | +| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | +| `-c, --config ` | Use specified config file (`string`) | +| `--base ` | Public base path (default: `/`) (`string`) | +| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | +| `-f, --filter ` | Filter debug logs (`string`) | +| `-m, --mode ` | Set env mode (`string`) | +| `-h, --help` | Display available CLI options | + +### `vite preview` + +Locally preview production build. + +#### Usage + +```bash +vite preview [root] +``` + +#### Options + +| Options | | +| ------------------------ | ---------------------------------------------------- | +| `--host [host]` | Specify hostname (`string`) | +| `--port ` | Specify port (`number`) | +| `--strictPort` | Exit if specified port is already in use (`boolean`) | +| `--https` | Use TLS + HTTP/2 (`boolean`) | +| `--open [path]` | Open browser on startup (`boolean \| string`) | +| `--outDir ` | Output directory (default: `dist`)(`string`) | +| `-c, --config ` | Use specified config file (`string`) | +| `--base ` | Public base path (default: `/`) (`string`) | +| `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | +| `-f, --filter ` | Filter debug logs (`string`) | +| `-m, --mode ` | Set env mode (`string`) | +| `-h, --help` | Display available CLI options | diff --git a/docs/guide/dep-pre-bundling.md b/docs/guide/dep-pre-bundling.md index 4ea53feac36cf6..5d5d98cac72645 100644 --- a/docs/guide/dep-pre-bundling.md +++ b/docs/guide/dep-pre-bundling.md @@ -47,13 +47,13 @@ However, this requires the linked dep to be exported as ESM. If not, you can add ```js export default defineConfig({ optimizeDeps: { - include: ['linked-dep'] + include: ['linked-dep'], }, build: { commonjsOptions: { - include: [/linked-dep/, /node_modules/] - } - } + include: [/linked-dep/, /node_modules/], + }, + }, }) ``` @@ -77,9 +77,10 @@ Both `include` and `exclude` can be used to deal with this. If the dependency is Vite caches the pre-bundled dependencies in `node_modules/.vite`. It determines whether it needs to re-run the pre-bundling step based on a few sources: -- The `dependencies` list in your `package.json`. -- Package manager lockfiles, e.g. `package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`. +- Package manager lockfile content, e.g. `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml` or `bun.lockb`. +- Patches folder modification time. - Relevant fields in your `vite.config.js`, if present. +- `NODE_ENV` value. The pre-bundling step will only need to be re-run when one of the above has changed. diff --git a/docs/guide/env-and-mode.md b/docs/guide/env-and-mode.md index 8c14e9d476fdcb..e3032cf92e5bfe 100644 --- a/docs/guide/env-and-mode.md +++ b/docs/guide/env-and-mode.md @@ -120,20 +120,22 @@ VITE_APP_TITLE=My App In your app, you can render the title using `import.meta.env.VITE_APP_TITLE`. -However, it is important to understand that **mode** is a wider concept than just development vs. production. A typical example is you may want to have a "staging" mode where it should have production-like behavior, but with slightly different env variables from production. - -You can overwrite the default mode used for a command by passing the `--mode` option flag. For example, if you want to build your app for our hypothetical staging mode: +In some cases, you may want to run `vite build` with a different mode to render a different title. You can overwrite the default mode used for a command by passing the `--mode` option flag. For example, if you want to build your app for a staging mode: ```bash vite build --mode staging ``` -And to get the behavior we want, we need a `.env.staging` file: +And create a `.env.staging` file: ``` # .env.staging -NODE_ENV=production VITE_APP_TITLE=My App (staging) ``` -Now your staging app should have production-like behavior, but display a different title from production. +As `vite build` runs a production build by default, you can also change this and run a development build by using a different mode and `.env` file configuration: + +``` +# .env.testing +NODE_ENV=development +``` diff --git a/docs/guide/features.md b/docs/guide/features.md index c90427247f820a..60cad69a6ce0be 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -22,7 +22,7 @@ Vite caches dependency requests via HTTP headers, so if you wish to locally edit ## Hot Module Replacement -Vite provides an [HMR API](./api-hmr) over native ESM. Frameworks with HMR capabilities can leverage the API to provide instant, precise updates without reloading the page or blowing away application state. Vite provides first-party HMR integrations for [Vue Single File Components](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) and [React Fast Refresh](https://github.com/vitejs/vite/tree/main/packages/plugin-react). There are also official integrations for Preact via [@prefresh/vite](https://github.com/JoviDeCroock/prefresh/tree/main/packages/vite). +Vite provides an [HMR API](./api-hmr) over native ESM. Frameworks with HMR capabilities can leverage the API to provide instant, precise updates without reloading the page or blowing away application state. Vite provides first-party HMR integrations for [Vue Single File Components](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) and [React Fast Refresh](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react). There are also official integrations for Preact via [@prefresh/vite](https://github.com/JoviDeCroock/prefresh/tree/main/packages/vite). Note you don't need to manually set these up - when you [create an app via `create-vite`](./), the selected templates would have these pre-configured for you already. @@ -120,8 +120,8 @@ declare module '*.svg' { Vite provides first-class Vue support: -- Vue 3 SFC support via [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) -- Vue 3 JSX support via [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) +- Vue 3 SFC support via [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) +- Vue 3 JSX support via [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) - Vue 2.7 support via [@vitejs/plugin-vue2](https://github.com/vitejs/vite-plugin-vue2) - Vue <2.7 support via [vite-plugin-vue2](https://github.com/underfin/vite-plugin-vue2) @@ -129,7 +129,7 @@ Vite provides first-class Vue support: `.jsx` and `.tsx` files are also supported out of the box. JSX transpilation is also handled via [esbuild](https://esbuild.github.io). -Vue users should use the official [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) plugin, which provides Vue 3 specific features including HMR, global component resolving, directives and slots. +Vue users should use the official [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) plugin, which provides Vue 3 specific features including HMR, global component resolving, directives and slots. If not using JSX with React or Vue, custom `jsxFactory` and `jsxFragment` can be configured using the [`esbuild` option](/config/shared-options.md#esbuild). For example for Preact: @@ -140,8 +140,8 @@ import { defineConfig } from 'vite' export default defineConfig({ esbuild: { jsxFactory: 'h', - jsxFragment: 'Fragment' - } + jsxFragment: 'Fragment', + }, }) ``` @@ -155,8 +155,8 @@ import { defineConfig } from 'vite' export default defineConfig({ esbuild: { - jsxInject: `import React from 'react'` - } + jsxInject: `import React from 'react'`, + }, }) ``` @@ -294,7 +294,7 @@ The above will be transformed into the following: // code produced by vite const modules = { './dir/foo.js': () => import('./dir/foo.js'), - './dir/bar.js': () => import('./dir/bar.js') + './dir/bar.js': () => import('./dir/bar.js'), } ``` @@ -322,7 +322,7 @@ import * as __glob__0_0 from './dir/foo.js' import * as __glob__0_1 from './dir/bar.js' const modules = { './dir/foo.js': __glob__0_0, - './dir/bar.js': __glob__0_1 + './dir/bar.js': __glob__0_1, } ``` @@ -340,7 +340,7 @@ The above will be transformed into the following: // code produced by vite const modules = { './dir/foo.js': 'export default "foo"\n', - './dir/bar.js': 'export default "bar"\n' + './dir/bar.js': 'export default "bar"\n', } ``` @@ -365,7 +365,7 @@ const modules = import.meta.glob(['./dir/*.js', '!**/bar.js']) ```js // code produced by vite const modules = { - './dir/foo.js': () => import('./dir/foo.js') + './dir/foo.js': () => import('./dir/foo.js'), } ``` @@ -381,7 +381,7 @@ const modules = import.meta.glob('./dir/*.js', { import: 'setup' }) // code produced by vite const modules = { './dir/foo.js': () => import('./dir/foo.js').then((m) => m.setup), - './dir/bar.js': () => import('./dir/bar.js').then((m) => m.setup) + './dir/bar.js': () => import('./dir/bar.js').then((m) => m.setup), } ``` @@ -397,7 +397,7 @@ import { setup as __glob__0_0 } from './dir/foo.js' import { setup as __glob__0_1 } from './dir/bar.js' const modules = { './dir/foo.js': __glob__0_0, - './dir/bar.js': __glob__0_1 + './dir/bar.js': __glob__0_1, } ``` @@ -406,7 +406,7 @@ Set `import` to `default` to import the default export. ```ts const modules = import.meta.glob('./dir/*.js', { import: 'default', - eager: true + eager: true, }) ``` @@ -416,7 +416,7 @@ import __glob__0_0 from './dir/foo.js' import __glob__0_1 from './dir/bar.js' const modules = { './dir/foo.js': __glob__0_0, - './dir/bar.js': __glob__0_1 + './dir/bar.js': __glob__0_1, } ``` @@ -426,7 +426,7 @@ You can also use the `query` option to provide custom queries to imports for oth ```ts const modules = import.meta.glob('./dir/*.js', { - query: { foo: 'bar', bar: true } + query: { foo: 'bar', bar: true }, }) ``` @@ -436,7 +436,7 @@ const modules = { './dir/foo.js': () => import('./dir/foo.js?foo=bar&bar=true').then((m) => m.setup), './dir/bar.js': () => - import('./dir/bar.js?foo=bar&bar=true').then((m) => m.setup) + import('./dir/bar.js?foo=bar&bar=true').then((m) => m.setup), } ``` @@ -478,8 +478,8 @@ init({ imports: { someFunc: () => { /* ... */ - } - } + }, + }, }).then(() => { /* ... */ }) @@ -506,7 +506,7 @@ The worker constructor also accepts options, which can be used to create "module ```ts const worker = new Worker(new URL('./worker.js', import.meta.url), { - type: 'module' + type: 'module', }) ``` diff --git a/docs/guide/index.md b/docs/guide/index.md index e88dbbb045d823..c313dbaebfa29c 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -128,6 +128,8 @@ In a project where Vite is installed, you can use the `vite` binary in your npm You can specify additional CLI options like `--port` or `--https`. For a full list of CLI options, run `npx vite --help` in your project. +Learn more about the [Command Line Interface](./cli.md) + ## Using Unreleased Commits If you can't wait for a new release to test the latest features, you will need to clone the [vite repo](https://github.com/vitejs/vite) to your local machine and then build and link it yourself ([pnpm](https://pnpm.io/) is required): diff --git a/docs/guide/migration.md b/docs/guide/migration.md index c47207686af609..3fa4683a5b4d1f 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -98,7 +98,7 @@ Since Vite v3, we recommend manually creating your certificates. If you still wa import basicSsl from '@vitejs/plugin-basic-ssl' export default { - plugins: [basicSsl()] + plugins: [basicSsl()], } ``` diff --git a/docs/guide/ssr.md b/docs/guide/ssr.md index dc7d976382c207..b4eee64df7166e 100644 --- a/docs/guide/ssr.md +++ b/docs/guide/ssr.md @@ -18,8 +18,8 @@ If you have questions, the community is usually helpful at [Vite Discord's #ssr Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be used as references for this guide: -- [Vue 3](https://github.com/vitejs/vite/tree/main/playground/ssr-vue) -- [React](https://github.com/vitejs/vite/tree/main/playground/ssr-react) +- [Vue 3](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue) +- [React](https://github.com/vitejs/vite-plugin-react/tree/main/playground/ssr-react) ## Source Structure @@ -107,7 +107,7 @@ app.use('*', async (req, res, next) => { // 1. Read index.html let template = fs.readFileSync( path.resolve(__dirname, 'index.html'), - 'utf-8' + 'utf-8', ) // 2. Apply Vite HTML transforms. This injects the Vite HMR client, and @@ -162,7 +162,7 @@ Our scripts in `package.json` will look like this: "scripts": { "dev": "node server", "build:client": "vite build --outDir dist/client", - "build:server": "vite build --outDir dist/server --ssr src/entry-server.js " + "build:server": "vite build --outDir dist/server --ssr src/entry-server.js" } } ``` @@ -177,7 +177,7 @@ Then, in `server.js` we need to add some production specific logic by checking ` - Move the creation and all usage of the `vite` dev server behind dev-only conditional branches, then add static file serving middlewares to serve files from `dist/client`. -Refer to the [Vue](https://github.com/vitejs/vite/tree/main/playground/ssr-vue) and [React](https://github.com/vitejs/vite/tree/main/playground/ssr-react) demos for a working setup. +Refer to the [Vue](https://github.com/vitejs/vite-plugin-vue/tree/main/playground/ssr-vue) and [React](https://github.com/vitejs/vite-plugin-react/tree/main/playground/ssr-react) demos for a working setup. ## Generating Preload Directives @@ -201,11 +201,11 @@ const html = await vueServerRenderer.renderToString(app, ctx) // ctx.modules is now a Set of module IDs that were used during the render ``` -In the production branch of `server.js` we need to read and pass the manifest to the `render` function exported by `src/entry-server.js`. This would provide us with enough information to render preload directives for files used by async routes! See [demo source](https://github.com/vitejs/vite/blob/main/playground/ssr-vue/src/entry-server.js) for a full example. +In the production branch of `server.js` we need to read and pass the manifest to the `render` function exported by `src/entry-server.js`. This would provide us with enough information to render preload directives for files used by async routes! See [demo source](https://github.com/vitejs/vite-plugin-vue/blob/main/playground/ssr-vue/src/entry-server.js) for a full example. ## Pre-Rendering / SSG -If the routes and the data needed for certain routes are known ahead of time, we can pre-render these routes into static HTML using the same logic as production SSR. This can also be considered a form of Static-Site Generation (SSG). See [demo pre-render script](https://github.com/vitejs/vite/blob/main/playground/ssr-vue/prerender.js) for working example. +If the routes and the data needed for certain routes are known ahead of time, we can pre-render these routes into static HTML using the same logic as production SSR. This can also be considered a form of Static-Site Generation (SSG). See [demo pre-render script](https://github.com/vitejs/vite-plugin-vue/blob/main/playground/ssr-vue/prerender.js) for working example. ## SSR Externals @@ -237,7 +237,7 @@ export function mySSRPlugin() { if (options?.ssr) { // perform ssr-specific transform... } - } + }, } } ``` diff --git a/docs/guide/using-plugins.md b/docs/guide/using-plugins.md index b05c8c9f2223d3..8f6887594a197a 100644 --- a/docs/guide/using-plugins.md +++ b/docs/guide/using-plugins.md @@ -18,9 +18,9 @@ import { defineConfig } from 'vite' export default defineConfig({ plugins: [ legacy({ - targets: ['defaults', 'not IE 11'] - }) - ] + targets: ['defaults', 'not IE 11'], + }), + ], }) ``` @@ -55,9 +55,9 @@ export default defineConfig({ plugins: [ { ...image(), - enforce: 'pre' - } - ] + enforce: 'pre', + }, + ], }) ``` @@ -76,9 +76,9 @@ export default defineConfig({ plugins: [ { ...typescript2(), - apply: 'build' - } - ] + apply: 'build', + }, + ], }) ``` diff --git a/docs/plugins/index.md b/docs/plugins/index.md index 0a8803ba2d3b9a..a0057760319d8e 100644 --- a/docs/plugins/index.md +++ b/docs/plugins/index.md @@ -8,15 +8,15 @@ Check out [Using Plugins](../guide/using-plugins) for information on how to use ## Official Plugins -### [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) +### [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) - Provides Vue 3 Single File Components support. -### [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) +### [@vitejs/plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) - Provides Vue 3 JSX support (via [dedicated Babel transform](https://github.com/vuejs/jsx-next)). -### [@vitejs/plugin-react](https://github.com/vitejs/vite/tree/main/packages/plugin-react) +### [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react) - Provides all-in-one React Support. diff --git a/package.json b/package.json index f1803199ec1c36..1248b937bae7a5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "vite-monorepo", + "name": "@vitejs/vite-monorepo", "private": true, "engines": { "node": "^14.18.0 || >=16.0.0" @@ -36,9 +36,9 @@ "ci-docs": "run-s build docs-build" }, "devDependencies": { - "@babel/types": "^7.20.2", + "@babel/types": "^7.20.5", "@microsoft/api-extractor": "^7.33.6", - "@rollup/plugin-typescript": "^9.0.2", + "@rollup/plugin-typescript": "^10.0.1", "@types/babel__core": "^7.1.20", "@types/babel__standalone": "^7.1.4", "@types/convert-source-map": "^1.5.2", @@ -50,7 +50,7 @@ "@types/less": "^3.0.3", "@types/micromatch": "^4.0.2", "@types/minimist": "^1.2.2", - "@types/node": "^17.0.42", + "@types/node": "^18.11.10", "@types/picomatch": "^2.3.0", "@types/prompts": "^2.4.1", "@types/resolve": "^1.20.2", @@ -58,39 +58,39 @@ "@types/semver": "^7.3.13", "@types/stylus": "^0.48.38", "@types/ws": "^8.5.3", - "@typescript-eslint/eslint-plugin": "^5.43.0", - "@typescript-eslint/parser": "^5.43.0", + "@typescript-eslint/eslint-plugin": "^5.45.0", + "@typescript-eslint/parser": "^5.45.0", "conventional-changelog-cli": "^2.2.2", - "esbuild": "^0.15.9", - "eslint": "^8.28.0", + "esbuild": "^0.15.18", + "eslint": "^8.29.0", "eslint-define-config": "^1.12.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-regexp": "^1.10.0", + "eslint-plugin-regexp": "^1.11.0", "execa": "^6.1.0", "fast-glob": "^3.2.12", "fs-extra": "^10.1.0", - "lint-staged": "^13.0.3", + "lint-staged": "^13.1.0", "minimist": "^1.2.7", "npm-run-all": "^4.1.5", "picocolors": "^1.0.0", - "playwright-chromium": "^1.28.0", - "pnpm": "^7.17.0", - "prettier": "2.7.1", + "playwright-chromium": "^1.28.1", + "pnpm": "^7.18.1", + "prettier": "2.8.0", "prompts": "^2.4.2", "resolve": "^1.22.1", "rimraf": "^3.0.2", - "rollup": "~3.3.0", + "rollup": "^3.6.0", "rollup-plugin-license": "^2.9.1", "semver": "^7.3.8", "simple-git-hooks": "^2.8.1", "tslib": "^2.4.1", "tsx": "^3.12.1", - "typescript": "^4.6.4", + "typescript": "^4.9.3", "unbuild": "^0.9.4", "vite": "workspace:*", "vitepress": "^1.0.0-alpha.29", - "vitest": "^0.25.2", + "vitest": "^0.25.3", "vue": "^3.2.45" }, "simple-git-hooks": { @@ -111,18 +111,25 @@ "eslint --cache --fix" ] }, - "packageManager": "pnpm@7.17.0", + "packageManager": "pnpm@7.18.1", "pnpm": { "overrides": { - "vite": "workspace:*", - "@vitejs/plugin-vue": "workspace:*" + "vite": "workspace:*" }, "packageExtensions": { "postcss-load-config": { "peerDependencies": { "postcss": "*" } + }, + "acorn-walk": { + "peerDependencies": { + "acorn": "*" + } } + }, + "patchedDependencies": { + "dotenv-expand@9.0.0": "patches/dotenv-expand@9.0.0.patch" } } } diff --git a/packages/create-vite/CHANGELOG.md b/packages/create-vite/CHANGELOG.md index b9c9aa90770887..85a4beadd8646f 100644 --- a/packages/create-vite/CHANGELOG.md +++ b/packages/create-vite/CHANGELOG.md @@ -1,3 +1,19 @@ +## 4.0.0-beta.0 (2022-12-07) + +* chore: enable prettier trailing commas (#11167) ([134ce68](https://github.com/vitejs/vite/commit/134ce68)), closes [#11167](https://github.com/vitejs/vite/issues/11167) +* chore: update create-vite to use beta versions (#11244) ([f7cfab9](https://github.com/vitejs/vite/commit/f7cfab9)), closes [#11244](https://github.com/vitejs/vite/issues/11244) +* chore(create-vite): align vue template with create-vue (#11128) ([1a54e58](https://github.com/vitejs/vite/commit/1a54e58)), closes [#11128](https://github.com/vitejs/vite/issues/11128) +* chore(deps): typescript 4.9 (#11229) ([6b4c4e2](https://github.com/vitejs/vite/commit/6b4c4e2)), closes [#11229](https://github.com/vitejs/vite/issues/11229) +* chore(deps): update all non-major dependencies (#10910) ([f6ad607](https://github.com/vitejs/vite/commit/f6ad607)), closes [#10910](https://github.com/vitejs/vite/issues/10910) +* chore(deps): update all non-major dependencies (#11006) ([96f2e98](https://github.com/vitejs/vite/commit/96f2e98)), closes [#11006](https://github.com/vitejs/vite/issues/11006) +* chore(deps): update all non-major dependencies (#11182) ([8b83089](https://github.com/vitejs/vite/commit/8b83089)), closes [#11182](https://github.com/vitejs/vite/issues/11182) +* refactor: move framework plugins out of core (#11158) ([5935619](https://github.com/vitejs/vite/commit/5935619)), closes [#11158](https://github.com/vitejs/vite/issues/11158) +* fix(deps): update all non-major dependencies (#10804) ([f686afa](https://github.com/vitejs/vite/commit/f686afa)), closes [#10804](https://github.com/vitejs/vite/issues/10804) +* fix(deps): update all non-major dependencies (#11091) ([073a4bf](https://github.com/vitejs/vite/commit/073a4bf)), closes [#11091](https://github.com/vitejs/vite/issues/11091) +* perf: regexp perf issues, refactor regexp stylistic issues (#10905) ([fc007df](https://github.com/vitejs/vite/commit/fc007df)), closes [#10905](https://github.com/vitejs/vite/issues/10905) + + + ## 3.2.1 (2022-11-07) * chore(deps): update all non-major dependencies (#10725) ([22cfad8](https://github.com/vitejs/vite/commit/22cfad8)), closes [#10725](https://github.com/vitejs/vite/issues/10725) diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts index f5d666c3577e28..35239f2707c2c3 100644 --- a/packages/create-vite/__tests__/cli.spec.ts +++ b/packages/create-vite/__tests__/cli.spec.ts @@ -11,7 +11,7 @@ const genPath = join(__dirname, projectName) const run = ( args: string[], - options: SyncOptions = {} + options: SyncOptions = {}, ): ExecaSyncReturnValue => { return execaCommandSync(`node ${CLI_PATH} ${args.join(' ')}`, options) } @@ -59,7 +59,7 @@ test('prompts for the framework on not supplying a value for --template', () => test('prompts for the framework on supplying an invalid template', () => { const { stdout } = run([projectName, '--template', 'unknown']) expect(stdout).toContain( - `"unknown" isn't a valid template. Please choose from below:` + `"unknown" isn't a valid template. Please choose from below:`, ) }) @@ -77,7 +77,7 @@ test('asks to overwrite non-empty current directory', () => { test('successfully scaffolds a project based on vue starter template', () => { const { stdout } = run([projectName, '--template', 'vue'], { - cwd: __dirname + cwd: __dirname, }) const generatedFiles = readdirSync(genPath).sort() @@ -88,7 +88,7 @@ test('successfully scaffolds a project based on vue starter template', () => { test('works with the -t alias', () => { const { stdout } = run([projectName, '-t', 'vue'], { - cwd: __dirname + cwd: __dirname, }) const generatedFiles = readdirSync(genPath).sort() diff --git a/packages/create-vite/build.config.ts b/packages/create-vite/build.config.ts index 2c39d19d427de6..3ec4f99bab2213 100644 --- a/packages/create-vite/build.config.ts +++ b/packages/create-vite/build.config.ts @@ -11,12 +11,12 @@ export default defineBuildConfig({ rollup: { inlineDependencies: true, esbuild: { - minify: true - } + minify: true, + }, }, alias: { // we can always use non-transpiled code since we support 14.18.0+ - prompts: 'prompts/lib/index.js' + prompts: 'prompts/lib/index.js', }, hooks: { 'rollup:options'(ctx, options) { @@ -27,9 +27,9 @@ export default defineBuildConfig({ licensePlugin( path.resolve(__dirname, './LICENSE'), 'create-vite license', - 'create-vite' - ) + 'create-vite', + ), ) - } - } + }, + }, }) diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 8405ddc599befc..3e9ce6b18e01eb 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -1,6 +1,6 @@ { "name": "create-vite", - "version": "3.2.1", + "version": "4.0.0-beta.0", "type": "module", "license": "MIT", "author": "Evan You", diff --git a/packages/create-vite/src/index.ts b/packages/create-vite/src/index.ts index ce800f3eb23a24..f6bae6ebe82407 100755 --- a/packages/create-vite/src/index.ts +++ b/packages/create-vite/src/index.ts @@ -13,7 +13,7 @@ import { magenta, red, reset, - yellow + yellow, } from 'kolorist' // Avoids autoconversion to number of the project name by defining that the args @@ -47,14 +47,14 @@ const FRAMEWORKS: Framework[] = [ { name: 'vanilla', display: 'JavaScript', - color: yellow + color: yellow, }, { name: 'vanilla-ts', display: 'TypeScript', - color: blue - } - ] + color: blue, + }, + ], }, { name: 'vue', @@ -64,26 +64,26 @@ const FRAMEWORKS: Framework[] = [ { name: 'vue', display: 'JavaScript', - color: yellow + color: yellow, }, { name: 'vue-ts', display: 'TypeScript', - color: blue + color: blue, }, { name: 'custom-create-vue', display: 'Customize with create-vue ↗', color: green, - customCommand: 'npm create vue@latest TARGET_DIR' + customCommand: 'npm create vue@latest TARGET_DIR', }, { name: 'custom-nuxt', display: 'Nuxt ↗', color: lightGreen, - customCommand: 'npm exec nuxi init TARGET_DIR' - } - ] + customCommand: 'npm exec nuxi init TARGET_DIR', + }, + ], }, { name: 'react', @@ -93,14 +93,14 @@ const FRAMEWORKS: Framework[] = [ { name: 'react', display: 'JavaScript', - color: yellow + color: yellow, }, { name: 'react-ts', display: 'TypeScript', - color: blue - } - ] + color: blue, + }, + ], }, { name: 'preact', @@ -110,14 +110,14 @@ const FRAMEWORKS: Framework[] = [ { name: 'preact', display: 'JavaScript', - color: yellow + color: yellow, }, { name: 'preact-ts', display: 'TypeScript', - color: blue - } - ] + color: blue, + }, + ], }, { name: 'lit', @@ -127,14 +127,14 @@ const FRAMEWORKS: Framework[] = [ { name: 'lit', display: 'JavaScript', - color: yellow + color: yellow, }, { name: 'lit-ts', display: 'TypeScript', - color: blue - } - ] + color: blue, + }, + ], }, { name: 'svelte', @@ -144,20 +144,20 @@ const FRAMEWORKS: Framework[] = [ { name: 'svelte', display: 'JavaScript', - color: yellow + color: yellow, }, { name: 'svelte-ts', display: 'TypeScript', - color: blue + color: blue, }, { name: 'custom-svelte-kit', display: 'SvelteKit ↗', color: red, - customCommand: 'npm create svelte@latest TARGET_DIR' - } - ] + customCommand: 'npm create svelte@latest TARGET_DIR', + }, + ], }, { name: 'others', @@ -168,18 +168,18 @@ const FRAMEWORKS: Framework[] = [ name: 'create-vite-extra', display: 'create-vite-extra ↗', color: reset, - customCommand: 'npm create vite-extra@latest TARGET_DIR' - } - ] - } + customCommand: 'npm create vite-extra@latest TARGET_DIR', + }, + ], + }, ] const TEMPLATES = FRAMEWORKS.map( - (f) => (f.variants && f.variants.map((v) => v.name)) || [f.name] + (f) => (f.variants && f.variants.map((v) => v.name)) || [f.name], ).reduce((a, b) => a.concat(b), []) const renameFiles: Record = { - _gitignore: '.gitignore' + _gitignore: '.gitignore', } const defaultTargetDir = 'vite-project' @@ -206,7 +206,7 @@ async function init() { initial: defaultTargetDir, onState: (state) => { targetDir = formatTargetDir(state.value) || defaultTargetDir - } + }, }, { type: () => @@ -216,7 +216,7 @@ async function init() { (targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"`) + - ` is not empty. Remove existing files and continue?` + ` is not empty. Remove existing files and continue?`, }, { type: (_, { overwrite }: { overwrite?: boolean }) => { @@ -225,7 +225,7 @@ async function init() { } return null }, - name: 'overwriteChecker' + name: 'overwriteChecker', }, { type: () => (isValidPackageName(getProjectName()) ? null : 'text'), @@ -233,7 +233,7 @@ async function init() { message: reset('Package name:'), initial: () => toValidPackageName(getProjectName()), validate: (dir) => - isValidPackageName(dir) || 'Invalid package.json name' + isValidPackageName(dir) || 'Invalid package.json name', }, { type: @@ -242,7 +242,7 @@ async function init() { message: typeof argTemplate === 'string' && !TEMPLATES.includes(argTemplate) ? reset( - `"${argTemplate}" isn't a valid template. Please choose from below: ` + `"${argTemplate}" isn't a valid template. Please choose from below: `, ) : reset('Select a framework:'), initial: 0, @@ -250,9 +250,9 @@ async function init() { const frameworkColor = framework.color return { title: frameworkColor(framework.display || framework.name), - value: framework + value: framework, } - }) + }), }, { type: (framework: Framework) => @@ -264,16 +264,16 @@ async function init() { const variantColor = variant.color return { title: variantColor(variant.display || variant.name), - value: variant.name + value: variant.name, } - }) - } + }), + }, ], { onCancel: () => { throw new Error(red('✖') + ' Operation cancelled') - } - } + }, + }, ) } catch (cancelled: any) { console.log(cancelled.message) @@ -322,7 +322,7 @@ async function init() { const [command, ...args] = fullCustomCommand.split(' ') const { status } = spawn.sync(command, args, { - stdio: 'inherit' + stdio: 'inherit', }) process.exit(status ?? 0) } @@ -332,7 +332,7 @@ async function init() { const templateDir = path.resolve( fileURLToPath(import.meta.url), '../..', - `template-${template}` + `template-${template}`, ) const write = (file: string, content?: string) => { @@ -350,7 +350,7 @@ async function init() { } const pkg = JSON.parse( - fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8') + fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8'), ) pkg.name = packageName || getProjectName() @@ -389,7 +389,7 @@ function copy(src: string, dest: string) { function isValidPackageName(projectName: string) { return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test( - projectName + projectName, ) } @@ -434,7 +434,7 @@ function pkgFromUserAgent(userAgent: string | undefined) { const pkgSpecArr = pkgSpec.split('/') return { name: pkgSpecArr[0], - version: pkgSpecArr[1] + version: pkgSpecArr[1], } } diff --git a/packages/create-vite/template-lit-ts/package.json b/packages/create-vite/template-lit-ts/package.json index 5fdfb4ac2d4ec4..4b96ffa56d377b 100644 --- a/packages/create-vite/template-lit-ts/package.json +++ b/packages/create-vite/template-lit-ts/package.json @@ -20,7 +20,7 @@ "lit": "^2.4.1" }, "devDependencies": { - "typescript": "^4.6.4", - "vite": "^3.2.4" + "typescript": "^4.9.3", + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-lit-ts/vite.config.ts b/packages/create-vite/template-lit-ts/vite.config.ts index 14639f4b1c5178..fe69491e390523 100644 --- a/packages/create-vite/template-lit-ts/vite.config.ts +++ b/packages/create-vite/template-lit-ts/vite.config.ts @@ -5,10 +5,10 @@ export default defineConfig({ build: { lib: { entry: 'src/my-element.ts', - formats: ['es'] + formats: ['es'], }, rollupOptions: { - external: /^lit/ - } - } + external: /^lit/, + }, + }, }) diff --git a/packages/create-vite/template-lit/package.json b/packages/create-vite/template-lit/package.json index 1e2b5cc2a067b4..92e758223cbc1e 100644 --- a/packages/create-vite/template-lit/package.json +++ b/packages/create-vite/template-lit/package.json @@ -18,6 +18,6 @@ "lit": "^2.4.1" }, "devDependencies": { - "vite": "^3.2.4" + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-lit/src/my-element.js b/packages/create-vite/template-lit/src/my-element.js index 7c0c0426e49116..effd159f8b5f2d 100644 --- a/packages/create-vite/template-lit/src/my-element.js +++ b/packages/create-vite/template-lit/src/my-element.js @@ -18,7 +18,7 @@ export class MyElement extends LitElement { /** * The number of times the button has been clicked. */ - count: { type: Number } + count: { type: Number }, } } diff --git a/packages/create-vite/template-lit/vite.config.js b/packages/create-vite/template-lit/vite.config.js index 45cfc00cd01365..3847c1f38466f1 100644 --- a/packages/create-vite/template-lit/vite.config.js +++ b/packages/create-vite/template-lit/vite.config.js @@ -5,10 +5,10 @@ export default defineConfig({ build: { lib: { entry: 'src/my-element.js', - formats: ['es'] + formats: ['es'], }, rollupOptions: { - external: /^lit/ - } - } + external: /^lit/, + }, + }, }) diff --git a/packages/create-vite/template-preact-ts/package.json b/packages/create-vite/template-preact-ts/package.json index f3379cbff4ab5e..7d9619bfc0b952 100644 --- a/packages/create-vite/template-preact-ts/package.json +++ b/packages/create-vite/template-preact-ts/package.json @@ -13,7 +13,7 @@ }, "devDependencies": { "@preact/preset-vite": "^2.4.0", - "typescript": "^4.6.4", - "vite": "^3.2.4" + "typescript": "^4.9.3", + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-preact-ts/vite.config.ts b/packages/create-vite/template-preact-ts/vite.config.ts index e3bdaffe854595..29b326faf09c97 100644 --- a/packages/create-vite/template-preact-ts/vite.config.ts +++ b/packages/create-vite/template-preact-ts/vite.config.ts @@ -3,5 +3,5 @@ import preact from '@preact/preset-vite' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [preact()] + plugins: [preact()], }) diff --git a/packages/create-vite/template-preact/package.json b/packages/create-vite/template-preact/package.json index b5263a181a71b8..1eb28d64c8ce3a 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.4.0", - "vite": "^3.2.4" + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-preact/vite.config.js b/packages/create-vite/template-preact/vite.config.js index e3bdaffe854595..29b326faf09c97 100644 --- a/packages/create-vite/template-preact/vite.config.js +++ b/packages/create-vite/template-preact/vite.config.js @@ -3,5 +3,5 @@ import preact from '@preact/preset-vite' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [preact()] + plugins: [preact()], }) diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index bcde3577f8f5b0..ef60ad8c26dde4 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -13,10 +13,10 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@types/react": "^18.0.25", + "@types/react": "^18.0.26", "@types/react-dom": "^18.0.9", - "@vitejs/plugin-react": "^2.2.0", - "typescript": "^4.6.4", - "vite": "^3.2.4" + "@vitejs/plugin-react": "^3.0.0-beta.0", + "typescript": "^4.9.3", + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-react-ts/src/main.tsx b/packages/create-vite/template-react-ts/src/main.tsx index 611e848f1a3e9c..791f139e242c70 100644 --- a/packages/create-vite/template-react-ts/src/main.tsx +++ b/packages/create-vite/template-react-ts/src/main.tsx @@ -6,5 +6,5 @@ import './index.css' ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - + , ) diff --git a/packages/create-vite/template-react-ts/vite.config.ts b/packages/create-vite/template-react-ts/vite.config.ts index b1b5f91e5ffd7f..5a33944a9b41b5 100644 --- a/packages/create-vite/template-react-ts/vite.config.ts +++ b/packages/create-vite/template-react-ts/vite.config.ts @@ -3,5 +3,5 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()] + plugins: [react()], }) diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index d33df374377dbe..701befa0a73914 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -13,9 +13,9 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@types/react": "^18.0.25", + "@types/react": "^18.0.26", "@types/react-dom": "^18.0.9", - "@vitejs/plugin-react": "^2.2.0", - "vite": "^3.2.4" + "@vitejs/plugin-react": "^3.0.0-beta.0", + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-react/src/main.jsx b/packages/create-vite/template-react/src/main.jsx index 9af0bb638e42c0..5cc599199a2091 100644 --- a/packages/create-vite/template-react/src/main.jsx +++ b/packages/create-vite/template-react/src/main.jsx @@ -6,5 +6,5 @@ import './index.css' ReactDOM.createRoot(document.getElementById('root')).render( - + , ) diff --git a/packages/create-vite/template-react/vite.config.js b/packages/create-vite/template-react/vite.config.js index b1b5f91e5ffd7f..5a33944a9b41b5 100644 --- a/packages/create-vite/template-react/vite.config.js +++ b/packages/create-vite/template-react/vite.config.js @@ -3,5 +3,5 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()] + plugins: [react()], }) diff --git a/packages/create-vite/template-svelte-ts/package.json b/packages/create-vite/template-svelte-ts/package.json index 5870260be40a8a..66e2c6f01c904d 100644 --- a/packages/create-vite/template-svelte-ts/package.json +++ b/packages/create-vite/template-svelte-ts/package.json @@ -10,13 +10,13 @@ "check": "svelte-check --tsconfig ./tsconfig.json" }, "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^1.2.0", + "@sveltejs/vite-plugin-svelte": "^2.0.0-beta.0", "@tsconfig/svelte": "^3.0.0", "svelte": "^3.53.1", - "svelte-check": "^2.9.2", + "svelte-check": "^2.10.0", "svelte-preprocess": "^4.10.7", "tslib": "^2.4.1", - "typescript": "^4.6.4", - "vite": "^3.2.4" + "typescript": "^4.9.3", + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-svelte-ts/src/main.ts b/packages/create-vite/template-svelte-ts/src/main.ts index 5c1f795f9f55a6..8a909a15a0ebff 100644 --- a/packages/create-vite/template-svelte-ts/src/main.ts +++ b/packages/create-vite/template-svelte-ts/src/main.ts @@ -2,7 +2,7 @@ import './app.css' import App from './App.svelte' const app = new App({ - target: document.getElementById('app') + target: document.getElementById('app'), }) export default app diff --git a/packages/create-vite/template-svelte-ts/svelte.config.js b/packages/create-vite/template-svelte-ts/svelte.config.js index 3630bb3963b627..aa911a709460bf 100644 --- a/packages/create-vite/template-svelte-ts/svelte.config.js +++ b/packages/create-vite/template-svelte-ts/svelte.config.js @@ -3,5 +3,5 @@ import sveltePreprocess from 'svelte-preprocess' export default { // Consult https://github.com/sveltejs/svelte-preprocess // for more information about preprocessors - preprocess: sveltePreprocess() + preprocess: sveltePreprocess(), } diff --git a/packages/create-vite/template-svelte-ts/vite.config.ts b/packages/create-vite/template-svelte-ts/vite.config.ts index 401b4d4bd6b143..d70196943d0d24 100644 --- a/packages/create-vite/template-svelte-ts/vite.config.ts +++ b/packages/create-vite/template-svelte-ts/vite.config.ts @@ -3,5 +3,5 @@ import { svelte } from '@sveltejs/vite-plugin-svelte' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [svelte()] + plugins: [svelte()], }) diff --git a/packages/create-vite/template-svelte/package.json b/packages/create-vite/template-svelte/package.json index c59a0c996f8796..aaf3b6b1493565 100644 --- a/packages/create-vite/template-svelte/package.json +++ b/packages/create-vite/template-svelte/package.json @@ -9,8 +9,8 @@ "preview": "vite preview" }, "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^1.2.0", + "@sveltejs/vite-plugin-svelte": "^2.0.0-beta.0", "svelte": "^3.53.1", - "vite": "^3.2.4" + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-svelte/src/main.js b/packages/create-vite/template-svelte/src/main.js index 5c1f795f9f55a6..8a909a15a0ebff 100644 --- a/packages/create-vite/template-svelte/src/main.js +++ b/packages/create-vite/template-svelte/src/main.js @@ -2,7 +2,7 @@ import './app.css' import App from './App.svelte' const app = new App({ - target: document.getElementById('app') + target: document.getElementById('app'), }) export default app diff --git a/packages/create-vite/template-svelte/vite.config.js b/packages/create-vite/template-svelte/vite.config.js index 401b4d4bd6b143..d70196943d0d24 100644 --- a/packages/create-vite/template-svelte/vite.config.js +++ b/packages/create-vite/template-svelte/vite.config.js @@ -3,5 +3,5 @@ import { svelte } from '@sveltejs/vite-plugin-svelte' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [svelte()] + plugins: [svelte()], }) diff --git a/packages/create-vite/template-vanilla-ts/package.json b/packages/create-vite/template-vanilla-ts/package.json index 35fe00aff04f46..c36e72003aa54f 100644 --- a/packages/create-vite/template-vanilla-ts/package.json +++ b/packages/create-vite/template-vanilla-ts/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "devDependencies": { - "typescript": "^4.6.4", - "vite": "^3.2.4" + "typescript": "^4.9.3", + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-vanilla/package.json b/packages/create-vite/template-vanilla/package.json index 0df5cde3d0915b..4e71f7b6c9d47f 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": "^3.2.4" + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-vue-ts/.vscode/extensions.json b/packages/create-vite/template-vue-ts/.vscode/extensions.json index a7cea0b0678120..c0a6e5a48110e4 100644 --- a/packages/create-vite/template-vue-ts/.vscode/extensions.json +++ b/packages/create-vite/template-vue-ts/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["Vue.volar"] + "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] } diff --git a/packages/create-vite/template-vue-ts/README.md b/packages/create-vite/template-vue-ts/README.md index 30b15e215a24b7..ef72fd52424558 100644 --- a/packages/create-vite/template-vue-ts/README.md +++ b/packages/create-vite/template-vue-ts/README.md @@ -4,13 +4,15 @@ This template should help get you started developing with Vue 3 and TypeScript i ## Recommended IDE Setup -- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) +- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin). ## Type Support For `.vue` Imports in TS -Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps: +TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types. -1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled. -2. Reload the VS Code window by running `Developer: Reload Window` from the command palette. +If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps: -You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471). +1. Disable the built-in TypeScript Extension + 1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette + 2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)` +2. Reload the VSCode window by running `Developer: Reload Window` from the command palette. diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index faf2538aa00766..22da037ff791a7 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -12,9 +12,9 @@ "vue": "^3.2.45" }, "devDependencies": { - "@vitejs/plugin-vue": "^3.2.0", - "typescript": "^4.6.4", - "vite": "^3.2.4", - "vue-tsc": "^1.0.9" + "@vitejs/plugin-vue": "^4.0.0-beta.0", + "typescript": "^4.9.3", + "vite": "^4.0.0-beta.3", + "vue-tsc": "^1.0.11" } } diff --git a/packages/create-vite/template-vue-ts/src/App.vue b/packages/create-vite/template-vue-ts/src/App.vue index 76ebf08602f448..fb679f1d510fc0 100644 --- a/packages/create-vite/template-vue-ts/src/App.vue +++ b/packages/create-vite/template-vue-ts/src/App.vue @@ -1,6 +1,4 @@ diff --git a/packages/create-vite/template-vue-ts/src/vite-env.d.ts b/packages/create-vite/template-vue-ts/src/vite-env.d.ts index 323c78a6cd8507..11f02fe2a0061d 100644 --- a/packages/create-vite/template-vue-ts/src/vite-env.d.ts +++ b/packages/create-vite/template-vue-ts/src/vite-env.d.ts @@ -1,7 +1 @@ /// - -declare module '*.vue' { - import type { DefineComponent } from 'vue' - const component: DefineComponent<{}, {}, any> - export default component -} diff --git a/packages/create-vite/template-vue-ts/vite.config.ts b/packages/create-vite/template-vue-ts/vite.config.ts index 315212d69a7ba5..05c17402a4a92b 100644 --- a/packages/create-vite/template-vue-ts/vite.config.ts +++ b/packages/create-vite/template-vue-ts/vite.config.ts @@ -3,5 +3,5 @@ import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [vue()] + plugins: [vue()], }) diff --git a/packages/create-vite/template-vue/.vscode/extensions.json b/packages/create-vite/template-vue/.vscode/extensions.json index a7cea0b0678120..c0a6e5a48110e4 100644 --- a/packages/create-vite/template-vue/.vscode/extensions.json +++ b/packages/create-vite/template-vue/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["Vue.volar"] + "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] } diff --git a/packages/create-vite/template-vue/README.md b/packages/create-vite/template-vue/README.md index 02124a7a0a92bc..e62e093e7092d1 100644 --- a/packages/create-vite/template-vue/README.md +++ b/packages/create-vite/template-vue/README.md @@ -4,4 +4,4 @@ This template should help get you started developing with Vue 3 in Vite. The tem ## Recommended IDE Setup -- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) +- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin). diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index 1b3046b597b244..57e62a92a3ca27 100644 --- a/packages/create-vite/template-vue/package.json +++ b/packages/create-vite/template-vue/package.json @@ -12,7 +12,7 @@ "vue": "^3.2.45" }, "devDependencies": { - "@vitejs/plugin-vue": "^3.2.0", - "vite": "^3.2.4" + "@vitejs/plugin-vue": "^4.0.0-beta.0", + "vite": "^4.0.0-beta.3" } } diff --git a/packages/create-vite/template-vue/src/App.vue b/packages/create-vite/template-vue/src/App.vue index 6febdb7581ea83..3f9b55cb79605c 100644 --- a/packages/create-vite/template-vue/src/App.vue +++ b/packages/create-vite/template-vue/src/App.vue @@ -1,6 +1,4 @@ diff --git a/packages/create-vite/template-vue/src/components/HelloWorld.vue b/packages/create-vite/template-vue/src/components/HelloWorld.vue index 91f9bfcbcb305d..d3c3f15cde9911 100644 --- a/packages/create-vite/template-vue/src/components/HelloWorld.vue +++ b/packages/create-vite/template-vue/src/components/HelloWorld.vue @@ -2,7 +2,7 @@ import { ref } from 'vue' defineProps({ - msg: String + msg: String, }) const count = ref(0) diff --git a/packages/create-vite/template-vue/vite.config.js b/packages/create-vite/template-vue/vite.config.js index 315212d69a7ba5..05c17402a4a92b 100644 --- a/packages/create-vite/template-vue/vite.config.js +++ b/packages/create-vite/template-vue/vite.config.js @@ -3,5 +3,5 @@ import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [vue()] + plugins: [vue()], }) diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index ab8fc009c665b6..59e4c99c38787d 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,15 @@ +## 3.0.0-alpha.0 (2022-11-30) + +* fix: support polyfill import paths containing an escaping char (e.g. '\') (#10859) ([7ac2535](https://github.com/vitejs/vite/commit/7ac2535)), closes [#10859](https://github.com/vitejs/vite/issues/10859) +* fix(deps): update all non-major dependencies (#10804) ([f686afa](https://github.com/vitejs/vite/commit/f686afa)), closes [#10804](https://github.com/vitejs/vite/issues/10804) +* fix(deps): update all non-major dependencies (#11091) ([073a4bf](https://github.com/vitejs/vite/commit/073a4bf)), closes [#11091](https://github.com/vitejs/vite/issues/11091) +* chore(deps): update all non-major dependencies (#10910) ([f6ad607](https://github.com/vitejs/vite/commit/f6ad607)), closes [#10910](https://github.com/vitejs/vite/issues/10910) +* chore(deps): update all non-major dependencies (#11006) ([96f2e98](https://github.com/vitejs/vite/commit/96f2e98)), closes [#11006](https://github.com/vitejs/vite/issues/11006) +* feat: align default chunk and asset file names with rollup (#10927) ([cc2adb3](https://github.com/vitejs/vite/commit/cc2adb3)), closes [#10927](https://github.com/vitejs/vite/issues/10927) +* feat: rollup 3 (#9870) ([beb7166](https://github.com/vitejs/vite/commit/beb7166)), closes [#9870](https://github.com/vitejs/vite/issues/9870) + + + ## 2.3.1 (2022-11-07) * chore(deps): update all non-major dependencies (#10725) ([22cfad8](https://github.com/vitejs/vite/commit/22cfad8)), closes [#10725](https://github.com/vitejs/vite/issues/10725) diff --git a/packages/plugin-legacy/README.md b/packages/plugin-legacy/README.md index 708ba6059561f1..2b12552632a5d3 100644 --- a/packages/plugin-legacy/README.md +++ b/packages/plugin-legacy/README.md @@ -21,9 +21,9 @@ import legacy from '@vitejs/plugin-legacy' export default { plugins: [ legacy({ - targets: ['defaults', 'not IE 11'] - }) - ] + targets: ['defaults', 'not IE 11'], + }), + ], } ``` @@ -104,9 +104,9 @@ npm add -D terser modernPolyfills: [ /* ... */ ], - renderLegacyChunks: false - }) - ] + renderLegacyChunks: false, + }), + ], } ``` @@ -141,9 +141,9 @@ export default { plugins: [ legacy({ polyfills: ['es.promise.finally', 'es/map', 'es/set'], - modernPolyfills: ['es.promise.finally'] - }) - ] + modernPolyfills: ['es.promise.finally'], + }), + ], } ``` diff --git a/packages/plugin-legacy/build.config.ts b/packages/plugin-legacy/build.config.ts index 12afbbc54d1efd..db325ecfa3b0a8 100644 --- a/packages/plugin-legacy/build.config.ts +++ b/packages/plugin-legacy/build.config.ts @@ -6,6 +6,6 @@ export default defineBuildConfig({ declaration: true, rollup: { emitCJS: true, - inlineDependencies: true - } + inlineDependencies: true, + }, }) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index ca67079152314e..c7a62b305d9003 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-legacy", - "version": "2.3.1", + "version": "3.0.0-alpha.0", "license": "MIT", "author": "Evan You", "files": [ @@ -35,9 +35,9 @@ }, "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme", "dependencies": { - "@babel/standalone": "^7.20.4", + "@babel/standalone": "^7.20.6", "core-js": "^3.26.1", - "magic-string": "^0.26.7", + "magic-string": "^0.27.0", "regenerator-runtime": "^0.13.11", "systemjs": "^6.13.0" }, @@ -46,7 +46,7 @@ "vite": "^3.0.0" }, "devDependencies": { - "@babel/core": "^7.20.2", + "@babel/core": "^7.20.5", "picocolors": "^1.0.0", "vite": "workspace:*" } diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index b131727849f1f0..41f76470d0b13a 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -9,14 +9,14 @@ import type { BuildOptions, HtmlTagDescriptor, Plugin, - ResolvedConfig + ResolvedConfig, } from 'vite' import type { NormalizedOutputOptions, OutputBundle, OutputOptions, PreRenderedChunk, - RenderedChunk + RenderedChunk, } from 'rollup' import type { PluginItem as BabelPlugin } from '@babel/core' import colors from 'picocolors' @@ -40,7 +40,7 @@ function toOutputFilePathInHtml( hostId: string, hostType: 'js' | 'css' | 'html', config: ResolvedConfig, - toRelative: (filename: string, importer: string) => string + toRelative: (filename: string, importer: string) => string, ): string { const { renderBuiltUrl } = config.experimental let relative = config.base === '' || config.base === './' @@ -49,12 +49,12 @@ function toOutputFilePathInHtml( hostId, hostType, type, - ssr: !!config.build.ssr + ssr: !!config.build.ssr, }) if (typeof result === 'object') { if (result.runtime) { throw new Error( - `{ runtime: "${result.runtime}" } is not supported for assets in ${hostType} files: ${filename}` + `{ runtime: "${result.runtime}" } is not supported for assets in ${hostType} files: ${filename}`, ) } if (typeof result.relative === 'boolean') { @@ -76,7 +76,7 @@ function getBaseInHTML(urlRelativePath: string, config: ResolvedConfig) { return config.base === './' || config.base === '' ? path.posix.join( path.posix.relative(urlRelativePath, '').slice(0, -2), - './' + './', ) : config.base } @@ -84,7 +84,7 @@ function getBaseInHTML(urlRelativePath: string, config: ResolvedConfig) { function toAssetPathFromHtml( filename: string, htmlPath: string, - config: ResolvedConfig + config: ResolvedConfig, ): string { const relativeUrlPath = normalizePath(path.relative(config.root, htmlPath)) const toRelative = (filename: string, hostId: string) => @@ -95,7 +95,7 @@ function toAssetPathFromHtml( htmlPath, 'html', config, - toRelative + toRelative, ) } @@ -136,7 +136,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { if (Array.isArray(options.modernPolyfills)) { options.modernPolyfills.forEach((i) => { modernPolyfills.add( - i.includes('/') ? `core-js/${i}` : `core-js/modules/${i}.js` + i.includes('/') ? `core-js/${i}` : `core-js/modules/${i}.js`, ) }) } @@ -146,7 +146,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { legacyPolyfills.add(`regenerator-runtime/runtime.js`) } else { legacyPolyfills.add( - i.includes('/') ? `core-js/${i}` : `core-js/modules/${i}.js` + i.includes('/') ? `core-js/${i}` : `core-js/modules/${i}.js`, ) } }) @@ -186,7 +186,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { 'edge79', 'firefox67', 'chrome64', - 'safari11.1' + 'safari11.1', ] } } @@ -196,19 +196,19 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { 'import.meta.env.LEGACY': env.command === 'serve' || config.build?.ssr ? false - : legacyEnvVarMarker - } + : legacyEnvVarMarker, + }, } }, configResolved(config) { if (overriddenBuildTarget) { config.logger.warn( colors.yellow( - `plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.` - ) + `plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.`, + ), ) } - } + }, } const legacyGenerateBundlePlugin: Plugin = { @@ -227,7 +227,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { isDebug && console.log( `[@vitejs/plugin-legacy] modern polyfills:`, - modernPolyfills + modernPolyfills, ) await buildPolyfillChunk( config.mode, @@ -237,7 +237,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { config.build, 'es', opts, - true + true, ) return } @@ -253,13 +253,13 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { await detectPolyfills( `Promise.resolve(); Promise.all();`, targets, - legacyPolyfills + legacyPolyfills, ) isDebug && console.log( `[@vitejs/plugin-legacy] legacy polyfills:`, - legacyPolyfills + legacyPolyfills, ) await buildPolyfillChunk( @@ -272,10 +272,10 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { config.build, 'iife', opts, - options.externalSystemJS + options.externalSystemJS, ) } - } + }, } const legacyPostPlugin: Plugin = { @@ -298,7 +298,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { | string | ((chunkInfo: PreRenderedChunk) => string) | undefined, - defaultFileName = '[name]-legacy-[hash].js' + defaultFileName = '[name]-legacy-[hash].js', ): string | ((chunkInfo: PreRenderedChunk) => string) => { if (!fileNames) { return path.posix.join(config.build.assetsDir, defaultFileName) @@ -321,13 +321,13 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { } const createLegacyOutput = ( - options: OutputOptions = {} + options: OutputOptions = {}, ): OutputOptions => { return { ...options, format: 'system', entryFileNames: getLegacyOutputFileName(options.entryFileNames), - chunkFileNames: getLegacyOutputFileName(options.chunkFileNames) + chunkFileNames: getLegacyOutputFileName(options.chunkFileNames), } } @@ -367,7 +367,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { ms.overwrite( match.index, match.index + legacyEnvVarMarker.length, - `false` + `false`, ) } } @@ -375,11 +375,11 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { if (config.build.sourcemap) { return { code: ms.toString(), - map: ms.generateMap({ hires: true }) + map: ms.generateMap({ hires: true }), } } return { - code: ms.toString() + code: ms.toString(), } } @@ -424,18 +424,18 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { plugins: [ recordAndRemovePolyfillBabelPlugin(legacyPolyfills), replaceLegacyEnvBabelPlugin(), - wrapIIFEBabelPlugin() - ] - }) + wrapIIFEBabelPlugin(), + ], + }), ], [ 'env', createBabelPresetEnvOptions(targets, { needPolyfills, - ignoreBrowserslistConfig: options.ignoreBrowserslistConfig - }) - ] - ] + ignoreBrowserslistConfig: options.ignoreBrowserslistConfig, + }), + ], + ], }) if (code) return { code, map } @@ -457,7 +457,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { // 1. inject modern polyfills const modernPolyfillFilename = facadeToModernPolyfillMap.get( - chunk.facadeModuleId + chunk.facadeModuleId, ) if (modernPolyfillFilename) { @@ -469,13 +469,13 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { src: toAssetPathFromHtml( modernPolyfillFilename, chunk.facadeModuleId!, - config - ) - } + config, + ), + }, }) } else if (modernPolyfills.size) { throw new Error( - `No corresponding modern polyfill chunk found for ${htmlFilename}` + `No corresponding modern polyfill chunk found for ${htmlFilename}`, ) } @@ -488,12 +488,12 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { tag: 'script', attrs: { nomodule: true }, children: safari10NoModuleFix, - injectTo: 'body' + injectTo: 'body', }) // 3. inject legacy polyfills const legacyPolyfillFilename = facadeToLegacyPolyfillMap.get( - chunk.facadeModuleId + chunk.facadeModuleId, ) if (legacyPolyfillFilename) { tags.push({ @@ -505,20 +505,20 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { src: toAssetPathFromHtml( legacyPolyfillFilename, chunk.facadeModuleId!, - config - ) + config, + ), }, - injectTo: 'body' + injectTo: 'body', }) } else if (legacyPolyfills.size) { throw new Error( - `No corresponding legacy polyfill chunk found for ${htmlFilename}` + `No corresponding legacy polyfill chunk found for ${htmlFilename}`, ) } // 4. inject legacy entry const legacyEntryFilename = facadeToLegacyChunkMap.get( - chunk.facadeModuleId + chunk.facadeModuleId, ) if (legacyEntryFilename) { // `assets/foo.js` means importing "named register" in SystemJS @@ -534,15 +534,15 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { 'data-src': toAssetPathFromHtml( legacyEntryFilename, chunk.facadeModuleId!, - config - ) + config, + ), }, children: systemJSInlineCode, - injectTo: 'body' + injectTo: 'body', }) } else { throw new Error( - `No corresponding legacy entry chunk found for ${htmlFilename}` + `No corresponding legacy entry chunk found for ${htmlFilename}`, ) } @@ -552,19 +552,19 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { tag: 'script', attrs: { type: 'module' }, children: detectModernBrowserCode, - injectTo: 'head' + injectTo: 'head', }) tags.push({ tag: 'script', attrs: { type: 'module' }, children: dynamicFallbackInlineCode, - injectTo: 'head' + injectTo: 'head', }) } return { html, - tags + tags, } }, @@ -581,7 +581,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { } } } - } + }, } return [legacyConfigPlugin, legacyGenerateBundlePlugin, legacyPostPlugin] @@ -590,7 +590,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { export async function detectPolyfills( code: string, targets: any, - list: Set + list: Set, ): Promise { const babel = await loadBabel() const { ast } = babel.transform(code, { @@ -600,9 +600,11 @@ export async function detectPolyfills( presets: [ [ 'env', - createBabelPresetEnvOptions(targets, { ignoreBrowserslistConfig: true }) - ] - ] + createBabelPresetEnvOptions(targets, { + ignoreBrowserslistConfig: true, + }), + ], + ], }) for (const node of ast!.program.body) { if (node.type === 'ImportDeclaration') { @@ -621,8 +623,8 @@ function createBabelPresetEnvOptions( targets: any, { needPolyfills = true, - ignoreBrowserslistConfig - }: { needPolyfills?: boolean; ignoreBrowserslistConfig?: boolean } + ignoreBrowserslistConfig, + }: { needPolyfills?: boolean; ignoreBrowserslistConfig?: boolean }, ) { return { targets, @@ -633,11 +635,11 @@ function createBabelPresetEnvOptions( corejs: needPolyfills ? { version: _require('core-js/package.json').version, - proposals: false + proposals: false, } : undefined, shippedProposals: true, - ignoreBrowserslistConfig + ignoreBrowserslistConfig, } } @@ -649,7 +651,7 @@ async function buildPolyfillChunk( buildOptions: BuildOptions, format: 'iife' | 'es', rollupOutputOptions: NormalizedOutputOptions, - excludeSystemJS?: boolean + excludeSystemJS?: boolean, ) { let { minify, assetsDir } = buildOptions minify = minify ? 'terser' : false @@ -666,13 +668,13 @@ async function buildPolyfillChunk( assetsDir, rollupOptions: { input: { - polyfills: polyfillId + polyfills: polyfillId, }, output: { format, - entryFileNames: rollupOutputOptions.entryFileNames - } - } + entryFileNames: rollupOutputOptions.entryFileNames, + }, + }, }, // Don't run esbuild for transpilation or minification // because we don't want to transpile code. @@ -683,9 +685,9 @@ async function buildPolyfillChunk( // This limits the input code not to include es2015+ codes. // But core-js is the only dependency which includes commonjs code // and core-js doesn't include es2015+ codes. - target: 'es5' - } - } + target: 'es5', + }, + }, }) const _polyfillChunk = Array.isArray(res) ? res[0] : res if (!('output' in _polyfillChunk)) return @@ -708,7 +710,7 @@ const polyfillId = '\0vite/legacy-polyfills' function polyfillsPlugin( imports: Set, - excludeSystemJS?: boolean + excludeSystemJS?: boolean, ): Plugin { return { name: 'vite:legacy-polyfills', @@ -724,7 +726,7 @@ function polyfillsPlugin( (excludeSystemJS ? '' : `import "systemjs/dist/s.min.js";`) ) } - } + }, } } @@ -734,11 +736,11 @@ function isLegacyChunk(chunk: RenderedChunk, options: NormalizedOutputOptions) { function isLegacyBundle( bundle: OutputBundle, - options: NormalizedOutputOptions + options: NormalizedOutputOptions, ) { if (options.format === 'system') { const entryChunk = Object.values(bundle).find( - (output) => output.type === 'chunk' && output.isEntry + (output) => output.type === 'chunk' && output.isEntry, ) return !!entryChunk && entryChunk.fileName.includes('-legacy') @@ -748,7 +750,7 @@ function isLegacyBundle( } function recordAndRemovePolyfillBabelPlugin( - polyfills: Set + polyfills: Set, ): BabelPlugin { return ({ types: t }): BabelPlugin => ({ name: 'vite-remove-polyfill-import', @@ -760,7 +762,7 @@ function recordAndRemovePolyfillBabelPlugin( p.remove() } }) - } + }, }) } @@ -772,8 +774,8 @@ function replaceLegacyEnvBabelPlugin(): BabelPlugin { if (path.node.name === legacyEnvVarMarker) { path.replaceWith(t.booleanLiteral(true)) } - } - } + }, + }, }) } @@ -788,7 +790,7 @@ function wrapIIFEBabelPlugin(): BabelPlugin { this.isWrapped = true path.replaceWith(t.program(buildIIFE({ body: path.node.body }))) } - } + }, } } } @@ -797,7 +799,7 @@ export const cspHashes = [ createHash('sha256').update(safari10NoModuleFix).digest('base64'), createHash('sha256').update(systemJSInlineCode).digest('base64'), createHash('sha256').update(detectModernBrowserCode).digest('base64'), - createHash('sha256').update(dynamicFallbackInlineCode).digest('base64') + createHash('sha256').update(dynamicFallbackInlineCode).digest('base64'), ] export default viteLegacyPlugin diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md deleted file mode 100644 index 75c0af1b2abf0b..00000000000000 --- a/packages/plugin-react/CHANGELOG.md +++ /dev/null @@ -1,297 +0,0 @@ -## 3.0.0-alpha.1 (2022-11-15) - -* fix(plugin-react): jsxDev is not a function when is set NODE_ENV in env files (#10861) ([be1ba4a](https://github.com/vitejs/vite/commit/be1ba4a)), closes [#10861](https://github.com/vitejs/vite/issues/10861) -* perf: regexp perf issues, refactor regexp stylistic issues (#10905) ([fc007df](https://github.com/vitejs/vite/commit/fc007df)), closes [#10905](https://github.com/vitejs/vite/issues/10905) - - - -## 3.0.0-alpha.0 (2022-11-08) - -* feat!: transform jsx with esbuild instead of babel (#9590) ([f677b62](https://github.com/vitejs/vite/commit/f677b62)), closes [#9590](https://github.com/vitejs/vite/issues/9590) -* fix(deps): update all non-major dependencies (#10804) ([f686afa](https://github.com/vitejs/vite/commit/f686afa)), closes [#10804](https://github.com/vitejs/vite/issues/10804) - - - -## 2.2.0 (2022-10-26) - -* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) -* fix(plugin-react): update `package.json` (#10479) ([7f45eb5](https://github.com/vitejs/vite/commit/7f45eb5)), closes [#10479](https://github.com/vitejs/vite/issues/10479) -* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) - - - -## 2.2.0-beta.0 (2022-10-05) - -* fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) -* fix(deps): update all non-major dependencies (#10160) ([6233c83](https://github.com/vitejs/vite/commit/6233c83)), closes [#10160](https://github.com/vitejs/vite/issues/10160) -* fix(deps): update all non-major dependencies (#10316) ([a38b450](https://github.com/vitejs/vite/commit/a38b450)), closes [#10316](https://github.com/vitejs/vite/issues/10316) -* fix(deps): update all non-major dependencies (#9985) ([855f2f0](https://github.com/vitejs/vite/commit/855f2f0)), closes [#9985](https://github.com/vitejs/vite/issues/9985) -* fix(react): conditionally self-accept fast-refresh HMR (#10239) ([e976b06](https://github.com/vitejs/vite/commit/e976b06)), closes [#10239](https://github.com/vitejs/vite/issues/10239) -* feat: add `throwIfNamespace` option for custom JSX runtime (#9571) ([f842f74](https://github.com/vitejs/vite/commit/f842f74)), closes [#9571](https://github.com/vitejs/vite/issues/9571) -* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) - - - -## 2.1.0 (2022-09-05) - -* fix(plugin-react): duplicate __self prop and __source prop (#9387) ([c89de3a](https://github.com/vitejs/vite/commit/c89de3a)), closes [#9387](https://github.com/vitejs/vite/issues/9387) - - - -## 2.1.0-beta.0 (2022-08-29) - -* docs: fix typo (#9855) ([583f185](https://github.com/vitejs/vite/commit/583f185)), closes [#9855](https://github.com/vitejs/vite/issues/9855) -* fix: add `react` to `optimizeDeps` (#9056) ([bc4a627](https://github.com/vitejs/vite/commit/bc4a627)), closes [#9056](https://github.com/vitejs/vite/issues/9056) -* fix(deps): update all non-major dependencies (#9888) ([e35a58b](https://github.com/vitejs/vite/commit/e35a58b)), closes [#9888](https://github.com/vitejs/vite/issues/9888) - - - -## 2.0.1 (2022-08-11) - -* fix: don't count class declarations as react fast refresh boundry (fixes #3675) (#8887) ([5a18284](https://github.com/vitejs/vite/commit/5a18284)), closes [#3675](https://github.com/vitejs/vite/issues/3675) [#8887](https://github.com/vitejs/vite/issues/8887) -* fix: mention that Node.js 13/15 support is dropped (fixes #9113) (#9116) ([2826303](https://github.com/vitejs/vite/commit/2826303)), closes [#9113](https://github.com/vitejs/vite/issues/9113) [#9116](https://github.com/vitejs/vite/issues/9116) -* fix(deps): update all non-major dependencies (#9176) ([31d3b70](https://github.com/vitejs/vite/commit/31d3b70)), closes [#9176](https://github.com/vitejs/vite/issues/9176) -* fix(deps): update all non-major dependencies (#9575) ([8071325](https://github.com/vitejs/vite/commit/8071325)), closes [#9575](https://github.com/vitejs/vite/issues/9575) -* fix(plugin-react): wrong substitution causes `React is not defined` (#9386) ([8a5b575](https://github.com/vitejs/vite/commit/8a5b575)), closes [#9386](https://github.com/vitejs/vite/issues/9386) -* docs: fix server options link (#9242) ([29db3ea](https://github.com/vitejs/vite/commit/29db3ea)), closes [#9242](https://github.com/vitejs/vite/issues/9242) - - - -## 2.0.0 (2022-07-13) - -* chore: 3.0 release notes and bump peer deps (#9072) ([427ba26](https://github.com/vitejs/vite/commit/427ba26)), closes [#9072](https://github.com/vitejs/vite/issues/9072) -* fix(react): sourcemap incorrect warning and classic runtime sourcemap (#9006) ([bdae7fa](https://github.com/vitejs/vite/commit/bdae7fa)), closes [#9006](https://github.com/vitejs/vite/issues/9006) - - - -## 2.0.0-beta.1 (2022-07-06) - -* fix(deps): update all non-major dependencies (#8802) ([a4a634d](https://github.com/vitejs/vite/commit/a4a634d)), closes [#8802](https://github.com/vitejs/vite/issues/8802) -* fix(plugin-react): pass correct context to runPluginOverrides (#8809) ([09742e2](https://github.com/vitejs/vite/commit/09742e2)), closes [#8809](https://github.com/vitejs/vite/issues/8809) -* fix(plugin-react): return code if should skip in transform (fix #7586) (#8676) ([206e22a](https://github.com/vitejs/vite/commit/206e22a)), closes [#7586](https://github.com/vitejs/vite/issues/7586) [#8676](https://github.com/vitejs/vite/issues/8676) -* chore: use `tsx` directly instead of indirect `esno` (#8773) ([f018f13](https://github.com/vitejs/vite/commit/f018f13)), closes [#8773](https://github.com/vitejs/vite/issues/8773) - - - -## 2.0.0-beta.0 (2022-06-21) - -* feat: bump minimum node version to 14.18.0 (#8662) ([8a05432](https://github.com/vitejs/vite/commit/8a05432)), closes [#8662](https://github.com/vitejs/vite/issues/8662) -* feat: experimental.buildAdvancedBaseOptions (#8450) ([8ef7333](https://github.com/vitejs/vite/commit/8ef7333)), closes [#8450](https://github.com/vitejs/vite/issues/8450) -* feat: expose createFilter util (#8562) ([c5c424a](https://github.com/vitejs/vite/commit/c5c424a)), closes [#8562](https://github.com/vitejs/vite/issues/8562) -* chore: update major deps (#8572) ([0e20949](https://github.com/vitejs/vite/commit/0e20949)), closes [#8572](https://github.com/vitejs/vite/issues/8572) -* chore: use node prefix (#8309) ([60721ac](https://github.com/vitejs/vite/commit/60721ac)), closes [#8309](https://github.com/vitejs/vite/issues/8309) -* chore(deps): update all non-major dependencies (#8669) ([628863d](https://github.com/vitejs/vite/commit/628863d)), closes [#8669](https://github.com/vitejs/vite/issues/8669) -* fix(plugin-react): set `this-is-undefined-in-esm` to silent if classic runtime (#8674) ([f0aecba](https://github.com/vitejs/vite/commit/f0aecba)), closes [#8674](https://github.com/vitejs/vite/issues/8674) - - - -## 2.0.0-alpha.3 (2022-06-12) - -* fix(deps): update all non-major dependencies (#8391) ([842f995](https://github.com/vitejs/vite/commit/842f995)), closes [#8391](https://github.com/vitejs/vite/issues/8391) -* fix(plugin-react): apply manual runtime interop (#8546) ([f09299c](https://github.com/vitejs/vite/commit/f09299c)), closes [#8546](https://github.com/vitejs/vite/issues/8546) -* fix(plugin-react): support import namespace in `parseReactAlias` (#5313) ([05b91cd](https://github.com/vitejs/vite/commit/05b91cd)), closes [#5313](https://github.com/vitejs/vite/issues/5313) -* refactor: remove hooks ssr param support (#8491) ([f59adf8](https://github.com/vitejs/vite/commit/f59adf8)), closes [#8491](https://github.com/vitejs/vite/issues/8491) - - - -## 2.0.0-alpha.2 (2022-05-26) - -* feat: non-blocking esbuild optimization at build time (#8280) ([909cf9c](https://github.com/vitejs/vite/commit/909cf9c)), closes [#8280](https://github.com/vitejs/vite/issues/8280) -* feat(plugin-react): allow options.babel to be a function (#6238) ([f4d6262](https://github.com/vitejs/vite/commit/f4d6262)), closes [#6238](https://github.com/vitejs/vite/issues/6238) -* fix(deps): update all non-major dependencies (#8281) ([c68db4d](https://github.com/vitejs/vite/commit/c68db4d)), closes [#8281](https://github.com/vitejs/vite/issues/8281) -* fix(plugin-react): broken optimized deps dir check (#8255) ([9e2a1ea](https://github.com/vitejs/vite/commit/9e2a1ea)), closes [#8255](https://github.com/vitejs/vite/issues/8255) -* chore: use `esno` to replace `ts-node` (#8162) ([c18a5f3](https://github.com/vitejs/vite/commit/c18a5f3)), closes [#8162](https://github.com/vitejs/vite/issues/8162) - - - -## 2.0.0-alpha.1 (2022-05-19) - -* fix: rewrite CJS specific funcs/vars in plugins (#8227) ([9baa70b](https://github.com/vitejs/vite/commit/9baa70b)), closes [#8227](https://github.com/vitejs/vite/issues/8227) -* build!: bump targets (#8045) ([66efd69](https://github.com/vitejs/vite/commit/66efd69)), closes [#8045](https://github.com/vitejs/vite/issues/8045) -* chore: enable `import/no-duplicates` eslint rule (#8199) ([11243de](https://github.com/vitejs/vite/commit/11243de)), closes [#8199](https://github.com/vitejs/vite/issues/8199) - - - -## 2.0.0-alpha.0 (2022-05-13) - -* chore: restore-jsx.spec.ts lint (#8004) ([f1af941](https://github.com/vitejs/vite/commit/f1af941)), closes [#8004](https://github.com/vitejs/vite/issues/8004) -* chore: revert vitejs/vite#8152 (#8161) ([85b8b55](https://github.com/vitejs/vite/commit/85b8b55)), closes [vitejs/vite#8152](https://github.com/vitejs/vite/issues/8152) [#8161](https://github.com/vitejs/vite/issues/8161) -* chore: update plugins peer deps ([d57c23c](https://github.com/vitejs/vite/commit/d57c23c)) -* chore: use `unbuild` to bundle plugins (#8139) ([638b168](https://github.com/vitejs/vite/commit/638b168)), closes [#8139](https://github.com/vitejs/vite/issues/8139) -* chore(deps): use `esno` to replace `ts-node` (#8152) ([2363bd3](https://github.com/vitejs/vite/commit/2363bd3)), closes [#8152](https://github.com/vitejs/vite/issues/8152) -* chore(lint): sort for imports (#8113) ([43a58dd](https://github.com/vitejs/vite/commit/43a58dd)), closes [#8113](https://github.com/vitejs/vite/issues/8113) -* chore(plugin-react): add vite peer dep (#8083) ([2d978f7](https://github.com/vitejs/vite/commit/2d978f7)), closes [#8083](https://github.com/vitejs/vite/issues/8083) -* fix: use Vitest for unit testing, clean regex bug (#8040) ([63cd53d](https://github.com/vitejs/vite/commit/63cd53d)), closes [#8040](https://github.com/vitejs/vite/issues/8040) -* refactor: remove deprecated api for 3.0 (#5868) ([b5c3709](https://github.com/vitejs/vite/commit/b5c3709)), closes [#5868](https://github.com/vitejs/vite/issues/5868) -* build!: remove node v12 support (#7833) ([eeac2d2](https://github.com/vitejs/vite/commit/eeac2d2)), closes [#7833](https://github.com/vitejs/vite/issues/7833) - - - -## 1.3.2 (2022-05-02) - -* fix(plugin-react): React is not defined when component name is lowercase (#6838) ([bf40e5c](https://github.com/vitejs/vite/commit/bf40e5c)), closes [#6838](https://github.com/vitejs/vite/issues/6838) -* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) -* chore(deps): update all non-major dependencies (#7949) ([b877d30](https://github.com/vitejs/vite/commit/b877d30)), closes [#7949](https://github.com/vitejs/vite/issues/7949) - - - -## 1.3.1 (2022-04-13) - -* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) -* chore: fix term cases (#7553) ([c296130](https://github.com/vitejs/vite/commit/c296130)), closes [#7553](https://github.com/vitejs/vite/issues/7553) -* chore(deps): update all non-major dependencies (#7603) ([fc51a15](https://github.com/vitejs/vite/commit/fc51a15)), closes [#7603](https://github.com/vitejs/vite/issues/7603) - - - -## 1.3.0 (2022-03-30) - -* feat(plugin-react): adding jsxPure option (#7088) ([d451435](https://github.com/vitejs/vite/commit/d451435)), closes [#7088](https://github.com/vitejs/vite/issues/7088) -* fix(deps): update all non-major dependencies (#6782) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e)), closes [#6782](https://github.com/vitejs/vite/issues/6782) -* fix(deps): update all non-major dependencies (#7392) ([b63fc3b](https://github.com/vitejs/vite/commit/b63fc3b)), closes [#7392](https://github.com/vitejs/vite/issues/7392) -* chore: fix publish, build vite before plugin-react and plugin-vue (#6988) ([620a9bd](https://github.com/vitejs/vite/commit/620a9bd)), closes [#6988](https://github.com/vitejs/vite/issues/6988) -* chore(deps): update all non-major dependencies (#6905) ([839665c](https://github.com/vitejs/vite/commit/839665c)), closes [#6905](https://github.com/vitejs/vite/issues/6905) -* workflow: separate version bumping and publishing on release (#6879) ([fe8ef39](https://github.com/vitejs/vite/commit/fe8ef39)), closes [#6879](https://github.com/vitejs/vite/issues/6879) - - - -# [1.2.0](https://github.com/vitejs/vite/compare/plugin-react@1.1.4...plugin-react@1.2.0) (2022-02-09) - - -### Features - -* **plugin-react:** ensure `overrides` array exists before `api.reactBabel` hooks are called ([#6750](https://github.com/vitejs/vite/issues/6750)) ([104bdb5](https://github.com/vitejs/vite/commit/104bdb5b5e44e79bf3456cabe15f3753f7c1ef28)) - - - -## [1.1.4](https://github.com/vitejs/vite/compare/plugin-react@1.1.3...plugin-react@1.1.4) (2022-01-04) - - -### Bug Fixes - -* **plugin-react:** check for import React statement in .js files ([#6320](https://github.com/vitejs/vite/issues/6320)) ([bd9e97b](https://github.com/vitejs/vite/commit/bd9e97bd1b9156059b78b531871a12f6f47c04b1)), closes [#6148](https://github.com/vitejs/vite/issues/6148) [#6148](https://github.com/vitejs/vite/issues/6148) -* **plugin-react:** restore-jsx bug when component name is lowercase ([#6110](https://github.com/vitejs/vite/issues/6110)) ([ce65c56](https://github.com/vitejs/vite/commit/ce65c567a64fad3be4209cbd1132e62e905fe349)) - - -### Features - -* **plugin-react:** check for `api.reactBabel` on other plugins ([#5454](https://github.com/vitejs/vite/issues/5454)) ([2ab41b3](https://github.com/vitejs/vite/commit/2ab41b3184d2452be4fa0b427f05c791311644aa)) - - - -## [1.1.3](https://github.com/vitejs/vite/compare/plugin-react@1.1.2...plugin-react@1.1.3) (2021-12-13) - - -### Bug Fixes - -* **plugin-react:** only detect preamble in hmr context ([#6096](https://github.com/vitejs/vite/issues/6096)) ([8735294](https://github.com/vitejs/vite/commit/8735294055ce16308a6b8302eba4538f4a2931d0)) - - - -## [1.1.2](https://github.com/vitejs/vite/compare/plugin-react@1.1.1...plugin-react@1.1.2) (2021-12-13) - - -### Bug Fixes - -* ignore babel config when running restore-jsx ([#6047](https://github.com/vitejs/vite/issues/6047)) ([9c2843c](https://github.com/vitejs/vite/commit/9c2843cf0506844ee32f042a04c22c440434df2a)) - - - -## [1.1.1](https://github.com/vitejs/vite/compare/plugin-react@1.1.0...plugin-react@1.1.1) (2021-12-07) - - - -# [1.1.0](https://github.com/vitejs/vite/compare/plugin-react@1.1.0-beta.1...plugin-react@1.1.0) (2021-11-22) - - - -# [1.1.0-beta.1](https://github.com/vitejs/vite/compare/plugin-react@1.1.0-beta.0...plugin-react@1.1.0-beta.1) (2021-11-19) - - -### Bug Fixes - -* **plugin-react:** apply `babel.plugins` to project files only ([#5255](https://github.com/vitejs/vite/issues/5255)) ([377d0be](https://github.com/vitejs/vite/commit/377d0be5cf85a50240e160beaaafda77b7199452)) -* **plugin-react:** remove querystring from sourcemap filename ([#5760](https://github.com/vitejs/vite/issues/5760)) ([d93a9fa](https://github.com/vitejs/vite/commit/d93a9fab8986f3659e79d7b0b065e99ef625a5dd)) -* **plugin-react:** restore usage of extension instead of id ([#5761](https://github.com/vitejs/vite/issues/5761)) ([59471b1](https://github.com/vitejs/vite/commit/59471b186612d3da0083543e23d660747d3287f3)) -* **plugin-react:** uncompiled JSX in linked pkgs ([#5669](https://github.com/vitejs/vite/issues/5669)) ([41a7c9c](https://github.com/vitejs/vite/commit/41a7c9ccfbc1a7bc60aec672056eac3966ddd036)) - - - -# [1.1.0-beta.0](https://github.com/vitejs/vite/compare/plugin-react@1.0.6...plugin-react@1.1.0-beta.0) (2021-10-28) - - -### Bug Fixes - -* **plugin-react:** avoid mangling the sourcemaps of virtual modules ([#5421](https://github.com/vitejs/vite/issues/5421)) ([8556ffe](https://github.com/vitejs/vite/commit/8556ffe3c59952d7e64565422bf433699e97756e)) - - - -## [1.0.6](https://github.com/vitejs/vite/compare/plugin-react@1.0.5...plugin-react@1.0.6) (2021-10-25) - - -### Bug Fixes - -* **plugin-react:** account for querystring in transform hook ([#5333](https://github.com/vitejs/vite/issues/5333)) ([13c3813](https://github.com/vitejs/vite/commit/13c381368caf8302a0c5b7cec07dfc0eb344bede)) - - - -## [1.0.5](https://github.com/vitejs/vite/compare/plugin-react@1.0.4...plugin-react@1.0.5) (2021-10-18) - - -### Bug Fixes - -* **plugin-react:** fix regex for react imports ([#5274](https://github.com/vitejs/vite/issues/5274)) ([00b3e4f](https://github.com/vitejs/vite/commit/00b3e4fe102652b2d92e76a05e8c7a5b766b1d03)) -* **plugin-react:** transform .mjs files ([#5314](https://github.com/vitejs/vite/issues/5314)) ([8ce2ea1](https://github.com/vitejs/vite/commit/8ce2ea17d51b80c660f2cdca7844d4fc6991baed)) - - - -## [1.0.4](https://github.com/vitejs/vite/compare/plugin-react@1.0.3...plugin-react@1.0.4) (2021-10-11) - - - -## [1.0.3](https://github.com/vitejs/vite/compare/plugin-react@1.0.2...plugin-react@1.0.3) (2021-10-11) - - -### Bug Fixes - -* **plugin-react:** turn off jsx for .ts ([#5198](https://github.com/vitejs/vite/issues/5198)) ([916f9d3](https://github.com/vitejs/vite/commit/916f9d3984d5e83f7cb869b3606a1f043a814b97)), closes [#5102](https://github.com/vitejs/vite/issues/5102) - - - -## [1.0.2](https://github.com/vitejs/vite/compare/plugin-react@1.0.1...plugin-react@1.0.2) (2021-10-05) - - -### Bug Fixes - -* **plugin-react:** respect `opts.fastRefresh` in viteBabel ([#5139](https://github.com/vitejs/vite/issues/5139)) ([5cf4e69](https://github.com/vitejs/vite/commit/5cf4e69cd3afc7f960e02072171c7c441747e8f0)) - - - -## [1.0.1](https://github.com/vitejs/vite/compare/plugin-react@1.0.0...plugin-react@1.0.1) (2021-09-22) - - -### Bug Fixes - -* **plugin-react:** inconsistent error warning ([#5031](https://github.com/vitejs/vite/issues/5031)) ([89ba8ce](https://github.com/vitejs/vite/commit/89ba8cedb8636968516bc38b37e1d2d5ed6234bb)) - - -### Features - -* **plugin-react:** pre-optimize jsx-dev-runtime ([#5036](https://github.com/vitejs/vite/issues/5036)) ([a34dd27](https://github.com/vitejs/vite/commit/a34dd2725e64fedf626e23ba9ced480f5465a59b)) - - - -# [1.0.0](https://github.com/vitejs/vite/compare/plugin-react@1.0.0-beta.0...plugin-react@1.0.0) (2021-09-22) - -See the [readme](https://github.com/aleclarson/vite/blob/f8129ce6e87684eb7a4edd8106351c5d98207d7b/packages/plugin-react/README.md#vitejsplugin-react-) for more information. - -- Support for [automatic JSX runtime](https://github.com/alloc/vite-react-jsx) -- Babel integration for both development and production builds -- Add `react` and `react-dom` to [`resolve.dedupe`](https://vitejs.dev/config/#resolve-dedupe) automatically - -Thanks to @aleclarson and @pengx17 for preparing this release! - -# Legacy - -Before `@vitejs/plugin-react`, there was `@vitejs/plugin-react-refresh`. - -See its changelog [here.](https://github.com/vitejs/vite/blob/b9e837a2aa2c1a7a8f93d4b19df9f72fd3c6fb09/packages/plugin-react-refresh/CHANGELOG.md) diff --git a/packages/plugin-react/LICENSE b/packages/plugin-react/LICENSE deleted file mode 100644 index 9c1b313d7b1816..00000000000000 --- a/packages/plugin-react/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/plugin-react/README.md b/packages/plugin-react/README.md deleted file mode 100644 index 6a8f3cb0ac9e21..00000000000000 --- a/packages/plugin-react/README.md +++ /dev/null @@ -1,107 +0,0 @@ -# @vitejs/plugin-react [![npm](https://img.shields.io/npm/v/@vitejs/plugin-react.svg)](https://npmjs.com/package/@vitejs/plugin-react) - -The all-in-one Vite plugin for React projects. - -- enable [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development -- use the [automatic JSX runtime](https://github.com/alloc/vite-react-jsx#faq) -- avoid manual `import React` in `.jsx` and `.tsx` modules -- dedupe the `react` and `react-dom` packages -- use custom Babel plugins/presets - -```js -// vite.config.js -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' - -export default defineConfig({ - plugins: [react()] -}) -``` - -## Filter which files use Fast Refresh - -By default, Fast Refresh is used by files ending with `.js`, `.jsx`, `.ts`, and `.tsx`, except for files with a `node_modules` parent directory. - -In some situations, you may not want a file to act as a HMR boundary, instead preferring that the changes propagate higher in the stack before being handled. In these cases, you can provide an `include` and/or `exclude` option, which can be a regex, a [picomatch](https://github.com/micromatch/picomatch#globbing-features) pattern, or an array of either. Files matching `include` and not `exclude` will use Fast Refresh. The defaults are always applied. - -```js -react({ - // Exclude storybook stories - exclude: /\.stories\.(t|j)sx?$/, - // Only .tsx files - include: '**/*.tsx' -}) -``` - -## Opting out of the automatic JSX runtime - -By default, the plugin uses the [automatic JSX runtime](https://github.com/alloc/vite-react-jsx#faq). However, if you encounter any issues, you may opt out using the `jsxRuntime` option. - -```js -react({ - jsxRuntime: 'classic' -}) -``` - -## Babel configuration - -The `babel` option lets you add plugins, presets, and [other configuration](https://babeljs.io/docs/en/options) to the Babel transformation performed on each JSX/TSX file. - -```js -react({ - babel: { - presets: [...], - // Your plugins run before any built-in transform (eg: Fast Refresh) - plugins: [...], - // Use .babelrc files - babelrc: true, - // Use babel.config.js files - configFile: true, - } -}) -``` - -### Proposed syntax - -If you are using ES syntax that are still in proposal status (e.g. class properties), you can selectively enable them with the `babel.parserOpts.plugins` option: - -```js -react({ - babel: { - parserOpts: { - plugins: ['decorators-legacy'] - } - } -}) -``` - -This option does not enable _code transformation_. That is handled by esbuild. - -**Note:** TypeScript syntax is handled automatically. - -Here's the [complete list of Babel parser plugins](https://babeljs.io/docs/en/babel-parser#ecmascript-proposalshttpsgithubcombabelproposals). - -## Middleware mode - -In [middleware mode](https://vitejs.dev/config/server-options.html#server-middlewaremode), you should make sure your entry `index.html` file is transformed by Vite. Here's an example for an Express server: - -```js -app.get('/', async (req, res, next) => { - try { - let html = fs.readFileSync(path.resolve(root, 'index.html'), 'utf-8') - - // Transform HTML using Vite plugins. - html = await viteServer.transformIndexHtml(req.url, html) - - res.send(html) - } catch (e) { - return next(e) - } -}) -``` - -Otherwise, you'll probably get this error: - -``` -Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. -``` diff --git a/packages/plugin-react/build.config.ts b/packages/plugin-react/build.config.ts deleted file mode 100644 index 61165722c633a6..00000000000000 --- a/packages/plugin-react/build.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineBuildConfig } from 'unbuild' - -export default defineBuildConfig({ - entries: ['src/index'], - externals: ['vite'], - clean: true, - declaration: true, - rollup: { - emitCJS: true, - inlineDependencies: true - } -}) diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json deleted file mode 100644 index f06dc3ffc7c280..00000000000000 --- a/packages/plugin-react/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@vitejs/plugin-react", - "version": "3.0.0-alpha.1", - "license": "MIT", - "author": "Evan You", - "contributors": [ - "Alec Larson" - ], - "files": [ - "dist" - ], - "main": "./dist/index.cjs", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" - } - }, - "scripts": { - "dev": "unbuild --stub", - "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "tsx ../../scripts/patchCJS.ts", - "prepublishOnly": "npm run build" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vitejs/vite.git", - "directory": "packages/plugin-react" - }, - "bugs": { - "url": "https://github.com/vitejs/vite/issues" - }, - "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme", - "dependencies": { - "@babel/core": "^7.20.2", - "@babel/plugin-transform-react-jsx": "^7.19.0", - "@babel/plugin-transform-react-jsx-development": "^7.18.6", - "@babel/plugin-transform-react-jsx-self": "^7.18.6", - "@babel/plugin-transform-react-jsx-source": "^7.19.6", - "magic-string": "^0.26.7", - "react-refresh": "^0.14.0" - }, - "peerDependencies": { - "vite": "^3.0.0" - }, - "devDependencies": { - "vite": "workspace:*" - } -} diff --git a/packages/plugin-react/src/babel.d.ts b/packages/plugin-react/src/babel.d.ts deleted file mode 100644 index 2d13f794efb7a9..00000000000000 --- a/packages/plugin-react/src/babel.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '@babel/plugin-transform-react-jsx' -declare module '@babel/plugin-transform-react-jsx-self' -declare module '@babel/plugin-transform-react-jsx-source' -declare module 'react-refresh/babel.js' diff --git a/packages/plugin-react/src/fast-refresh.ts b/packages/plugin-react/src/fast-refresh.ts deleted file mode 100644 index 1461b4d785fe7b..00000000000000 --- a/packages/plugin-react/src/fast-refresh.ts +++ /dev/null @@ -1,155 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' -import { createRequire } from 'node:module' -import type { types as t } from '@babel/core' - -export const runtimePublicPath = '/@react-refresh' - -const _require = createRequire(import.meta.url) -const reactRefreshDir = path.dirname( - _require.resolve('react-refresh/package.json') -) -const runtimeFilePath = path.join( - reactRefreshDir, - 'cjs/react-refresh-runtime.development.js' -) - -export const runtimeCode = ` -const exports = {} -${fs.readFileSync(runtimeFilePath, 'utf-8')} -function debounce(fn, delay) { - let handle - return () => { - clearTimeout(handle) - handle = setTimeout(fn, delay) - } -} -exports.performReactRefresh = debounce(exports.performReactRefresh, 16) -export default exports -` - -export const preambleCode = ` -import RefreshRuntime from "__BASE__${runtimePublicPath.slice(1)}" -RefreshRuntime.injectIntoGlobalHook(window) -window.$RefreshReg$ = () => {} -window.$RefreshSig$ = () => (type) => type -window.__vite_plugin_react_preamble_installed__ = true -` - -const header = ` -import RefreshRuntime from "${runtimePublicPath}"; - -let prevRefreshReg; -let prevRefreshSig; - -if (import.meta.hot) { - if (!window.__vite_plugin_react_preamble_installed__) { - throw new Error( - "@vitejs/plugin-react can't detect preamble. Something is wrong. " + - "See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201" - ); - } - - prevRefreshReg = window.$RefreshReg$; - prevRefreshSig = window.$RefreshSig$; - window.$RefreshReg$ = (type, id) => { - RefreshRuntime.register(type, __SOURCE__ + " " + id) - }; - window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform; -}`.replace(/\n+/g, '') - -const timeout = ` - if (!window.__vite_plugin_react_timeout) { - window.__vite_plugin_react_timeout = setTimeout(() => { - window.__vite_plugin_react_timeout = 0; - RefreshRuntime.performReactRefresh(); - }, 30); - } -` - -const footer = ` -if (import.meta.hot) { - window.$RefreshReg$ = prevRefreshReg; - window.$RefreshSig$ = prevRefreshSig; - - __ACCEPT__ -}` - -const checkAndAccept = ` -function isReactRefreshBoundary(mod) { - if (mod == null || typeof mod !== 'object') { - return false; - } - let hasExports = false; - let areAllExportsComponents = true; - for (const exportName in mod) { - hasExports = true; - if (exportName === '__esModule') { - continue; - } - const desc = Object.getOwnPropertyDescriptor(mod, exportName); - if (desc && desc.get) { - // Don't invoke getters as they may have side effects. - return false; - } - const exportValue = mod[exportName]; - if (!RefreshRuntime.isLikelyComponentType(exportValue)) { - areAllExportsComponents = false; - } - } - return hasExports && areAllExportsComponents; -} - -import.meta.hot.accept(mod => { - if (isReactRefreshBoundary(mod)) { - ${timeout} - } else { - import.meta.hot.invalidate(); - } -}); -` - -export function addRefreshWrapper( - code: string, - id: string, - accept: boolean -): string { - return ( - header.replace('__SOURCE__', JSON.stringify(id)) + - code + - footer.replace('__ACCEPT__', accept ? checkAndAccept : timeout) - ) -} - -export function isRefreshBoundary(ast: t.File): boolean { - // Every export must be a potential React component. - // We'll also perform a runtime check that's more robust as well (isLikelyComponentType). - return ast.program.body.every((node) => { - if (node.type !== 'ExportNamedDeclaration') { - return true - } - const { declaration, specifiers } = node - if (declaration) { - if (declaration.type === 'ClassDeclaration') return false - if (declaration.type === 'VariableDeclaration') { - return declaration.declarations.every((variable) => - isComponentLikeIdentifier(variable.id) - ) - } - if (declaration.type === 'FunctionDeclaration') { - return !!declaration.id && isComponentLikeIdentifier(declaration.id) - } - } - return specifiers.every((spec) => { - return isComponentLikeIdentifier(spec.exported) - }) - }) -} - -function isComponentLikeIdentifier(node: t.Node): boolean { - return node.type === 'Identifier' && isComponentLikeName(node.name) -} - -function isComponentLikeName(name: string): boolean { - return typeof name === 'string' && name[0] >= 'A' && name[0] <= 'Z' -} diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts deleted file mode 100644 index f8aa1097cc037d..00000000000000 --- a/packages/plugin-react/src/index.ts +++ /dev/null @@ -1,464 +0,0 @@ -import path from 'node:path' -import type { ParserOptions, TransformOptions, types as t } from '@babel/core' -import * as babel from '@babel/core' -import { createFilter, loadEnv, normalizePath, resolveEnvPrefix } from 'vite' -import type { Plugin, PluginOption, ResolvedConfig } from 'vite' -import MagicString from 'magic-string' -import type { SourceMap } from 'magic-string' -import { - addRefreshWrapper, - isRefreshBoundary, - preambleCode, - runtimeCode, - runtimePublicPath -} from './fast-refresh' - -export interface Options { - include?: string | RegExp | Array - exclude?: string | RegExp | Array - /** - * Enable `react-refresh` integration. Vite disables this in prod env or build mode. - * @default true - */ - fastRefresh?: boolean - /** - * Set this to `"automatic"` to use [vite-react-jsx](https://github.com/alloc/vite-react-jsx). - * @default "automatic" - */ - jsxRuntime?: 'classic' | 'automatic' - /** - * Control where the JSX factory is imported from. - * This option is ignored when `jsxRuntime` is not `"automatic"`. - * @default "react" - */ - jsxImportSource?: string - /** - * Set this to `true` to annotate the JSX factory with `\/* @__PURE__ *\/`. - * This option is ignored when `jsxRuntime` is not `"automatic"`. - * @default true - */ - jsxPure?: boolean - /** - * Babel configuration applied in both dev and prod. - */ - babel?: - | BabelOptions - | ((id: string, options: { ssr?: boolean }) => BabelOptions) -} - -export type BabelOptions = Omit< - TransformOptions, - | 'ast' - | 'filename' - | 'root' - | 'sourceFileName' - | 'sourceMaps' - | 'inputSourceMap' -> - -/** - * The object type used by the `options` passed to plugins with - * an `api.reactBabel` method. - */ -export interface ReactBabelOptions extends BabelOptions { - plugins: Extract - presets: Extract - overrides: Extract - parserOpts: ParserOptions & { - plugins: Extract - } -} - -type ReactBabelHook = ( - babelConfig: ReactBabelOptions, - context: ReactBabelHookContext, - config: ResolvedConfig -) => void - -type ReactBabelHookContext = { ssr: boolean; id: string } - -declare module 'vite' { - export interface Plugin { - api?: { - /** - * Manipulate the Babel options of `@vitejs/plugin-react` - */ - reactBabel?: ReactBabelHook - } - } -} - -const prependReactImportCode = "import React from 'react'; " - -export default function viteReact(opts: Options = {}): PluginOption[] { - // Provide default values for Rollup compat. - let devBase = '/' - let filter = createFilter(opts.include, opts.exclude) - let needHiresSourcemap = false - let isProduction = true - let projectRoot = process.cwd() - let skipFastRefresh = opts.fastRefresh === false - let skipReactImport = false - let runPluginOverrides = ( - options: ReactBabelOptions, - context: ReactBabelHookContext - ) => false - let staticBabelOptions: ReactBabelOptions | undefined - - const useAutomaticRuntime = opts.jsxRuntime !== 'classic' - - // Support patterns like: - // - import * as React from 'react'; - // - import React from 'react'; - // - import React, {useEffect} from 'react'; - const importReactRE = /(?:^|\n)import\s+(?:\*\s+as\s+)?React(?:,|\s+)/ - - // Any extension, including compound ones like '.bs.js' - const fileExtensionRE = /\.[^/\s?]+$/ - - const viteBabel: Plugin = { - name: 'vite:react-babel', - enforce: 'pre', - config(userConfig, { mode }) { - // Copied from https://github.com/vitejs/vite/blob/4e9bdd4fb3654a9d43917e1cb682d3d2bad25115/packages/vite/src/node/config.ts#L477-L494 - - const resolvedRoot = normalizePath( - userConfig.root ? path.resolve(userConfig.root) : process.cwd() - ) - const envDir = userConfig.envDir - ? normalizePath(path.resolve(resolvedRoot, userConfig.envDir)) - : resolvedRoot - loadEnv(mode, envDir, resolveEnvPrefix(userConfig)) - - const isProduction = - (process.env.NODE_ENV || process.env.VITE_USER_NODE_ENV || mode) === - 'production' - - if (opts.jsxRuntime === 'classic') { - return { - esbuild: { - logOverride: { - 'this-is-undefined-in-esm': 'silent' - }, - jsx: 'transform', - jsxImportSource: opts.jsxImportSource, - jsxSideEffects: opts.jsxPure === false - } - } - } else { - return { - esbuild: { - jsxDev: !isProduction, - jsx: 'automatic', - jsxImportSource: opts.jsxImportSource, - jsxSideEffects: opts.jsxPure === false - } - } - } - }, - configResolved(config) { - devBase = config.base - projectRoot = config.root - filter = createFilter(opts.include, opts.exclude, { - resolve: projectRoot - }) - needHiresSourcemap = - config.command === 'build' && !!config.build.sourcemap - isProduction = config.isProduction - skipFastRefresh ||= isProduction || config.command === 'build' - - const jsxInject = config.esbuild && config.esbuild.jsxInject - if (jsxInject && importReactRE.test(jsxInject)) { - skipReactImport = true - config.logger.warn( - '[@vitejs/plugin-react] This plugin imports React for you automatically,' + - ' so you can stop using `esbuild.jsxInject` for that purpose.' - ) - } - - config.plugins.forEach((plugin) => { - const hasConflict = - plugin.name === 'react-refresh' || - (plugin !== viteReactJsx && plugin.name === 'vite:react-jsx') - - if (hasConflict) - return config.logger.warn( - `[@vitejs/plugin-react] You should stop using "${plugin.name}" ` + - `since this plugin conflicts with it.` - ) - }) - - runPluginOverrides = (babelOptions, context) => { - const hooks = config.plugins - .map((plugin) => plugin.api?.reactBabel) - .filter(Boolean) as ReactBabelHook[] - - if (hooks.length > 0) { - return (runPluginOverrides = (babelOptions, context) => { - hooks.forEach((hook) => hook(babelOptions, context, config)) - return true - })(babelOptions, context) - } - runPluginOverrides = () => false - return false - } - }, - async transform(code, id, options) { - const ssr = options?.ssr === true - // File extension could be mocked/overridden in querystring. - const [filepath, querystring = ''] = id.split('?') - const [extension = ''] = - querystring.match(fileExtensionRE) || - filepath.match(fileExtensionRE) || - [] - - if (/\.(?:mjs|[tj]sx?)$/.test(extension)) { - const isJSX = extension.endsWith('x') - const isNodeModules = id.includes('/node_modules/') - const isProjectFile = - !isNodeModules && (id[0] === '\0' || id.startsWith(projectRoot + '/')) - - let babelOptions = staticBabelOptions - if (typeof opts.babel === 'function') { - const rawOptions = opts.babel(id, { ssr }) - babelOptions = createBabelOptions(rawOptions) - runPluginOverrides(babelOptions, { ssr, id: id }) - } else if (!babelOptions) { - babelOptions = createBabelOptions(opts.babel) - if (!runPluginOverrides(babelOptions, { ssr, id: id })) { - staticBabelOptions = babelOptions - } - } - - const plugins = isProjectFile ? [...babelOptions.plugins] : [] - - let useFastRefresh = false - if (!skipFastRefresh && !ssr && !isNodeModules) { - // Modules with .js or .ts extension must import React. - const isReactModule = isJSX || importReactRE.test(code) - if (isReactModule && filter(id)) { - useFastRefresh = true - plugins.push([ - await loadPlugin('react-refresh/babel'), - { skipEnvCheck: true } - ]) - } - } - - let ast: t.File | null | undefined - let prependReactImport = false - if (!isProjectFile || isJSX) { - if (!useAutomaticRuntime && isProjectFile) { - // These plugins are only needed for the classic runtime. - if (!isProduction) { - plugins.push( - await loadPlugin('@babel/plugin-transform-react-jsx-self'), - await loadPlugin('@babel/plugin-transform-react-jsx-source') - ) - } - - // Even if the automatic JSX runtime is not used, we can still - // inject the React import for .jsx and .tsx modules. - if (!skipReactImport && !importReactRE.test(code)) { - prependReactImport = true - } - } - } - - let inputMap: SourceMap | undefined - if (prependReactImport) { - if (needHiresSourcemap) { - const s = new MagicString(code) - s.prepend(prependReactImportCode) - code = s.toString() - inputMap = s.generateMap({ hires: true, source: id }) - } else { - code = prependReactImportCode + code - } - } - - // Plugins defined through this Vite plugin are only applied - // to modules within the project root, but "babel.config.js" - // files can define plugins that need to be applied to every - // module, including node_modules and linked packages. - const shouldSkip = - !plugins.length && - !babelOptions.configFile && - !(isProjectFile && babelOptions.babelrc) - - // Avoid parsing if no plugins exist. - if (shouldSkip) { - return { - code, - map: inputMap ?? null - } - } - - const parserPlugins: typeof babelOptions.parserOpts.plugins = [ - ...babelOptions.parserOpts.plugins, - 'importMeta', - // This plugin is applied before esbuild transforms the code, - // so we need to enable some stage 3 syntax that is supported in - // TypeScript and some environments already. - 'topLevelAwait', - 'classProperties', - 'classPrivateProperties', - 'classPrivateMethods' - ] - - if (!extension.endsWith('.ts')) { - parserPlugins.push('jsx') - } - - if (/\.tsx?$/.test(extension)) { - parserPlugins.push('typescript') - } - - const transformAsync = ast - ? babel.transformFromAstAsync.bind(babel, ast, code) - : babel.transformAsync.bind(babel, code) - - const isReasonReact = extension.endsWith('.bs.js') - const result = await transformAsync({ - ...babelOptions, - ast: !isReasonReact, - root: projectRoot, - filename: id, - sourceFileName: filepath, - parserOpts: { - ...babelOptions.parserOpts, - sourceType: 'module', - allowAwaitOutsideFunction: true, - plugins: parserPlugins - }, - generatorOpts: { - ...babelOptions.generatorOpts, - decoratorsBeforeExport: true - }, - plugins, - sourceMaps: true, - // Vite handles sourcemap flattening - inputSourceMap: inputMap ?? (false as any) - }) - - if (result) { - let code = result.code! - if (useFastRefresh && /\$RefreshReg\$\(/.test(code)) { - const accept = isReasonReact || isRefreshBoundary(result.ast!) - code = addRefreshWrapper(code, id, accept) - } - return { - code, - map: result.map - } - } - } - } - } - - const viteReactRefresh: Plugin = { - name: 'vite:react-refresh', - enforce: 'pre', - config: () => ({ - resolve: { - dedupe: ['react', 'react-dom'] - } - }), - resolveId(id) { - if (id === runtimePublicPath) { - return id - } - }, - load(id) { - if (id === runtimePublicPath) { - return runtimeCode - } - }, - transformIndexHtml() { - if (!skipFastRefresh) - return [ - { - tag: 'script', - attrs: { type: 'module' }, - children: preambleCode.replace(`__BASE__`, devBase) - } - ] - } - } - - const reactJsxRuntimeId = 'react/jsx-runtime' - const reactJsxDevRuntimeId = 'react/jsx-dev-runtime' - const virtualReactJsxRuntimeId = '\0' + reactJsxRuntimeId - const virtualReactJsxDevRuntimeId = '\0' + reactJsxDevRuntimeId - // Adapted from https://github.com/alloc/vite-react-jsx - const viteReactJsx: Plugin = { - name: 'vite:react-jsx', - enforce: 'pre', - config() { - return { - optimizeDeps: { - // We can't add `react-dom` because the dependency is `react-dom/client` - // for React 18 while it's `react-dom` for React 17. We'd need to detect - // what React version the user has installed. - include: [reactJsxRuntimeId, reactJsxDevRuntimeId, 'react'] - } - } - }, - resolveId(id, importer) { - // Resolve runtime to a virtual path to be interoped. - // Since the interop code re-imports `id`, we need to prevent re-resolving - // to the virtual id if the importer is already the virtual id. - if (id === reactJsxRuntimeId && importer !== virtualReactJsxRuntimeId) { - return virtualReactJsxRuntimeId - } - if ( - id === reactJsxDevRuntimeId && - importer !== virtualReactJsxDevRuntimeId - ) { - return virtualReactJsxDevRuntimeId - } - }, - load(id) { - // Apply manual interop - if (id === virtualReactJsxRuntimeId) { - return [ - `import * as jsxRuntime from ${JSON.stringify(reactJsxRuntimeId)}`, - `export const Fragment = jsxRuntime.Fragment`, - `export const jsx = jsxRuntime.jsx`, - `export const jsxs = jsxRuntime.jsxs` - ].join('\n') - } - if (id === virtualReactJsxDevRuntimeId) { - return [ - `import * as jsxRuntime from ${JSON.stringify(reactJsxDevRuntimeId)}`, - `export const Fragment = jsxRuntime.Fragment`, - `export const jsxDEV = jsxRuntime.jsxDEV` - ].join('\n') - } - } - } - - return [viteBabel, viteReactRefresh, useAutomaticRuntime && viteReactJsx] -} - -viteReact.preambleCode = preambleCode - -function loadPlugin(path: string): Promise { - return import(path).then((module) => module.default || module) -} - -function createBabelOptions(rawOptions?: BabelOptions) { - const babelOptions = { - babelrc: false, - configFile: false, - ...rawOptions - } as ReactBabelOptions - - babelOptions.plugins ||= [] - babelOptions.presets ||= [] - babelOptions.overrides ||= [] - babelOptions.parserOpts ||= {} as any - babelOptions.parserOpts.plugins ||= [] - - return babelOptions -} diff --git a/packages/plugin-react/tsconfig.json b/packages/plugin-react/tsconfig.json deleted file mode 100644 index bd94458fe2dc28..00000000000000 --- a/packages/plugin-react/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "include": ["src"], - "exclude": ["**/*.spec.ts"], - "compilerOptions": { - "outDir": "dist", - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "Node", - "strict": true, - "declaration": true, - "sourceMap": true, - "noUnusedLocals": true, - "esModuleInterop": true, - "paths": { - "vite": ["../vite/src/node/index.js"] - } - } -} diff --git a/packages/plugin-vue-jsx/CHANGELOG.md b/packages/plugin-vue-jsx/CHANGELOG.md deleted file mode 100644 index 7ec103c9daa00d..00000000000000 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ /dev/null @@ -1,286 +0,0 @@ -## 2.1.1 (2022-11-07) - -* chore(deps): update all non-major dependencies (#10725) ([22cfad8](https://github.com/vitejs/vite/commit/22cfad8)), closes [#10725](https://github.com/vitejs/vite/issues/10725) - - - -## 2.1.0 (2022-10-26) - -* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) - - - -## 2.1.0-beta.0 (2022-10-05) - -* fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) -* fix(deps): update all non-major dependencies (#10160) ([6233c83](https://github.com/vitejs/vite/commit/6233c83)), closes [#10160](https://github.com/vitejs/vite/issues/10160) -* fix(deps): update all non-major dependencies (#10316) ([a38b450](https://github.com/vitejs/vite/commit/a38b450)), closes [#10316](https://github.com/vitejs/vite/issues/10316) -* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) -* refactor(vue-jsx): remove `@babel/plugin-syntax-import-meta` (#10233) ([1bac86a](https://github.com/vitejs/vite/commit/1bac86a)), closes [#10233](https://github.com/vitejs/vite/issues/10233) - - - -## 2.0.1 (2022-08-29) - -* fix: mention that Node.js 13/15 support is dropped (fixes #9113) (#9116) ([2826303](https://github.com/vitejs/vite/commit/2826303)), closes [#9113](https://github.com/vitejs/vite/issues/9113) [#9116](https://github.com/vitejs/vite/issues/9116) -* fix(deps): update all non-major dependencies (#9176) ([31d3b70](https://github.com/vitejs/vite/commit/31d3b70)), closes [#9176](https://github.com/vitejs/vite/issues/9176) -* fix(deps): update all non-major dependencies (#9575) ([8071325](https://github.com/vitejs/vite/commit/8071325)), closes [#9575](https://github.com/vitejs/vite/issues/9575) -* fix(deps): update all non-major dependencies (#9888) ([e35a58b](https://github.com/vitejs/vite/commit/e35a58b)), closes [#9888](https://github.com/vitejs/vite/issues/9888) -* perf(plugin-vue-jsx): hoist variables (#9687) ([d9eb6b9](https://github.com/vitejs/vite/commit/d9eb6b9)), closes [#9687](https://github.com/vitejs/vite/issues/9687) - - - -## 2.0.0 (2022-07-13) - -* chore: 3.0 release notes and bump peer deps (#9072) ([427ba26](https://github.com/vitejs/vite/commit/427ba26)), closes [#9072](https://github.com/vitejs/vite/issues/9072) -* chore: use `tsx` directly instead of indirect `esno` (#8773) ([f018f13](https://github.com/vitejs/vite/commit/f018f13)), closes [#8773](https://github.com/vitejs/vite/issues/8773) -* chore(deps): update all non-major dependencies (#9022) ([6342140](https://github.com/vitejs/vite/commit/6342140)), closes [#9022](https://github.com/vitejs/vite/issues/9022) -* fix(deps): update all non-major dependencies (#8802) ([a4a634d](https://github.com/vitejs/vite/commit/a4a634d)), closes [#8802](https://github.com/vitejs/vite/issues/8802) - - - -## 2.0.0-beta.0 (2022-06-21) - -* chore: update major deps (#8572) ([0e20949](https://github.com/vitejs/vite/commit/0e20949)), closes [#8572](https://github.com/vitejs/vite/issues/8572) -* chore: use `esno` to replace `ts-node` (#8162) ([c18a5f3](https://github.com/vitejs/vite/commit/c18a5f3)), closes [#8162](https://github.com/vitejs/vite/issues/8162) -* chore: use node prefix (#8309) ([60721ac](https://github.com/vitejs/vite/commit/60721ac)), closes [#8309](https://github.com/vitejs/vite/issues/8309) -* feat: bump minimum node version to 14.18.0 (#8662) ([8a05432](https://github.com/vitejs/vite/commit/8a05432)), closes [#8662](https://github.com/vitejs/vite/issues/8662) -* feat: expose createFilter util (#8562) ([c5c424a](https://github.com/vitejs/vite/commit/c5c424a)), closes [#8562](https://github.com/vitejs/vite/issues/8562) -* refactor: remove hooks ssr param support (#8491) ([f59adf8](https://github.com/vitejs/vite/commit/f59adf8)), closes [#8491](https://github.com/vitejs/vite/issues/8491) -* docs(plugin-vue-jsx): update the options (#8496) ([0826f7b](https://github.com/vitejs/vite/commit/0826f7b)), closes [#8496](https://github.com/vitejs/vite/issues/8496) -* fix(deps): update all non-major dependencies (#8281) ([c68db4d](https://github.com/vitejs/vite/commit/c68db4d)), closes [#8281](https://github.com/vitejs/vite/issues/8281) -* fix(deps): update all non-major dependencies (#8391) ([842f995](https://github.com/vitejs/vite/commit/842f995)), closes [#8391](https://github.com/vitejs/vite/issues/8391) -* feat!: migrate to ESM (#8178) ([76fdc27](https://github.com/vitejs/vite/commit/76fdc27)), closes [#8178](https://github.com/vitejs/vite/issues/8178) - - - -## 2.0.0-alpha.1 (2022-05-19) - -* fix: rewrite CJS specific funcs/vars in plugins (#8227) ([9baa70b](https://github.com/vitejs/vite/commit/9baa70b)), closes [#8227](https://github.com/vitejs/vite/issues/8227) -* build!: bump targets (#8045) ([66efd69](https://github.com/vitejs/vite/commit/66efd69)), closes [#8045](https://github.com/vitejs/vite/issues/8045) - - - -## 2.0.0-alpha.0 (2022-05-13) - -* chore: revert vitejs/vite#8152 (#8161) ([85b8b55](https://github.com/vitejs/vite/commit/85b8b55)), closes [vitejs/vite#8152](https://github.com/vitejs/vite/issues/8152) [#8161](https://github.com/vitejs/vite/issues/8161) -* chore: update plugins peer deps ([d57c23c](https://github.com/vitejs/vite/commit/d57c23c)) -* chore: use `unbuild` to bundle plugins (#8139) ([638b168](https://github.com/vitejs/vite/commit/638b168)), closes [#8139](https://github.com/vitejs/vite/issues/8139) -* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) -* chore(deps): update all non-major dependencies (#7949) ([b877d30](https://github.com/vitejs/vite/commit/b877d30)), closes [#7949](https://github.com/vitejs/vite/issues/7949) -* chore(deps): use `esno` to replace `ts-node` (#8152) ([2363bd3](https://github.com/vitejs/vite/commit/2363bd3)), closes [#8152](https://github.com/vitejs/vite/issues/8152) -* chore(plugin-vue-jsx): add peer deps (#8086) ([7b48e22](https://github.com/vitejs/vite/commit/7b48e22)), closes [#8086](https://github.com/vitejs/vite/issues/8086) -* refactor: use node hash (#7975) ([5ce7c74](https://github.com/vitejs/vite/commit/5ce7c74)), closes [#7975](https://github.com/vitejs/vite/issues/7975) -* refactor: use optional chaining in config `define` of vue-jsx (#8046) ([9f8381e](https://github.com/vitejs/vite/commit/9f8381e)), closes [#8046](https://github.com/vitejs/vite/issues/8046) -* build!: remove node v12 support (#7833) ([eeac2d2](https://github.com/vitejs/vite/commit/eeac2d2)), closes [#7833](https://github.com/vitejs/vite/issues/7833) - - - -## 1.3.10 (2022-04-13) - -* fix(deps): update all non-major dependencies (#7668) ([485263c](https://github.com/vitejs/vite/commit/485263c)), closes [#7668](https://github.com/vitejs/vite/issues/7668) - - - -## 1.3.9 (2022-03-30) - -* fix(deps): update all non-major dependencies (#7392) ([b63fc3b](https://github.com/vitejs/vite/commit/b63fc3b)), closes [#7392](https://github.com/vitejs/vite/issues/7392) -* chore(deps): update all non-major dependencies (#6905) ([839665c](https://github.com/vitejs/vite/commit/839665c)), closes [#6905](https://github.com/vitejs/vite/issues/6905) - - - -## [1.3.8](https://github.com/vitejs/vite/compare/plugin-vue@2.2.4...plugin-vue@1.3.8) (2022-02-28) - - - -## [1.3.7](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@1.3.7) (2022-02-14) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) - - - -## [1.3.6](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@1.3.6) (2022-02-12) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) - - - -## [1.3.5](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.4...plugin-vue-jsx@1.3.5) (2022-02-12) - - - -## [1.3.4](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.3...plugin-vue-jsx@1.3.4) (2022-02-09) - - - -## [1.3.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.2...plugin-vue-jsx@1.3.3) (2021-12-20) - - - -## [1.3.2](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.1...plugin-vue-jsx@1.3.2) (2021-12-13) - - -### Bug Fixes - -* allow overwriting `define` options in vue & vue-jsx plugins ([#6072](https://github.com/vitejs/vite/issues/6072)) ([5f3f6b7](https://github.com/vitejs/vite/commit/5f3f6b7b406cb3371084057c74814eb36175e5cf)) - - - -## [1.3.1](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.0...plugin-vue-jsx@1.3.1) (2021-12-07) - - - -# [1.3.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.3.0-beta.0...plugin-vue-jsx@1.3.0) (2021-11-22) - - - -# [1.3.0-beta.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.2.0...plugin-vue-jsx@1.3.0-beta.0) (2021-10-28) - - - -# [1.2.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.8...plugin-vue-jsx@1.2.0) (2021-09-29) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#4545](https://github.com/vitejs/vite/issues/4545)) ([a44fd5d](https://github.com/vitejs/vite/commit/a44fd5d38679da0be2536103e83af730cda73a95)) -* normalize internal plugin names ([#4976](https://github.com/vitejs/vite/issues/4976)) ([37f0b2f](https://github.com/vitejs/vite/commit/37f0b2fff74109d381513ed052a32b43655ee11d)) - - - -## [1.1.8](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.7...plugin-vue-jsx@1.1.8) (2021-09-07) - - -### Bug Fixes - -* hmr doesn't work when modifying the code of jsx in sfc ([#4563](https://github.com/vitejs/vite/issues/4563)) ([1012367](https://github.com/vitejs/vite/commit/101236794c5d6d28591302d5552cb1c0ab8f4115)) - - - -## [1.1.7](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.6...plugin-vue-jsx@1.1.7) (2021-07-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#4387](https://github.com/vitejs/vite/issues/4387)) ([2f900ba](https://github.com/vitejs/vite/commit/2f900ba4d4ad8061e0046898e8d1de3129e7f784)) - - - -## [1.1.6](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.5...plugin-vue-jsx@1.1.6) (2021-06-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#3791](https://github.com/vitejs/vite/issues/3791)) ([74d409e](https://github.com/vitejs/vite/commit/74d409eafca8d74ec4a6ece621ea2895bc1f2a32)) -* **plugin-vue-jsx:** replace default export with helper during SSR ([#3966](https://github.com/vitejs/vite/issues/3966)) ([bc86464](https://github.com/vitejs/vite/commit/bc86464d3c6591eae96e070a1724a3f21874c8ce)) -* **ssr:** normalize manifest filenames ([#3706](https://github.com/vitejs/vite/issues/3706)) ([aa8ca3f](https://github.com/vitejs/vite/commit/aa8ca3f35218c9fb48f87d3f6f4681d379ee45ca)), closes [#3303](https://github.com/vitejs/vite/issues/3303) - - -### Features - -* **plugin-vue-jsx:** jsx plugin should have extra babel plugins option ([#3923](https://github.com/vitejs/vite/issues/3923)) ([aada0c5](https://github.com/vitejs/vite/commit/aada0c5e71e4826cf049596f3459d48b386ea4da)) - - - -## [1.1.5](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.4...plugin-vue-jsx@1.1.5) (2021-06-01) - - -### Bug Fixes - -* include/exclude options for vue-jsx .d.ts ([#3573](https://github.com/vitejs/vite/issues/3573)) ([82ec0ca](https://github.com/vitejs/vite/commit/82ec0ca69c1f077cf518073edca4e6580ebd4892)) - - - -## [1.1.4](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.3...plugin-vue-jsx@1.1.4) (2021-05-03) - - -### Features - -* include/exclude options for vue-jsx plugin ([#1953](https://github.com/vitejs/vite/issues/1953)) ([fbecf1e](https://github.com/vitejs/vite/commit/fbecf1e5349ea5da8ff6f194efdcb152e2995398)) - - - -## [1.1.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.2...plugin-vue-jsx@1.1.3) (2021-03-31) - - -### Bug Fixes - -* ignore babelrc ([#2766](https://github.com/vitejs/vite/issues/2766)) ([23c4114](https://github.com/vitejs/vite/commit/23c41149ddf74261f7615d22e59b39a017b79509)), closes [#2722](https://github.com/vitejs/vite/issues/2722) - - - -## [1.1.2](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.1...plugin-vue-jsx@1.1.2) (2021-02-24) - - - -## [1.1.1](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.1.0...plugin-vue-jsx@1.1.1) (2021-02-24) - - -### Bug Fixes - -* **plugin-vue-jsx:** do not read babel configuration ([#2181](https://github.com/vitejs/vite/issues/2181)) ([8f0dc25](https://github.com/vitejs/vite/commit/8f0dc25e943ff490eefa0ed3663205a14e8eed9e)) - - - -# [1.1.0](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.3...plugin-vue-jsx@1.1.0) (2021-02-09) - - -### Features - -* **plugin-vue-jsx:** register jsx module during ssr ([7a6aa2a](https://github.com/vitejs/vite/commit/7a6aa2ad2689bf8221389924a608876866db7b0a)) - - - -## [1.0.3](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.2...plugin-vue-jsx@1.0.3) (2021-02-08) - - -### Bug Fixes - -* **plugin-vue-jsx:** support ssr ([30e92a1](https://github.com/vitejs/vite/commit/30e92a150e060e8bedcb6f0c477dcaa87e7996d6)), closes [#1939](https://github.com/vitejs/vite/issues/1939) - - - -## [1.0.2](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.1...plugin-vue-jsx@1.0.2) (2021-01-12) - - -### Bug Fixes - -* **plugin-vue-jsx:** files should include `index.d.ts` ([#1473](https://github.com/vitejs/vite/issues/1473)) [skip ci] ([f3ab497](https://github.com/vitejs/vite/commit/f3ab497b762e267721ace628bc6c7c5695b0d431)) -* **plugin-vue-jsx:** fix define call check ([#1480](https://github.com/vitejs/vite/issues/1480)) ([4ea065f](https://github.com/vitejs/vite/commit/4ea065f6278f30c022ed291bfb0412a674b18dd4)) -* **plugin-vue-jsx:** fix vue jsx hmr ([#1495](https://github.com/vitejs/vite/issues/1495)) ([6bdc3eb](https://github.com/vitejs/vite/commit/6bdc3eb2d004a28d2934946e33602f832b1ad8f2)) - - -### Performance Improvements - -* **plugin-vue-jsx:** only gen source map when necessary ([bfa8530](https://github.com/vitejs/vite/commit/bfa8530fc60deada634c38cfd6a23ab8ca05d47c)) - - - -## [1.0.1](https://github.com/vitejs/vite/compare/plugin-vue-jsx@1.0.0...plugin-vue-jsx@1.0.1) (2021-01-04) - - -### Bug Fixes - -* still let esbuild handle ts ([5903554](https://github.com/vitejs/vite/commit/59035546db7ff4b7020242ba994a5395aac92802)) - - - -# 2.0.0-beta.4 (2021-01-04) - - - -# 1.0.0 (2021-01-04) - - -### Features - -* vue-jsx support ([e756c48](https://github.com/vitejs/vite/commit/e756c48ed4c7372d4c8e26016ba4b91880e7e248)) - - - diff --git a/packages/plugin-vue-jsx/LICENSE b/packages/plugin-vue-jsx/LICENSE deleted file mode 100644 index 9c1b313d7b1816..00000000000000 --- a/packages/plugin-vue-jsx/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/plugin-vue-jsx/README.md b/packages/plugin-vue-jsx/README.md deleted file mode 100644 index c75e6d786f67b6..00000000000000 --- a/packages/plugin-vue-jsx/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# @vitejs/plugin-vue-jsx [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue-jsx.svg)](https://npmjs.com/package/@vitejs/plugin-vue-jsx) - -Provides Vue 3 JSX & TSX support with HMR. - -```js -// vite.config.js -import vueJsx from '@vitejs/plugin-vue-jsx' - -export default { - plugins: [ - vueJsx({ - // options are passed on to @vue/babel-plugin-jsx - }) - ] -} -``` - -## Options - -### include - -Type: `(string | RegExp)[] | string | RegExp | null` - -Default: `/\.[jt]sx$/` - -A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on. - -### exclude - -Type: `(string | RegExp)[] | string | RegExp | null` - -Default: `undefined` - -A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files to be ignored by the plugin. - -> See [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next) for other options. - -## HMR Detection - -This plugin supports HMR of Vue JSX components. The detection requirements are: - -- The component must be exported. -- The component must be declared by calling `defineComponent` via a root-level statement, either variable declaration or export declaration. - -### Supported patterns - -```jsx -import { defineComponent } from 'vue' - -// named exports w/ variable declaration: ok -export const Foo = defineComponent({}) - -// named exports referencing variable declaration: ok -const Bar = defineComponent({ render() { return
Test
}}) -export { Bar } - -// default export call: ok -export default defineComponent({ render() { return
Test
}}) - -// default export referencing variable declaration: ok -const Baz = defineComponent({ render() { return
Test
}}) -export default Baz -``` - -### Non-supported patterns - -```jsx -// not using `defineComponent` call -export const Bar = { ... } - -// not exported -const Foo = defineComponent(...) -``` diff --git a/packages/plugin-vue-jsx/build.config.ts b/packages/plugin-vue-jsx/build.config.ts deleted file mode 100644 index 6dcf1a5a2dc0b3..00000000000000 --- a/packages/plugin-vue-jsx/build.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineBuildConfig } from 'unbuild' - -export default defineBuildConfig({ - entries: ['src/index'], - clean: true, - declaration: true, - rollup: { - emitCJS: true - } -}) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json deleted file mode 100644 index be78033325a466..00000000000000 --- a/packages/plugin-vue-jsx/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "@vitejs/plugin-vue-jsx", - "version": "2.1.1", - "license": "MIT", - "author": "Evan You", - "files": [ - "dist" - ], - "main": "./dist/index.cjs", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" - } - }, - "scripts": { - "dev": "unbuild --stub", - "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "tsx ../../scripts/patchCJS.ts", - "prepublishOnly": "npm run build" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vitejs/vite.git", - "directory": "packages/plugin-vue-jsx" - }, - "bugs": { - "url": "https://github.com/vitejs/vite/issues" - }, - "homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx#readme", - "dependencies": { - "@babel/core": "^7.20.2", - "@babel/plugin-transform-typescript": "^7.20.2", - "@vue/babel-plugin-jsx": "^1.1.1" - }, - "devDependencies": { - "vite": "workspace:*" - }, - "peerDependencies": { - "vite": "^3.0.0", - "vue": "^3.0.0" - } -} diff --git a/packages/plugin-vue-jsx/src/index.ts b/packages/plugin-vue-jsx/src/index.ts deleted file mode 100644 index 15fcb808ed331b..00000000000000 --- a/packages/plugin-vue-jsx/src/index.ts +++ /dev/null @@ -1,283 +0,0 @@ -import { createHash } from 'node:crypto' -import path from 'node:path' -import type { types } from '@babel/core' -import * as babel from '@babel/core' -import jsx from '@vue/babel-plugin-jsx' -import { createFilter, normalizePath } from 'vite' -import type { ComponentOptions } from 'vue' -import type { Plugin } from 'vite' -// eslint-disable-next-line node/no-extraneous-import -import type { CallExpression, Identifier } from '@babel/types' -import type { Options } from './types' - -export * from './types' - -const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper' -const ssrRegisterHelperCode = - `import { useSSRContext } from "vue"\n` + - `export ${ssrRegisterHelper.toString()}` - -/** - * This function is serialized with toString() and evaluated as a virtual - * module during SSR - */ -function ssrRegisterHelper(comp: ComponentOptions, filename: string) { - const setup = comp.setup - comp.setup = (props, ctx) => { - // @ts-ignore - const ssrContext = useSSRContext() - ;(ssrContext.modules || (ssrContext.modules = new Set())).add(filename) - if (setup) { - return setup(props, ctx) - } - } -} - -function vueJsxPlugin(options: Options = {}): Plugin { - let root = '' - let needHmr = false - let needSourceMap = true - - const { include, exclude, babelPlugins = [], ...babelPluginOptions } = options - const filter = createFilter(include || /\.[jt]sx$/, exclude) - - return { - name: 'vite:vue-jsx', - - config(config) { - return { - // only apply esbuild to ts files - // since we are handling jsx and tsx now - esbuild: { - include: /\.ts$/ - }, - define: { - __VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true, - __VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false - } - } - }, - - configResolved(config) { - needHmr = config.command === 'serve' && !config.isProduction - needSourceMap = config.command === 'serve' || !!config.build.sourcemap - root = config.root - }, - - resolveId(id) { - if (id === ssrRegisterHelperId) { - return id - } - }, - - load(id) { - if (id === ssrRegisterHelperId) { - return ssrRegisterHelperCode - } - }, - - async transform(code, id, opt) { - const ssr = opt?.ssr === true - const [filepath] = id.split('?') - - // use id for script blocks in Vue SFCs (e.g. `App.vue?vue&type=script&lang.jsx`) - // use filepath for plain jsx files (e.g. App.jsx) - if (filter(id) || filter(filepath)) { - const plugins = [[jsx, babelPluginOptions], ...babelPlugins] - if (id.endsWith('.tsx') || filepath.endsWith('.tsx')) { - plugins.push([ - // @ts-ignore missing type - await import('@babel/plugin-transform-typescript').then( - (r) => r.default - ), - // @ts-ignore - { isTSX: true, allowExtensions: true } - ]) - } - - if (!ssr && !needHmr) { - plugins.push(() => { - return { - visitor: { - CallExpression: { - enter(_path: babel.NodePath) { - if (isDefineComponentCall(_path.node)) { - const callee = _path.node.callee as Identifier - callee.name = `/* @__PURE__ */ ${callee.name}` - } - } - } - } - } - }) - } - - const result = babel.transformSync(code, { - babelrc: false, - ast: true, - plugins, - sourceMaps: needSourceMap, - sourceFileName: id, - configFile: false - })! - - if (!ssr && !needHmr) { - if (!result.code) return - return { - code: result.code, - map: result.map - } - } - - interface HotComponent { - local: string - exported: string - id: string - } - - // check for hmr injection - const declaredComponents: { name: string }[] = [] - const hotComponents: HotComponent[] = [] - let hasDefault = false - - for (const node of result.ast!.program.body) { - if (node.type === 'VariableDeclaration') { - const names = parseComponentDecls(node, code) - if (names.length) { - declaredComponents.push(...names) - } - } - - if (node.type === 'ExportNamedDeclaration') { - if ( - node.declaration && - node.declaration.type === 'VariableDeclaration' - ) { - hotComponents.push( - ...parseComponentDecls(node.declaration, code).map( - ({ name }) => ({ - local: name, - exported: name, - id: getHash(id + name) - }) - ) - ) - } else if (node.specifiers.length) { - for (const spec of node.specifiers) { - if ( - spec.type === 'ExportSpecifier' && - spec.exported.type === 'Identifier' - ) { - const matched = declaredComponents.find( - ({ name }) => name === spec.local.name - ) - if (matched) { - hotComponents.push({ - local: spec.local.name, - exported: spec.exported.name, - id: getHash(id + spec.exported.name) - }) - } - } - } - } - } - - if (node.type === 'ExportDefaultDeclaration') { - if (node.declaration.type === 'Identifier') { - const _name = node.declaration.name - const matched = declaredComponents.find( - ({ name }) => name === _name - ) - if (matched) { - hotComponents.push({ - local: node.declaration.name, - exported: 'default', - id: getHash(id + 'default') - }) - } - } else if (isDefineComponentCall(node.declaration)) { - hasDefault = true - hotComponents.push({ - local: '__default__', - exported: 'default', - id: getHash(id + 'default') - }) - } - } - } - - if (hotComponents.length) { - if (hasDefault && (needHmr || ssr)) { - result.code = - result.code!.replace( - /export default defineComponent/g, - `const __default__ = defineComponent` - ) + `\nexport default __default__` - } - - if (needHmr && !ssr && !/\?vue&type=script/.test(id)) { - let code = result.code - let callbackCode = `` - for (const { local, exported, id } of hotComponents) { - code += - `\n${local}.__hmrId = "${id}"` + - `\n__VUE_HMR_RUNTIME__.createRecord("${id}", ${local})` - callbackCode += `\n__VUE_HMR_RUNTIME__.reload("${id}", __${exported})` - } - - code += `\nimport.meta.hot.accept(({${hotComponents - .map((c) => `${c.exported}: __${c.exported}`) - .join(',')}}) => {${callbackCode}\n})` - - result.code = code - } - - if (ssr) { - const normalizedId = normalizePath(path.relative(root, id)) - let ssrInjectCode = - `\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"` + - `\nconst __moduleId = ${JSON.stringify(normalizedId)}` - for (const { local } of hotComponents) { - ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)` - } - result.code += ssrInjectCode - } - } - - if (!result.code) return - return { - code: result.code, - map: result.map - } - } - } - } -} - -function parseComponentDecls(node: types.VariableDeclaration, source: string) { - const names = [] - for (const decl of node.declarations) { - if (decl.id.type === 'Identifier' && isDefineComponentCall(decl.init)) { - names.push({ - name: decl.id.name - }) - } - } - return names -} - -function isDefineComponentCall(node?: types.Node | null) { - return ( - node && - node.type === 'CallExpression' && - node.callee.type === 'Identifier' && - node.callee.name === 'defineComponent' - ) -} - -function getHash(text: string) { - return createHash('sha256').update(text).digest('hex').substring(0, 8) -} - -export default vueJsxPlugin diff --git a/packages/plugin-vue-jsx/src/types.ts b/packages/plugin-vue-jsx/src/types.ts deleted file mode 100644 index a3be580859ea00..00000000000000 --- a/packages/plugin-vue-jsx/src/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx' -import type { FilterPattern } from 'vite' - -export interface FilterOptions { - include?: FilterPattern - exclude?: FilterPattern -} - -export type Options = VueJSXPluginOptions & - FilterOptions & { babelPlugins?: any[] } diff --git a/packages/plugin-vue-jsx/tsconfig.json b/packages/plugin-vue-jsx/tsconfig.json deleted file mode 100644 index bd94458fe2dc28..00000000000000 --- a/packages/plugin-vue-jsx/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "include": ["src"], - "exclude": ["**/*.spec.ts"], - "compilerOptions": { - "outDir": "dist", - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "Node", - "strict": true, - "declaration": true, - "sourceMap": true, - "noUnusedLocals": true, - "esModuleInterop": true, - "paths": { - "vite": ["../vite/src/node/index.js"] - } - } -} diff --git a/packages/plugin-vue/CHANGELOG.md b/packages/plugin-vue/CHANGELOG.md deleted file mode 100644 index 757260f5453267..00000000000000 --- a/packages/plugin-vue/CHANGELOG.md +++ /dev/null @@ -1,622 +0,0 @@ -## 4.0.0-alpha.1 (2022-11-22) - -* feat: dedupe the `vue` in client bundle by default (#11032) ([fae0e23](https://github.com/vitejs/vite/commit/fae0e23)), closes [#11032](https://github.com/vitejs/vite/issues/11032) - - - -## 4.0.0-alpha.0 (2022-11-15) - -* fix: handle HMR for Vue SFC with query parameters (fix #9341) (#10794) ([6462ab0](https://github.com/vitejs/vite/commit/6462ab0)), closes [#9341](https://github.com/vitejs/vite/issues/9341) [#10794](https://github.com/vitejs/vite/issues/10794) -* fix(vue): skip url query request (fixes #10863) (#10920) ([97d200c](https://github.com/vitejs/vite/commit/97d200c)), closes [#10863](https://github.com/vitejs/vite/issues/10863) [#10920](https://github.com/vitejs/vite/issues/10920) -* chore(deps): update all non-major dependencies (#10910) ([f6ad607](https://github.com/vitejs/vite/commit/f6ad607)), closes [#10910](https://github.com/vitejs/vite/issues/10910) -* chore(deps): update to rollup 3.3 (#10890) ([2d17aa2](https://github.com/vitejs/vite/commit/2d17aa2)), closes [#10890](https://github.com/vitejs/vite/issues/10890) -* perf: regexp perf issues, refactor regexp stylistic issues (#10905) ([fc007df](https://github.com/vitejs/vite/commit/fc007df)), closes [#10905](https://github.com/vitejs/vite/issues/10905) -* docs(plugin-vue): add link to plugin-vue-jsx (#10830) ([0c295e0](https://github.com/vitejs/vite/commit/0c295e0)), closes [#10830](https://github.com/vitejs/vite/issues/10830) -* feat: rollup 3 (#9870) ([beb7166](https://github.com/vitejs/vite/commit/beb7166)), closes [#9870](https://github.com/vitejs/vite/issues/9870) - - - -## 3.2.0 (2022-10-26) - -* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) -* chore(deps): update all non-major dependencies (#10488) ([15aa827](https://github.com/vitejs/vite/commit/15aa827)), closes [#10488](https://github.com/vitejs/vite/issues/10488) -* fix(plugin-vue): enable ts in template when using tsx in dev mode (#10180) ([a9f9d31](https://github.com/vitejs/vite/commit/a9f9d31)), closes [#10180](https://github.com/vitejs/vite/issues/10180) -* docs: add missing binding in asset import example (#10414) ([d7ac96d](https://github.com/vitejs/vite/commit/d7ac96d)), closes [#10414](https://github.com/vitejs/vite/issues/10414) - - - -## 3.2.0-beta.0 (2022-10-05) - -* fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) -* fix(deps): update all non-major dependencies (#10316) ([a38b450](https://github.com/vitejs/vite/commit/a38b450)), closes [#10316](https://github.com/vitejs/vite/issues/10316) -* fix(deps): update all non-major dependencies (#9985) ([855f2f0](https://github.com/vitejs/vite/commit/855f2f0)), closes [#9985](https://github.com/vitejs/vite/issues/9985) -* fix(deps): update rollup to `^2.79.1` (#10298) ([2266d83](https://github.com/vitejs/vite/commit/2266d83)), closes [#10298](https://github.com/vitejs/vite/issues/10298) -* fix(esbuild): transpile with esnext in dev (#10207) ([43b7b78](https://github.com/vitejs/vite/commit/43b7b78)), closes [#10207](https://github.com/vitejs/vite/issues/10207) -* chore(deps): update dependency slash to v5 (#10317) ([9d87c11](https://github.com/vitejs/vite/commit/9d87c11)), closes [#10317](https://github.com/vitejs/vite/issues/10317) -* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) - - - -## 3.1.0 (2022-09-05) - - - - -## 3.1.0-beta.0 (2022-08-29) - -* docs: fix typo (#9855) ([583f185](https://github.com/vitejs/vite/commit/583f185)), closes [#9855](https://github.com/vitejs/vite/issues/9855) -* feat: support object style hooks (#9634) ([757a92f](https://github.com/vitejs/vite/commit/757a92f)), closes [#9634](https://github.com/vitejs/vite/issues/9634) -* chore: fix typo (#9684) ([d30f881](https://github.com/vitejs/vite/commit/d30f881)), closes [#9684](https://github.com/vitejs/vite/issues/9684) -* chore(deps): update all non-major dependencies (#9675) ([4e56e87](https://github.com/vitejs/vite/commit/4e56e87)), closes [#9675](https://github.com/vitejs/vite/issues/9675) -* chore(plugin-vue): update reactivityTransform comment docs [ci skip] ([d04784b](https://github.com/vitejs/vite/commit/d04784b)) - - - -## 3.0.3 (2022-08-12) - - - - -## 3.0.2 (2022-08-11) - -* chore: fix code typos (#9033) ([ed02861](https://github.com/vitejs/vite/commit/ed02861)), closes [#9033](https://github.com/vitejs/vite/issues/9033) -* chore: narrow down rollup version (#9637) ([fcf4d98](https://github.com/vitejs/vite/commit/fcf4d98)), closes [#9637](https://github.com/vitejs/vite/issues/9637) - - - -## 3.0.1 (2022-07-18) - -* fix: mention that Node.js 13/15 support is dropped (fixes #9113) (#9116) ([2826303](https://github.com/vitejs/vite/commit/2826303)), closes [#9113](https://github.com/vitejs/vite/issues/9113) [#9116](https://github.com/vitejs/vite/issues/9116) -* fix(vue): remove ssr.external config (#9128) ([ec91f98](https://github.com/vitejs/vite/commit/ec91f98)), closes [#9128](https://github.com/vitejs/vite/issues/9128) -* refactor(vue): limit passable compilerOptions (#8994) ([b7b3e65](https://github.com/vitejs/vite/commit/b7b3e65)), closes [#8994](https://github.com/vitejs/vite/issues/8994) - - - -## 3.0.0 (2022-07-13) - -* chore: 3.0 release notes and bump peer deps (#9072) ([427ba26](https://github.com/vitejs/vite/commit/427ba26)), closes [#9072](https://github.com/vitejs/vite/issues/9072) -* fix(vue): handle undefined on import.meta.hot.accept (fixes #8625) (#9011) ([70af44a](https://github.com/vitejs/vite/commit/70af44a)), closes [#8625](https://github.com/vitejs/vite/issues/8625) [#9011](https://github.com/vitejs/vite/issues/9011) -* docs: cleanup changes (#8989) ([07aef1b](https://github.com/vitejs/vite/commit/07aef1b)), closes [#8989](https://github.com/vitejs/vite/issues/8989) - - - -## 3.0.0-beta.1 (2022-07-06) - -* fix(deps): update all non-major dependencies (#8802) ([a4a634d](https://github.com/vitejs/vite/commit/a4a634d)), closes [#8802](https://github.com/vitejs/vite/issues/8802) -* fix(plugin-vue): handle TS decorators in rewriteDefault fallback ([cb0c76a](https://github.com/vitejs/vite/commit/cb0c76a)) -* chore: use `tsx` directly instead of indirect `esno` (#8773) ([f018f13](https://github.com/vitejs/vite/commit/f018f13)), closes [#8773](https://github.com/vitejs/vite/issues/8773) -* chore(plugin-vue): mark export helper with null byte (#8792) ([8de4319](https://github.com/vitejs/vite/commit/8de4319)), closes [#8792](https://github.com/vitejs/vite/issues/8792) - - - -## 3.0.0-beta.0 (2022-06-21) - -* feat: bump minimum node version to 14.18.0 (#8662) ([8a05432](https://github.com/vitejs/vite/commit/8a05432)), closes [#8662](https://github.com/vitejs/vite/issues/8662) -* feat: experimental.buildAdvancedBaseOptions (#8450) ([8ef7333](https://github.com/vitejs/vite/commit/8ef7333)), closes [#8450](https://github.com/vitejs/vite/issues/8450) -* chore: use node prefix (#8309) ([60721ac](https://github.com/vitejs/vite/commit/60721ac)), closes [#8309](https://github.com/vitejs/vite/issues/8309) - - - -## 3.0.0-alpha.2 (2022-06-19) - -* fix(deps): update all non-major dependencies (#8281) ([c68db4d](https://github.com/vitejs/vite/commit/c68db4d)), closes [#8281](https://github.com/vitejs/vite/issues/8281) -* fix(deps): update all non-major dependencies (#8391) ([842f995](https://github.com/vitejs/vite/commit/842f995)), closes [#8391](https://github.com/vitejs/vite/issues/8391) -* fix(plugin-vue): fix sourcemap when no script block in sfc (close #8601) (#8604) ([ccfccec](https://github.com/vitejs/vite/commit/ccfccec)), closes [#8601](https://github.com/vitejs/vite/issues/8601) [#8604](https://github.com/vitejs/vite/issues/8604) -* chore: enable reportUnusedDisableDirectives (#8384) ([9a99bc4](https://github.com/vitejs/vite/commit/9a99bc4)), closes [#8384](https://github.com/vitejs/vite/issues/8384) -* chore: update major deps (#8572) ([0e20949](https://github.com/vitejs/vite/commit/0e20949)), closes [#8572](https://github.com/vitejs/vite/issues/8572) -* chore: use `esno` to replace `ts-node` (#8162) ([c18a5f3](https://github.com/vitejs/vite/commit/c18a5f3)), closes [#8162](https://github.com/vitejs/vite/issues/8162) -* chore(deps): update all non-major dependencies (#8474) ([6d0ede7](https://github.com/vitejs/vite/commit/6d0ede7)), closes [#8474](https://github.com/vitejs/vite/issues/8474) -* feat: expose createFilter util (#8562) ([c5c424a](https://github.com/vitejs/vite/commit/c5c424a)), closes [#8562](https://github.com/vitejs/vite/issues/8562) -* refactor: remove hooks ssr param support (#8491) ([f59adf8](https://github.com/vitejs/vite/commit/f59adf8)), closes [#8491](https://github.com/vitejs/vite/issues/8491) -* feat!: migrate to ESM (#8178) ([76fdc27](https://github.com/vitejs/vite/commit/76fdc27)), closes [#8178](https://github.com/vitejs/vite/issues/8178) - - - -## 3.0.0-alpha.1 (2022-05-19) - -* fix: rewrite CJS specific funcs/vars in plugins (#8227) ([9baa70b](https://github.com/vitejs/vite/commit/9baa70b)), closes [#8227](https://github.com/vitejs/vite/issues/8227) -* fix(plugin-vue): regenerate scoped css in build watch, fix #7980 (#7989) ([dc00225](https://github.com/vitejs/vite/commit/dc00225)), closes [#7980](https://github.com/vitejs/vite/issues/7980) [#7989](https://github.com/vitejs/vite/issues/7989) -* fix(plugin-vue): use server.origin when building base for transformAssetUrls (#8077) ([2f7a490](https://github.com/vitejs/vite/commit/2f7a490)), closes [#8077](https://github.com/vitejs/vite/issues/8077) -* build!: bump targets (#8045) ([66efd69](https://github.com/vitejs/vite/commit/66efd69)), closes [#8045](https://github.com/vitejs/vite/issues/8045) -* chore: enable `import/no-duplicates` eslint rule (#8199) ([11243de](https://github.com/vitejs/vite/commit/11243de)), closes [#8199](https://github.com/vitejs/vite/issues/8199) -* docs(plugin-vue): clarify asset url handling (#8184) ([32c75e2](https://github.com/vitejs/vite/commit/32c75e2)), closes [#8184](https://github.com/vitejs/vite/issues/8184) - - - -## 3.0.0-alpha.0 (2022-05-13) - -* chore: bump minors and rebuild lock (#8074) ([aeb5b74](https://github.com/vitejs/vite/commit/aeb5b74)), closes [#8074](https://github.com/vitejs/vite/issues/8074) -* chore: revert vitejs/vite#8152 (#8161) ([85b8b55](https://github.com/vitejs/vite/commit/85b8b55)), closes [vitejs/vite#8152](https://github.com/vitejs/vite/issues/8152) [#8161](https://github.com/vitejs/vite/issues/8161) -* chore: update plugins peer deps ([d57c23c](https://github.com/vitejs/vite/commit/d57c23c)) -* chore: upgrade to pnpm v7 (#8041) ([50f8f3b](https://github.com/vitejs/vite/commit/50f8f3b)), closes [#8041](https://github.com/vitejs/vite/issues/8041) -* chore: use `unbuild` to bundle plugins (#8139) ([638b168](https://github.com/vitejs/vite/commit/638b168)), closes [#8139](https://github.com/vitejs/vite/issues/8139) -* chore(deps): use `esno` to replace `ts-node` (#8152) ([2363bd3](https://github.com/vitejs/vite/commit/2363bd3)), closes [#8152](https://github.com/vitejs/vite/issues/8152) -* chore(lint): sort for imports (#8113) ([43a58dd](https://github.com/vitejs/vite/commit/43a58dd)), closes [#8113](https://github.com/vitejs/vite/issues/8113) -* chore(plugin-vue): change @rollup/pluginutils to dep from devDep (#8154) ([dcc8ea4](https://github.com/vitejs/vite/commit/dcc8ea4)), closes [#8154](https://github.com/vitejs/vite/issues/8154) -* chore(plugin-vue): replace source-map with gen/trace-mapping (#8155) ([79a8c85](https://github.com/vitejs/vite/commit/79a8c85)), closes [#8155](https://github.com/vitejs/vite/issues/8155) -* fix(plugin-vue): allow overwriting template.transformAssetUrls.includeAbsolute (fix #4836) (#6779) ([e0fe200](https://github.com/vitejs/vite/commit/e0fe200)), closes [#4836](https://github.com/vitejs/vite/issues/4836) [#6779](https://github.com/vitejs/vite/issues/6779) -* fix(plugin-vue): don't inline ts scripts during build (#7909) ([ba6cae9](https://github.com/vitejs/vite/commit/ba6cae9)), closes [#7909](https://github.com/vitejs/vite/issues/7909) -* fix(plugin-vue): trigger css hmr on custom template languages (#6987) ([2289d04](https://github.com/vitejs/vite/commit/2289d04)), closes [#6987](https://github.com/vitejs/vite/issues/6987) -* fix(plugin-vue): user defined transformAssetUrls ignored in production build (#7171) ([bfab569](https://github.com/vitejs/vite/commit/bfab569)), closes [#7171](https://github.com/vitejs/vite/issues/7171) -* fix(vue): same src file request same key (#8059) ([4c54800](https://github.com/vitejs/vite/commit/4c54800)), closes [#8059](https://github.com/vitejs/vite/issues/8059) -* refactor: use node hash (#7975) ([5ce7c74](https://github.com/vitejs/vite/commit/5ce7c74)), closes [#7975](https://github.com/vitejs/vite/issues/7975) -* build!: remove node v12 support (#7833) ([eeac2d2](https://github.com/vitejs/vite/commit/eeac2d2)), closes [#7833](https://github.com/vitejs/vite/issues/7833) - - - -## 2.3.2 (2022-05-04) - -* feat: import ts with .js in vue (#7998) ([9974094](https://github.com/vitejs/vite/commit/9974094)), closes [#7998](https://github.com/vitejs/vite/issues/7998) -* refactor(plugin-vue): remove querystring import (#7997) ([f3d15f1](https://github.com/vitejs/vite/commit/f3d15f1)), closes [#7997](https://github.com/vitejs/vite/issues/7997) -* chore(deps): update all non-major dependencies (#7780) ([eba9d05](https://github.com/vitejs/vite/commit/eba9d05)), closes [#7780](https://github.com/vitejs/vite/issues/7780) - - - -## 2.3.1 (2022-03-30) - -* chore(plugin-vue): revert #7527, lower vite peer dep ([447bbeb](https://github.com/vitejs/vite/commit/447bbeb)), closes [#7527](https://github.com/vitejs/vite/issues/7527) - - - -## 2.3.0 (2022-03-30) - -* chore(plugin-vue): bump vite peer dep to 2.9.0 (#7472) ([12fd1d9](https://github.com/vitejs/vite/commit/12fd1d9)), closes [#7472](https://github.com/vitejs/vite/issues/7472) -* feat(css): css.devSourcemap option (#7471) ([57f14cb](https://github.com/vitejs/vite/commit/57f14cb)), closes [#7471](https://github.com/vitejs/vite/issues/7471) -* fix(plugin-vue): respect __VUE_PROD_DEVTOOLS__ setting (#4984) ([90e812a](https://github.com/vitejs/vite/commit/90e812a)), closes [#4984](https://github.com/vitejs/vite/issues/4984) - - - -## 2.3.0-beta.0 (2022-03-22) - -* fix(deps): update all non-major dependencies (#7392) ([b63fc3b](https://github.com/vitejs/vite/commit/b63fc3b)), closes [#7392](https://github.com/vitejs/vite/issues/7392) -* feat: css sourcemap support during dev (#7173) ([38a655f](https://github.com/vitejs/vite/commit/38a655f)), closes [#7173](https://github.com/vitejs/vite/issues/7173) -* chore(deps): update all non-major dependencies (#6905) ([839665c](https://github.com/vitejs/vite/commit/839665c)), closes [#6905](https://github.com/vitejs/vite/issues/6905) -* docs(vue): add transformAssetUrls example (#7232) ([08e928c](https://github.com/vitejs/vite/commit/08e928c)), closes [#7232](https://github.com/vitejs/vite/issues/7232) - - - -## [2.2.4](https://github.com/vitejs/vite/compare/plugin-vue@2.2.3...plugin-vue@2.2.4) (2022-02-28) - - - -## [2.2.3](https://github.com/vitejs/vite/compare/plugin-vue@2.2.2...plugin-vue@2.2.3) (2022-02-28) - - -### Bug Fixes - -* **plugin-vue:** setup jsx script no hmr ([#6568](https://github.com/vitejs/vite/issues/6568)) ([c84601c](https://github.com/vitejs/vite/commit/c84601cee5232bad0f65c8fcc663e38bb457a0b3)) - - - -## [2.2.2](https://github.com/vitejs/vite/compare/plugin-vue@2.2.1...plugin-vue@2.2.2) (2022-02-18) - - - -## [2.2.1](https://github.com/vitejs/vite/compare/plugin-vue@2.2.0...plugin-vue@2.2.1) (2022-02-18) - - -### Bug Fixes - -* adjust vue template sourcemap ([#6972](https://github.com/vitejs/vite/issues/6972)) ([a774303](https://github.com/vitejs/vite/commit/a7743039f263f41e1c3971e324f893a5ef5e5508)) -* **deps:** update all non-major dependencies ([#6782](https://github.com/vitejs/vite/issues/6782)) ([e38be3e](https://github.com/vitejs/vite/commit/e38be3e6ca7bf79319d5d7188e1d347b1d6091ef)) - - - -# [2.2.0](https://github.com/vitejs/vite/compare/plugin-vue@2.1.0...plugin-vue@2.2.0) (2022-02-09) - - -### Bug Fixes - -* plugin-vue `options.compiler` field ([#6588](https://github.com/vitejs/vite/issues/6588)) ([caec019](https://github.com/vitejs/vite/commit/caec01998a9599d255761f3efc1c49827aadac0d)), closes [#6587](https://github.com/vitejs/vite/issues/6587) - - - -# [2.1.0](https://github.com/vitejs/vite/compare/plugin-vue@2.0.1...plugin-vue@2.1.0) (2022-01-21) - - -### Bug Fixes - -* **plugin-vue:** compiler is null on rollup ([#6566](https://github.com/vitejs/vite/issues/6566)) ([b289b2d](https://github.com/vitejs/vite/commit/b289b2d433f94949730e1f041f3c8e16c417e9d0)) -* **plugin-vue:** make cssm code tree shakeable ([#6353](https://github.com/vitejs/vite/issues/6353)) ([3fb4118](https://github.com/vitejs/vite/commit/3fb4118026e2745140894afb9755298656750f43)) -* update the vue version in the error message ([#6252](https://github.com/vitejs/vite/issues/6252)) ([6a47083](https://github.com/vitejs/vite/commit/6a47083df14cb8d2584a86abda8a5e89a731c170)) - - - -## [2.0.1](https://github.com/vitejs/vite/compare/plugin-vue@2.0.0...plugin-vue@2.0.1) (2021-12-14) - - -### Bug Fixes - -* **plugin-vue:** error.length is zero ([#6106](https://github.com/vitejs/vite/issues/6106)) ([5ec49be](https://github.com/vitejs/vite/commit/5ec49befad4d7b5e7cc14f14520ba96d5b6f6d69)) - - - -# [2.0.0](https://github.com/vitejs/vite/compare/plugin-vue@1.10.2...plugin-vue@2.0.0) (2021-12-12) - - -### Bug Fixes - -* allow overwriting `define` options in vue & vue-jsx plugins ([#6072](https://github.com/vitejs/vite/issues/6072)) ([5f3f6b7](https://github.com/vitejs/vite/commit/5f3f6b7b406cb3371084057c74814eb36175e5cf)) -* **plugin-vue:** multiple vue files using the same src file (fix [#5925](https://github.com/vitejs/vite/issues/5925), [#5447](https://github.com/vitejs/vite/issues/5447)) ([#5994](https://github.com/vitejs/vite/issues/5994)) ([df7aec7](https://github.com/vitejs/vite/commit/df7aec7d2a567af1dfbab76e5765aba80dc3cb5c)) - - -### Code Refactoring - -* **plugin-vue:** resolve vue/compiler-sfc from project root ([ce8b0fe](https://github.com/vitejs/vite/commit/ce8b0feae334cc224b3f4d2fdb2bffbb62322acf)) - - -### Features - -* **plugin-vue:** add `reactivityTransform` option. ([955d0fe](https://github.com/vitejs/vite/commit/955d0fecd936b8175d7a7e4355eab855eb4567f8)) - - -### BREAKING CHANGES - -* **plugin-vue:** `refTransform` option has been replaced by -`reactivityTransform` option. Now also requires vue@^3.2.25. -* **plugin-vue:** now requires vue@^3.2.13 as peer dep - - - -## [1.10.2](https://github.com/vitejs/vite/compare/plugin-vue@1.10.1...plugin-vue@1.10.2) (2021-12-07) - - -### Bug Fixes - -* **plugin-vue:** misleading error thrown after refresh or hmr ([#5870](https://github.com/vitejs/vite/issues/5870)) ([5c07cec](https://github.com/vitejs/vite/commit/5c07cec7214948da73fbbc33c7f5c83bf7f6cd2e)) - - - -## [1.10.1](https://github.com/vitejs/vite/compare/plugin-vue@1.10.0...plugin-vue@1.10.1) (2021-11-26) - - -### Bug Fixes - -* **plugin-vue:** fix hmr issue in vuejs/core[#4358](https://github.com/vitejs/vite/issues/4358) ([709e4b0](https://github.com/vitejs/vite/commit/709e4b0428d8cdc8299b22898c76e58d66ca92c9)) - - - -# [1.10.0](https://github.com/vitejs/vite/compare/plugin-vue@1.10.0-beta.1...plugin-vue@1.10.0) (2021-11-22) - - - -# [1.10.0-beta.1](https://github.com/vitejs/vite/compare/plugin-vue@1.10.0-beta.0...plugin-vue@1.10.0-beta.1) (2021-11-19) - - -### Bug Fixes - -* plugin-vue dev scripts error in ssr-vue ([#5607](https://github.com/vitejs/vite/issues/5607)) ([502b8f2](https://github.com/vitejs/vite/commit/502b8f2b31f06d4e524d36b5566197db76f6ccda)) -* **plugin-vue:** template src isn't working when script setup ([#5418](https://github.com/vitejs/vite/issues/5418)) ([518da44](https://github.com/vitejs/vite/commit/518da447e573b6f6ec5e2b1ca837332e0e230c14)) -* **plugin-vue:** use __vccOpts for vue-class-component ([#5374](https://github.com/vitejs/vite/issues/5374)) ([c4f9db2](https://github.com/vitejs/vite/commit/c4f9db2cb375729b06f438298560045d4c488c14)) - - - -# [1.10.0-beta.0](https://github.com/vitejs/vite/compare/plugin-vue@1.9.4...plugin-vue@1.10.0-beta.0) (2021-10-28) - - - -## [1.9.4](https://github.com/vitejs/vite/compare/plugin-vue@1.9.3...plugin-vue@1.9.4) (2021-10-27) - - -### Bug Fixes - -* **plugin-vue:** exclude direct css request from hmr target ([#5422](https://github.com/vitejs/vite/issues/5422)) ([4331c26](https://github.com/vitejs/vite/commit/4331c26a5e5d7a9efc08a8b7bf7056785a1bcd94)) - - - -## [1.9.3](https://github.com/vitejs/vite/compare/plugin-vue@1.9.2...plugin-vue@1.9.3) (2021-10-05) - - -### Bug Fixes - -* **plugin-vue:** don't use object spread in the config hook ([#5155](https://github.com/vitejs/vite/issues/5155)) ([c1ce471](https://github.com/vitejs/vite/commit/c1ce471c07264db034f42573662971f0dc531df7)) - - - -## [1.9.2](https://github.com/vitejs/vite/compare/plugin-vue@1.9.1...plugin-vue@1.9.2) (2021-09-24) - - -### Bug Fixes - -* **plugin-vue:** handle rewrite default edge case with TS ([609a342](https://github.com/vitejs/vite/commit/609a342986b2d3b05ef59dc23523239938264008)) - - -### Reverts - -* Revert "feat(plugin-vue): define __VUE_SSR__ flag" ([3e2c1bf](https://github.com/vitejs/vite/commit/3e2c1bf74bb8ef583d66c67c715fdeae8d8fe432)) - - - -## [1.9.1](https://github.com/vitejs/vite/compare/plugin-vue@1.9.0...plugin-vue@1.9.1) (2021-09-23) - - -### Features - -* ~~**plugin-vue:** define __VUE_SSR__ flag ([49618c1](https://github.com/vitejs/vite/commit/49618c17f38ee54ea17b4b04d58eb5fbf3e532fe))~~ (Reverted) - - - -# [1.9.0](https://github.com/vitejs/vite/compare/plugin-vue@1.8.1...plugin-vue@1.9.0) (2021-09-21) - - -### Bug Fixes - -* **plugin-vue:** enable ts in template also for lang=tsx ([ed88df3](https://github.com/vitejs/vite/commit/ed88df30a93d759e5c4ac0f079b9f604fad2ce40)) - - -### Features - -* **plugin-vue:** support optional @vue/compiler-sfc peer dep ([b17b5ae](https://github.com/vitejs/vite/commit/b17b5ae68de50413a95fb992ceda92ec0fceaa86)) - - - -## [1.8.1](https://github.com/vitejs/vite/compare/plugin-vue@1.8.0...plugin-vue@1.8.1) (2021-09-19) - - -### Bug Fixes - -* **plugin-vue:** generate tree-shakable code ([316d7af](https://github.com/vitejs/vite/commit/316d7afc0c84e51359938a12ebe1b09ca34ea8bd)) - - - -# [1.8.0](https://github.com/vitejs/vite/compare/plugin-vue@1.7.1...plugin-vue@1.8.0) (2021-09-18) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#4545](https://github.com/vitejs/vite/issues/4545)) ([a44fd5d](https://github.com/vitejs/vite/commit/a44fd5d38679da0be2536103e83af730cda73a95)) - - -### Performance Improvements - -* **plugin-vue:** inline main script for build + avoid sourcemap generation when possible ([93d9a2d](https://github.com/vitejs/vite/commit/93d9a2d175b1a1e3fe54197856a86887b1dadb74)) - - - -## [1.7.1](https://github.com/vitejs/vite/compare/plugin-vue@1.7.0...plugin-vue@1.7.1) (2021-09-18) - - -### Bug Fixes - -* **plugin-vue:** properly handle in-template TS syntax + tests ([0a2a5e1](https://github.com/vitejs/vite/commit/0a2a5e1c8b9d2765faecfb5e4641b1c5a94575e1)) - - - -# [1.7.0](https://github.com/vitejs/vite/compare/plugin-vue@1.6.2...plugin-vue@1.7.0) (2021-09-18) - - -### Features - -* **plugin-vue:** support TS in template expressions ([01fa2ab](https://github.com/vitejs/vite/commit/01fa2abe901834c1c3168c343120429700e82983)) - - - -## [1.6.2](https://github.com/vitejs/vite/compare/plugin-vue@1.6.1...plugin-vue@1.6.2) (2021-09-08) - - -### Bug Fixes - -* **plugin-vue:** ensure descriptor in case main request is cached ([85612fe](https://github.com/vitejs/vite/commit/85612fe69da98759dbf3b5352cf47a74f20374ff)) - - - -## [1.6.1](https://github.com/vitejs/vite/compare/plugin-vue@1.6.0...plugin-vue@1.6.1) (2021-09-06) - - -### Bug Fixes - -* hmr doesn't work when modifying the code of jsx in sfc ([#4563](https://github.com/vitejs/vite/issues/4563)) ([1012367](https://github.com/vitejs/vite/commit/101236794c5d6d28591302d5552cb1c0ab8f4115)) -* **plugin-vue:** avoid applying ref transform to dependencies by default ([cd4f341](https://github.com/vitejs/vite/commit/cd4f341201d5598c3ec9cc594949e7d5304ac7ec)) - - - -# [1.6.0](https://github.com/vitejs/vite/compare/plugin-vue@1.5.0...plugin-vue@1.6.0) (2021-08-24) - - -### Features - -* **plugin-vue:** latest ref transform support ([533b002](https://github.com/vitejs/vite/commit/533b0029adc912257251b5021879ab1d676a16ab)) -* **plugin-vue:** warn compiler-sfc version mismatch ([e7263b9](https://github.com/vitejs/vite/commit/e7263b98f2e174198b322d26c6a7207d706a6639)) - - - -# [1.5.0](https://github.com/vitejs/vite/compare/plugin-vue@1.4.0...plugin-vue@1.5.0) (2021-08-24) - - - -# [1.4.0](https://github.com/vitejs/vite/compare/plugin-vue@1.3.0...plugin-vue@1.4.0) (2021-08-07) - -### Features - -* Custom Elements mode behavior changed: now only inlines the CSS and no longer exports the custom element constructor (exports the component as in normal mode). Users now need to explicitly call `defineCustomElement` on the component. This allows the custom element to be defined using an async version of the source component. - -### Bug Fixes - -* revert update dependency slash to v4 ([#4118](https://github.com/vitejs/vite/issues/4118)) ([#4519](https://github.com/vitejs/vite/issues/4519)) ([9b4fe1f](https://github.com/vitejs/vite/commit/9b4fe1fa68c522878d1bdef87d7aa02ae08e986f)) - - - -# [1.3.0](https://github.com/vitejs/vite/compare/plugin-vue@1.2.5...plugin-vue@1.3.0) (2021-07-27) - - -### Bug Fixes - -* reuse the old preprocessor after changing the lang attr ([#4224](https://github.com/vitejs/vite/issues/4224)) ([7a3c6e6](https://github.com/vitejs/vite/commit/7a3c6e616385cbc069620ae583d6739a972c0ead)) - - -### Features - -* **plugin-vue:** support importing vue files as custom elements ([3a3af6e](https://github.com/vitejs/vite/commit/3a3af6eeafbc9fc686fc909ec6a61c61283316fc)) - - - -## [1.2.5](https://github.com/vitejs/vite/compare/plugin-vue@1.2.4...plugin-vue@1.2.5) (2021-07-12) - - - -## [1.2.4](https://github.com/vitejs/vite/compare/plugin-vue@1.2.3...plugin-vue@1.2.4) (2021-06-27) - - -### Bug Fixes - -* **ssr:** normalize manifest filenames ([#3706](https://github.com/vitejs/vite/issues/3706)) ([aa8ca3f](https://github.com/vitejs/vite/commit/aa8ca3f35218c9fb48f87d3f6f4681d379ee45ca)), closes [#3303](https://github.com/vitejs/vite/issues/3303) - - - -## [1.2.3](https://github.com/vitejs/vite/compare/plugin-vue@1.2.2...plugin-vue@1.2.3) (2021-06-01) - - -### Bug Fixes - -* **plugin-vue:** rewrite default after ts compiled ([#3591](https://github.com/vitejs/vite/issues/3591)) ([ea5bafa](https://github.com/vitejs/vite/commit/ea5bafaefbafd858389f88e537cb3473b4669802)) - - - -## [1.2.2](https://github.com/vitejs/vite/compare/plugin-vue@1.2.1...plugin-vue@1.2.2) (2021-04-24) - - -### Bug Fixes - -* **plugin-vue:** add newline character before class components, fix [#2787](https://github.com/vitejs/vite/issues/2787) ([#2933](https://github.com/vitejs/vite/issues/2933)) ([8fe828e](https://github.com/vitejs/vite/commit/8fe828e9be9e9de67463af6f5dc35ebdbfdbda28)) -* **plugin-vue:** avoid duplicate import, fix [#2640](https://github.com/vitejs/vite/issues/2640) ([#2897](https://github.com/vitejs/vite/issues/2897)) ([011438d](https://github.com/vitejs/vite/commit/011438d16dc42408d5229b842d67dba28868566b)) -* **plugin-vue:** respect `hmr: false` server config, fix [#2790](https://github.com/vitejs/vite/issues/2790) ([#2797](https://github.com/vitejs/vite/issues/2797)) ([27e0c3f](https://github.com/vitejs/vite/commit/27e0c3fffd32a0ff90d06a909a5d5cc7d73f44b0)) - - - -## [1.2.1](https://github.com/vitejs/vite/compare/plugin-vue@1.2.0...plugin-vue@1.2.1) (2021-03-31) - - -### Bug Fixes - -* **plugin-vue:** allow to overwrite feature flags ([#2675](https://github.com/vitejs/vite/issues/2675)) ([a4acc16](https://github.com/vitejs/vite/commit/a4acc161e10fb6d122f808ad6211feef389d41a9)) - - - -# [1.2.0](https://github.com/vitejs/vite/compare/plugin-vue@1.1.5...plugin-vue@1.2.0) (2021-03-26) - - -### Features - -* **plugin-vue:** enable :slotted usage detection ([c40c49f](https://github.com/vitejs/vite/commit/c40c49f6fa806406364f4982fe45a69db15c204f)) - - - -## [1.1.5](https://github.com/vitejs/vite/compare/plugin-vue@1.1.4...plugin-vue@1.1.5) (2021-02-26) - - -### Bug Fixes - -* **plugin-vue:** fix hmr when emptying sfc file ([#2142](https://github.com/vitejs/vite/issues/2142)) ([493b942](https://github.com/vitejs/vite/commit/493b94259d6a499e03684d6001fea1a96d56810c)), closes [#2128](https://github.com/vitejs/vite/issues/2128) -* **plugin-vue:** handle default rewrite edge case for commented class ([2900a9a](https://github.com/vitejs/vite/commit/2900a9a6a501628588b31f7453e2fe5a71fe45ce)), closes [#2277](https://github.com/vitejs/vite/issues/2277) -* **plugin-vue:** import vue file as raw correctly ([#1923](https://github.com/vitejs/vite/issues/1923)) ([5b56d70](https://github.com/vitejs/vite/commit/5b56d70c1d173d4c5e3d9532f9c3bc6f8bfc020c)) - - - -## [1.1.4](https://github.com/vitejs/vite/compare/plugin-vue@1.1.3...plugin-vue@1.1.4) (2021-01-30) - - -### Bug Fixes - -* **plugin-vue:** handle block src pointing to dependency files ([bb7da3f](https://github.com/vitejs/vite/commit/bb7da3f0f07da6558f0e81bd82ede4cfe1785a56)), closes [#1812](https://github.com/vitejs/vite/issues/1812) - - - -## [1.1.3](https://github.com/vitejs/vite/compare/plugin-vue@1.1.2...plugin-vue@1.1.3) (2021-01-29) - - -### Bug Fixes - -* **plugin-vue:** special handling for class default export in sfc ([d3397e6](https://github.com/vitejs/vite/commit/d3397e61cd9d0761606506dcc176a1cbc845d8b5)), closes [#1476](https://github.com/vitejs/vite/issues/1476) - - - -## [1.1.2](https://github.com/vitejs/vite/compare/plugin-vue@1.1.1...plugin-vue@1.1.2) (2021-01-24) - - - -## [1.1.1](https://github.com/vitejs/vite/compare/plugin-vue@1.1.0...plugin-vue@1.1.1) (2021-01-23) - - -### Bug Fixes - -* avoid eager hmr api access ([fa37456](https://github.com/vitejs/vite/commit/fa37456584a09b52b39a61760a6d130e261886ff)) - - -### Features - -* support `base` option during dev, deprecate `build.base` ([#1556](https://github.com/vitejs/vite/issues/1556)) ([809d4bd](https://github.com/vitejs/vite/commit/809d4bd3bf62d3bc6b35f182178922d2ab2175f1)) - - - -# [1.1.0](https://github.com/vitejs/vite/compare/plugin-vue@1.0.6...plugin-vue@1.1.0) (2021-01-19) - - -### Features - -* ssr manifest for preload inference ([107e79e](https://github.com/vitejs/vite/commit/107e79e7b7d422f0d1dbe8b7b435636df7c6281c)) -* **plugin-vue:** support for vite core new ssr impl ([a93ab23](https://github.com/vitejs/vite/commit/a93ab23491ee9fee78345ddc20567e1b0ceec2a7)) - - - -## [1.0.6](https://github.com/vitejs/vite/compare/plugin-vue@1.0.5...plugin-vue@1.0.6) (2021-01-15) - - -### Bug Fixes - -* **plugin-vue:** sfc src import respect alias ([#1544](https://github.com/vitejs/vite/issues/1544)) ([d8754de](https://github.com/vitejs/vite/commit/d8754deeb16ef0d86b17dfa2a3394d0919bcd72e)), closes [#1542](https://github.com/vitejs/vite/issues/1542) - - - -## [1.0.5](https://github.com/vitejs/vite/compare/plugin-vue@1.0.4...plugin-vue@1.0.5) (2021-01-09) - - -### Bug Fixes - -* **plugin-vue:** default pug doctype ([756a0f2](https://github.com/vitejs/vite/commit/756a0f26911e5bff9c1ea3f780a0a1eccd1f1cfd)), closes [#1383](https://github.com/vitejs/vite/issues/1383) -* **plugin-vue:** pass on script and style options to compiler-sfc ([0503d42](https://github.com/vitejs/vite/commit/0503d42aaddbc4b8428c94ede07cf7b84f800cef)), closes [#1450](https://github.com/vitejs/vite/issues/1450) - - - -## [1.0.4](https://github.com/vitejs/vite/compare/plugin-vue@1.0.3...plugin-vue@1.0.4) (2021-01-04) - - -### Bug Fixes - -* **plugin-vue:** mark SFC compiler options as `Partial` ([#1316](https://github.com/vitejs/vite/issues/1316)) ([331484c](https://github.com/vitejs/vite/commit/331484c2600e96543aa8007b4940d023cb5cc19f)) - - -### Features - -* **plugin-vue:** export vue query parse API ([#1303](https://github.com/vitejs/vite/issues/1303)) ([56bcb0c](https://github.com/vitejs/vite/commit/56bcb0c475a5dff31527cad6dcd7c61fde424f5e)) - - - -## [1.0.3](https://github.com/vitejs/vite/compare/plugin-vue@1.0.2...plugin-vue@1.0.3) (2021-01-02) - - -### Bug Fixes - -* **plugin-vue:** custom block prev handling ([8dbc2b4](https://github.com/vitejs/vite/commit/8dbc2b47dd8fea4a953fb05057edb47122e2dcb7)) - - -### Code Refactoring - -* **hmr:** pass context object to `handleHotUpdate` plugin hook ([b314771](https://github.com/vitejs/vite/commit/b3147710e96a8f88ab81b2e45dbf7e7174ad976c)) - - -### BREAKING CHANGES - -* **hmr:** `handleHotUpdate` plugin hook now receives a single -`HmrContext` argument instead of multiple args. - - - -## [1.0.2](https://github.com/vitejs/vite/compare/plugin-vue@1.0.2...plugin-vue@1.0.2) (2021-01-02) - - -### Bug Fixes - -* **plugin-vue:** avoid throwing on never requested file ([48a24c1](https://github.com/vitejs/vite/commit/48a24c1fa1f64e89ca853635580911859ef5881b)) -* **plugin-vue:** custom block prev handling ([8dbc2b4](https://github.com/vitejs/vite/commit/8dbc2b47dd8fea4a953fb05057edb47122e2dcb7)) -* avoid self referencing type in plugin-vue ([9cccdaa](https://github.com/vitejs/vite/commit/9cccdaa0935ca664c8a709a89ebd1f2216565546)) -* **plugin-vue:** ensure id on descriptor ([91217f6](https://github.com/vitejs/vite/commit/91217f6d968485303e71128bb79ad4400b9b4412)) diff --git a/packages/plugin-vue/LICENSE b/packages/plugin-vue/LICENSE deleted file mode 100644 index 9c1b313d7b1816..00000000000000 --- a/packages/plugin-vue/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/plugin-vue/README.md b/packages/plugin-vue/README.md deleted file mode 100644 index 30e2cd6ceb0399..00000000000000 --- a/packages/plugin-vue/README.md +++ /dev/null @@ -1,173 +0,0 @@ -# @vitejs/plugin-vue [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue.svg)](https://npmjs.com/package/@vitejs/plugin-vue) - -> Note: as of `vue` 3.2.13+ and `@vitejs/plugin-vue` 1.9.0+, `@vue/compiler-sfc` is no longer required as a peer dependency. - -```js -// vite.config.js -import vue from '@vitejs/plugin-vue' - -export default { - plugins: [vue()] -} -``` - -For JSX / TSX support, [`@vitejs/plugin-vue-jsx`](https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx) is also needed. - -## Options - -```ts -export interface Options { - include?: string | RegExp | (string | RegExp)[] - exclude?: string | RegExp | (string | RegExp)[] - - ssr?: boolean - isProduction?: boolean - - /** - * Transform Vue SFCs into custom elements (requires vue@^3.2.0) - * - `true` -> all `*.vue` imports are converted into custom elements - * - `string | RegExp` -> matched files are converted into custom elements - * - * @default /\.ce\.vue$/ - */ - customElement?: boolean | string | RegExp | (string | RegExp)[] - - /** - * Enable Vue reactivity transform (experimental, requires vue@^3.2.25). - * https://github.com/vuejs/core/tree/master/packages/reactivity-transform - * - * - `true`: transform will be enabled for all vue,js(x),ts(x) files except - * those inside node_modules - * - `string | RegExp`: apply to vue + only matched files (will include - * node_modules, so specify directories in necessary) - * - `false`: disable in all cases - * - * @default false - */ - reactivityTransform?: boolean | string | RegExp | (string | RegExp)[] - - // options to pass on to vue/compiler-sfc - script?: Partial> - template?: Partial< - Pick< - SFCTemplateCompileOptions, - | 'compiler' - | 'compilerOptions' - | 'preprocessOptions' - | 'preprocessCustomRequire' - | 'transformAssetUrls' - > - > - style?: Partial> -} -``` - -## Asset URL handling - -When `@vitejs/plugin-vue` compiles the `