Skip to content

Commit

Permalink
Merge branch 'main' into chore/terser-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed May 27, 2022
2 parents 706840f + a9ccedd commit c8d2e2d
Show file tree
Hide file tree
Showing 94 changed files with 2,001 additions and 1,191 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -74,6 +74,9 @@ jobs:
- name: Test build
run: pnpm run test-build

- name: Test docs
run: pnpm run test-docs

lint:
timeout-minutes: 10
runs-on: ubuntu-latest
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Expand Up @@ -19,8 +19,6 @@ jobs:

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6

- name: Set node version to 16.x
uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Expand Up @@ -5,3 +5,4 @@ hoist-pattern[]=postcss
hoist-pattern[]=pug
hoist-pattern[]=source-map-support
hoist-pattern[]=ts-node
strict-peer-dependencies=false
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -214,6 +214,8 @@ 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/types`. This way we can still expose the typing but bundle the dependency's source code.

Use `pnpm run check-dist-types` to check bundled types does not rely on types in `devDependencies`. If you are adding `dependencies`, make sure to configure `tsconfig.check.json`.

### Think before adding yet another option

We already have many config options, and we should avoid fixing an issue by adding yet another one. Before adding an option, try to think about:
Expand Down
2 changes: 1 addition & 1 deletion docs/config/dep-optimization-options.md
Expand Up @@ -8,7 +8,7 @@

By default, Vite will crawl all your `.html` files to detect dependencies that need to be pre-bundled (ignoring `node_modules`, `build.outDir`, `__tests__` and `coverage`). If `build.rollupOptions.input` is specified, Vite will crawl those entry points instead.

If neither of these fit your needs, you can specify custom entries using this option - the value should be a [fast-glob pattern](https://github.com/mrmlnc/fast-glob#basic-syntax) or array of patterns that are relative from Vite project root. This will overwrite default entries inference. Only `node_modules` and `build.outDir` folders will be ignored by default when `optimizeDeps.entries` is explicitily defined. If other folders needs to be ignored, you can use an ignore pattern as part of the entries list, marked with an initial `!`.
If neither of these fit your needs, you can specify custom entries using this option - the value should be a [fast-glob pattern](https://github.com/mrmlnc/fast-glob#basic-syntax) or array of patterns that are relative from Vite project root. This will overwrite default entries inference. Only `node_modules` and `build.outDir` folders will be ignored by default when `optimizeDeps.entries` is explicitly defined. If other folders needs to be ignored, you can use an ignore pattern as part of the entries list, marked with an initial `!`.

## optimizeDeps.exclude

Expand Down
22 changes: 12 additions & 10 deletions package.json
Expand Up @@ -21,6 +21,7 @@
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"test-unit": "vitest run",
"test-docs": "pnpm run docs-build",
"debug-serve": "cross-env VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts",
"debug-build": "cross-env VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts",
"docs": "vitepress dev docs",
Expand All @@ -33,7 +34,8 @@
"ci-docs": "run-s build docs-build"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.23.1",
"@babel/types": "^7.17.10",
"@microsoft/api-extractor": "^7.24.1",
"@rollup/plugin-typescript": "^8.3.2",
"@types/babel__core": "^7.1.19",
"@types/babel__standalone": "^7.1.4",
Expand All @@ -53,15 +55,15 @@
"@types/resolve": "^1.20.2",
"@types/sass": "~1.43.1",
"@types/semver": "^7.3.9",
"@types/stylus": "^0.48.37",
"@types/stylus": "^0.48.38",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"esbuild": "^0.14.38",
"eslint": "^8.15.0",
"eslint-define-config": "^1.4.0",
"eslint": "^8.16.0",
"eslint-define-config": "^1.4.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"esno": "^0.16.3",
Expand All @@ -73,8 +75,8 @@
"node-fetch": "^2.6.7",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.21.1",
"pnpm": "^7.1.2",
"playwright-chromium": "^1.22.2",
"pnpm": "^7.1.3",
"prettier": "2.6.2",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
Expand All @@ -88,7 +90,7 @@
"vite": "workspace:*",
"vitepress": "1.0.0-draft.4",
"vitest": "^0.12.9",
"vue": "^3.2.33"
"vue": "^3.2.35"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged --concurrent false",
Expand All @@ -108,7 +110,7 @@
"eslint --fix"
]
},
"packageManager": "pnpm@7.0.1",
"packageManager": "pnpm@7.1.3",
"pnpm": {
"overrides": {
"vite": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-vite/template-lit-ts/package.json
Expand Up @@ -17,10 +17,10 @@
"build": "tsc && vite build"
},
"dependencies": {
"lit": "^2.2.3"
"lit": "^2.2.4"
},
"devDependencies": {
"typescript": "^4.6.4",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-lit/package.json
Expand Up @@ -15,9 +15,9 @@
"build": "vite build"
},
"dependencies": {
"lit": "^2.2.3"
"lit": "^2.2.4"
},
"devDependencies": {
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact-ts/package.json
Expand Up @@ -14,6 +14,6 @@
"devDependencies": {
"@preact/preset-vite": "^2.2.0",
"typescript": "^4.6.4",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact/package.json
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"@preact/preset-vite": "^2.2.0",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-react-ts/package.json
Expand Up @@ -14,9 +14,9 @@
},
"devDependencies": {
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.3",
"@types/react-dom": "^18.0.4",
"@vitejs/plugin-react": "^1.3.2",
"typescript": "^4.6.4",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-react/package.json
Expand Up @@ -14,8 +14,8 @@
},
"devDependencies": {
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.3",
"@types/react-dom": "^18.0.4",
"@vitejs/plugin-react": "^1.3.2",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-svelte-ts/package.json
Expand Up @@ -10,13 +10,13 @@
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.43",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.44",
"@tsconfig/svelte": "^3.0.0",
"svelte": "^3.48.0",
"svelte-check": "^2.7.0",
"svelte-check": "^2.7.1",
"svelte-preprocess": "^4.10.6",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
4 changes: 2 additions & 2 deletions packages/create-vite/template-svelte/package.json
Expand Up @@ -9,8 +9,8 @@
"preview": "vite preview"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.43",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.44",
"svelte": "^3.48.0",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vanilla-ts/package.json
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"typescript": "^4.6.4",
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vanilla/package.json
Expand Up @@ -9,6 +9,6 @@
"preview": "vite preview"
},
"devDependencies": {
"vite": "^2.9.8"
"vite": "^2.9.9"
}
}
8 changes: 4 additions & 4 deletions packages/create-vite/template-vue-ts/package.json
Expand Up @@ -9,12 +9,12 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.33"
"vue": "^3.2.35"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.2",
"@vitejs/plugin-vue": "^2.3.3",
"typescript": "^4.6.4",
"vite": "^2.9.8",
"vue-tsc": "^0.34.11"
"vite": "^2.9.9",
"vue-tsc": "^0.34.15"
}
}
6 changes: 3 additions & 3 deletions packages/create-vite/template-vue/package.json
Expand Up @@ -9,10 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.33"
"vue": "^3.2.35"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.2",
"vite": "^2.9.8"
"@vitejs/plugin-vue": "^2.3.3",
"vite": "^2.9.9"
}
}
8 changes: 4 additions & 4 deletions packages/plugin-legacy/package.json
Expand Up @@ -35,9 +35,9 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
"dependencies": {
"@babel/standalone": "^7.17.11",
"core-js": "^3.22.4",
"magic-string": "^0.26.1",
"@babel/standalone": "^7.18.1",
"core-js": "^3.22.6",
"magic-string": "^0.26.2",
"regenerator-runtime": "^0.13.9",
"systemjs": "^6.12.1"
},
Expand All @@ -47,6 +47,6 @@
},
"devDependencies": {
"vite": "workspace:*",
"@babel/core": "^7.17.10"
"@babel/core": "^7.18.0"
}
}
10 changes: 10 additions & 0 deletions packages/plugin-react/CHANGELOG.md
@@ -1,3 +1,13 @@
## 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)
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-react/package.json
@@ -1,6 +1,6 @@
{
"name": "@vitejs/plugin-react",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"license": "MIT",
"author": "Evan You",
"contributors": [
Expand Down Expand Up @@ -39,10 +39,10 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
"dependencies": {
"@babel/core": "^7.17.10",
"@babel/plugin-transform-react-jsx": "^7.17.3",
"@babel/core": "^7.18.0",
"@babel/plugin-transform-react-jsx": "^7.17.12",
"@babel/plugin-transform-react-jsx-development": "^7.16.7",
"@babel/plugin-transform-react-jsx-self": "^7.16.7",
"@babel/plugin-transform-react-jsx-self": "^7.17.12",
"@babel/plugin-transform-react-jsx-source": "^7.16.7",
"@rollup/pluginutils": "^4.2.1",
"react-refresh": "^0.13.0",
Expand Down
13 changes: 8 additions & 5 deletions packages/plugin-react/src/index.ts
Expand Up @@ -2,7 +2,6 @@ import path from 'path'
import type { ParserOptions, TransformOptions, types as t } from '@babel/core'
import * as babel from '@babel/core'
import { createFilter } from '@rollup/pluginutils'
import resolve from 'resolve'
import { normalizePath } from 'vite'
import type { Plugin, PluginOption, ResolvedConfig } from 'vite'
import {
Expand Down Expand Up @@ -362,7 +361,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
}
}

const runtimeId = 'react/jsx-runtime'
// const runtimeId = 'react/jsx-runtime'
// Adapted from https://github.com/alloc/vite-react-jsx
const viteReactJsx: Plugin = {
name: 'vite:react-jsx',
Expand All @@ -373,10 +372,14 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
include: ['react/jsx-dev-runtime']
}
}
},
}
// TODO: this optimization may not be necesary and it is breacking esbuild+rollup compat,
// see https://github.com/vitejs/vite/pull/7246#discussion_r861552185
// We could still do the same trick and resolve to the optimized dependency here
/*
resolveId(id: string) {
return id === runtimeId ? id : null
},
},
load(id: string) {
if (id === runtimeId) {
const runtimePath = resolve.sync(runtimeId, {
Expand All @@ -391,7 +394,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
...exports.map((name) => `export const ${name} = jsxRuntime.${name}`)
].join('\n')
}
}
} */
}

return [viteBabel, viteReactRefresh, useAutomaticRuntime && viteReactJsx]
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue-jsx/package.json
Expand Up @@ -35,9 +35,9 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx#readme",
"dependencies": {
"@babel/core": "^7.17.10",
"@babel/core": "^7.18.0",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-typescript": "^7.16.8",
"@babel/plugin-transform-typescript": "^7.18.1",
"@rollup/pluginutils": "^4.2.1",
"@vue/babel-plugin-jsx": "^1.1.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue/package.json
Expand Up @@ -40,13 +40,13 @@
},
"devDependencies": {
"@jridgewell/gen-mapping": "^0.3.1",
"@jridgewell/trace-mapping": "^0.3.10",
"@jridgewell/trace-mapping": "^0.3.13",
"debug": "^4.3.4",
"rollup": "^2.72.1",
"slash": "^4.0.0",
"source-map": "^0.6.1",
"vite": "workspace:*",
"vue": "^3.2.33"
"vue": "^3.2.35"
},
"dependencies": {
"@rollup/pluginutils": "^4.2.1"
Expand Down

0 comments on commit c8d2e2d

Please sign in to comment.