Skip to content

Commit

Permalink
chore: main
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Dec 8, 2022
2 parents 575d142 + 962e593 commit ebc2f85
Show file tree
Hide file tree
Showing 789 changed files with 7,137 additions and 15,170 deletions.
97 changes: 51 additions & 46 deletions .eslintrc.cjs
Expand Up @@ -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' }],
Expand All @@ -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',
Expand All @@ -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
Expand All @@ -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',
Expand All @@ -96,56 +96,61 @@ 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/**/*.*',
rules: {
'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/**'],
Expand All @@ -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/**'],
Expand All @@ -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,
})
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
@@ -0,0 +1,4 @@
# chore: enable prettier trailing commas (#11167)
134ce6817984bad0f5fb043481502531fee9b1db
# chore: rename test packages (#11172)
5170e44920458090b8b43ee9cfe5010c25dfe22b
6 changes: 6 additions & 0 deletions .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.
Expand Down
8 changes: 4 additions & 4 deletions .github/renovate.json5
Expand Up @@ -8,8 +8,8 @@
"packageRules": [
{
"depTypeList": ["peerDependencies"],
"enabled": false
}
"enabled": false,
},
],
"ignoreDeps": [
// manually bumping
Expand All @@ -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
],
}
24 changes: 15 additions & 9 deletions .github/workflows/ci.yml
Expand Up @@ -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 }}"
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ecosystem-ci-trigger.yml
Expand Up @@ -26,7 +26,8 @@ jobs:
'poyoho',
'sapphi-red',
'ygj6',
'Niputi'
'Niputi',
'dominikg'
])
if (allowedUsers.has(user)) {
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.json
Expand Up @@ -3,7 +3,7 @@
"tabWidth": 2,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "none",
"trailingComma": "all",
"overrides": [
{
"files": ["*.json5"],
Expand Down
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down
13 changes: 5 additions & 8 deletions README.md
Expand Up @@ -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

Expand Down

0 comments on commit ebc2f85

Please sign in to comment.