Skip to content

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Aug 10, 2022
1 parent aa0b77f commit 270d65e
Show file tree
Hide file tree
Showing 108 changed files with 841 additions and 555 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.cjs
@@ -1,4 +1,5 @@
// @ts-check
const { builtinModules } = require('node:module')
const { defineConfig } = require('eslint-define-config')

module.exports = defineConfig({
Expand Down Expand Up @@ -81,6 +82,10 @@ module.exports = defineConfig({
{ prefer: 'type-imports' }
],

'import/no-nodejs-modules': [
'error',
{ allow: builtinModules.map((mod) => `node:${mod}`) }
],
'import/no-duplicates': 'error',
'import/order': 'error',
'sort-imports': [
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config.ts
Expand Up @@ -65,7 +65,8 @@ export default defineConfig({
['meta', { property: 'og:url', content: ogUrl }],
['meta', { property: 'og:description', content: ogDescription }],
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { name: 'twitter:site', content: '@vite_js' }]
['meta', { name: 'twitter:site', content: '@vite_js' }],
['meta', { name: 'theme-color', content: '#646cff' }]
],

vue: {
Expand Down
4 changes: 2 additions & 2 deletions docs/config/preview-options.md
Expand Up @@ -65,7 +65,7 @@ Automatically open the app in the browser on server start. When the value is a s
- **Type:** `Record<string, string | ProxyOptions>`
- **Default:** [`server.proxy`](./server-options#server-proxy)

Configure custom proxy rules for the dev server. Expects an object of `{ key: options }` pairs. If the key starts with `^`, it will be interpreted as a `RegExp`. The `configure` option can be used to access the proxy instance.
Configure custom proxy rules for the preview server. Expects an object of `{ key: options }` pairs. If the key starts with `^`, it will be interpreted as a `RegExp`. The `configure` option can be used to access the proxy instance.

Uses [`http-proxy`](https://github.com/http-party/node-http-proxy). Full options [here](https://github.com/http-party/node-http-proxy#options).

Expand All @@ -74,4 +74,4 @@ Uses [`http-proxy`](https://github.com/http-party/node-http-proxy). Full options
- **Type:** `boolean | CorsOptions`
- **Default:** [`server.cors`](./server-options#server-cors)

Configure CORS for the dev server. This is enabled by default and allows any origin. Pass an [options object](https://github.com/expressjs/cors) to fine tune the behavior or `false` to disable.
Configure CORS for the preview server. This is enabled by default and allows any origin. Pass an [options object](https://github.com/expressjs/cors) to fine tune the behavior or `false` to disable.
12 changes: 6 additions & 6 deletions docs/guide/build.md
Expand Up @@ -208,9 +208,9 @@ A user may choose to deploy in three different paths:

A single static [base](#public-base-path) isn't enough in these scenarios. Vite provides experimental support for advanced base options during build, using `experimental.renderBuiltUrl`.

```js
```ts
experimental: {
renderBuiltUrl: (filename: string, { hostType: 'js' | 'css' | 'html' }) => {
renderBuiltUrl(filename: string, { hostType }: { hostType: 'js' | 'css' | 'html' }) {
if (hostType === 'js') {
return { runtime: `window.__toCdnUrl(${JSON.stringify(filename)})` }
} else {
Expand All @@ -220,15 +220,15 @@ experimental: {
}
```

If the hashed assets and public files aren't deployed together, options for each group can be defined independently using asset `type` included in the third `context` param given to the function.
If the hashed assets and public files aren't deployed together, options for each group can be defined independently using asset `type` included in the second `context` param given to the function.

```js
```ts
experimental: {
renderBuiltUrl(filename: string, { hostType: 'js' | 'css' | 'html', type: 'public' | 'asset' }) {
renderBuiltUrl(filename: string, { hostId, hostType, type }: { hostId: string, hostType: 'js' | 'css' | 'html', type: 'public' | 'asset' }) {
if (type === 'public') {
return 'https://www.domain.com/' + filename
}
else if (path.extname(importer) === '.js') {
else if (path.extname(hostId) === '.js') {
return { runtime: `window.__assetsPath(${JSON.stringify(filename)})` }
}
else {
Expand Down
10 changes: 5 additions & 5 deletions docs/guide/env-and-mode.md
Expand Up @@ -46,7 +46,7 @@ In addition, environment variables that already exist when Vite is executed have

Loaded env variables are also exposed to your client source code via `import.meta.env` as strings.

To prevent accidentally leaking env variables to the client, only variables prefixed with `VITE_` are exposed to your Vite-processed code. e.g. the following file:
To prevent accidentally leaking env variables to the client, only variables prefixed with `VITE_` are exposed to your Vite-processed code. e.g. for the following env variables:

```
VITE_SOME_KEY=123
Expand All @@ -60,7 +60,7 @@ console.log(import.meta.env.VITE_SOME_KEY) // 123
console.log(import.meta.env.DB_PASSWORD) // undefined
```
If you want to customize env variables prefix, see [envPrefix](/config/shared-options.html#envprefix) option.
If you want to customize the env variables prefix, see the [envPrefix](/config/shared-options.html#envprefix) option.
:::warning SECURITY NOTES
Expand All @@ -71,9 +71,9 @@ If you want to customize env variables prefix, see [envPrefix](/config/shared-op
### IntelliSense for TypeScript
By default, Vite provides type definition for `import.meta.env` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). While you can define more custom env variables in `.env.[mode]` files, you may want to get TypeScript IntelliSense for user-defined env variables which prefixed with `VITE_`.
By default, Vite provides type definitions for `import.meta.env` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). While you can define more custom env variables in `.env.[mode]` files, you may want to get TypeScript IntelliSense for user-defined env variables that are prefixed with `VITE_`.
To achieve, you can create an `env.d.ts` in `src` directory, then augment `ImportMetaEnv` like this:
To achieve this, you can create an `env.d.ts` in `src` directory, then augment `ImportMetaEnv` like this:
```typescript
/// <reference types="vite/client" />
Expand All @@ -98,7 +98,7 @@ If your code relies on types from browser environments such as [DOM](https://git
## Modes
By default, the dev server (`dev` command) runs in `development` mode and the `build` command run in `production` mode.
By default, the dev server (`dev` command) runs in `development` mode and the `build` command runs in `production` mode.
This means when running `vite build`, it will load the env variables from `.env.production` if there is one:
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/features.md
Expand Up @@ -122,8 +122,8 @@ 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 2.7 support via [vitejs/vite-plugin-vue2](https://github.com/vitejs/vite-plugin-vue2)
- Vue <2.7 support via [underfin/vite-plugin-vue2](https://github.com/underfin/vite-plugin-vue2)
- 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)

## JSX

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/ssr.md
Expand Up @@ -211,7 +211,7 @@ If the routes and the data needed for certain routes are known ahead of time, we
Dependencies are "externalized" from Vite's SSR transform module system by default when running SSR. This speeds up both dev and build.
If a dependency needs to be transformed by Vite's pipeline, for example, because Vite features are used untranspiled in them, they can be added to [`ssr.noExternal`](../config/ssr-options.md#ssrnoexternal).
If a dependency needs to be transformed by Vite's pipeline, for example, because Vite features are used untranspiled in them, they can be added to [`ssr.noExternal`](../config/ssr-options.md#ssr-noexternal).
:::warning Working with Aliases
If you have configured aliases that redirects one package to another, you may want to alias the actual `node_modules` packages instead to make it work for SSR externalized dependencies. Both [Yarn](https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias) and [pnpm](https://pnpm.js.org/en/aliases) support aliasing via the `npm:` prefix.
Expand Down Expand Up @@ -267,4 +267,4 @@ Use a post hook so that your SSR middleware runs _after_ Vite's middlewares.
## SSR Format
By default, Vite generates the SSR bundle in ESM. There is experimental support for configuring `ssr.format`, but it isn't recommended. Future efforts around SSR development will be based on ESM, and commonjs remain available for backward compatibility. If using ESM for SSR isn't possible in your project, you can set `legacy.buildSsrCjsExternalHeuristics: true` to generate a CJS bundle using the same [externalization heuristics of Vite v2](https://v2.vitejs.dev/guide/ssr.html#ssr-externals).
By default, Vite generates the SSR bundle in ESM. There is experimental support for configuring `ssr.format`, but it isn't recommended. Future efforts around SSR development will be based on ESM, and CommonJS remain available for backward compatibility. If using ESM for SSR isn't possible in your project, you can set `legacy.buildSsrCjsExternalHeuristics: true` to generate a CJS bundle using the same [externalization heuristics of Vite v2](https://v2.vitejs.dev/guide/ssr.html#ssr-externals).
35 changes: 35 additions & 0 deletions docs/guide/static-deploy.md
Expand Up @@ -131,6 +131,8 @@ You can also run the above script in your CI setup to enable automatic deploymen

## Netlify

### Netlify CLI

1. Install the [Netlify CLI](https://cli.netlify.com/).
2. Create a new site using `ntl init`.
3. Deploy using `ntl deploy`.
Expand All @@ -153,6 +155,16 @@ The Netlify CLI will share with you a preview URL to inspect. When you are ready
$ ntl deploy --prod
```

### Netlify with Git

1. Push your code to a git repository (GitHub, GitLab, BitBucket, Azure DevOps).
2. [Import the project](https://app.netlify.com/start) to Netlify.
3. Choose the branch, output directory, and set up environment variables if applicable.
4. Click on **Deploy**.
5. Your Vite app is deployed!

After your project has been imported and deployed, all subsequent pushes to branches other than the production branch along with pull requests will generate [Preview Deployments](https://docs.netlify.com/site-deploys/deploy-previews/), and all changes made to the Production Branch (commonly “main”) will result in a [Production Deployment](https://docs.netlify.com/site-deploys/overview/#definitions).

## Vercel

### Vercel CLI
Expand Down Expand Up @@ -331,3 +343,26 @@ Install the extension in VS Code and navigate to your app root. Open the Static
Follow the wizard started by the extension to give your app a name, choose a framework preset, and designate the app root (usually `/`) and built file location `/dist`. The wizard will run and will create a GitHub action in your repo in a `.github` folder.

The action will work to deploy your app (watch its progress in your repo's Actions tab) and, when successfully completed, you can view your app in the address provided in the extension's progress window by clicking the 'Browse Website' button that appears when the GitHub action has run.

## Render

You can deploy your Vite app as a Static Site on [Render](https://render.com/).

1. Create a [Render account](https://dashboard.render.com/register).

2. In the [Dashboard](https://dashboard.render.com/), click the **New** button and select **Static Site**.

3. Connect your GitHub/GitLab account or use a public repository.

4. Specify a project name and branch.

- **Build Command**: `npm run build`
- **Publish Directory**: `dist`

5. Click **Create Static Site**.

Your app should be deployed at `https://<PROJECTNAME>.onrender.com/`.

By default, any new commit pushed to the specified branch will automatically trigger a new deploy. [Auto-Deploy](https://render.com/docs/deploys#toggling-auto-deploy-for-a-service) can be configured in the project settings.

You can also add a [custom domain](https://render.com/docs/custom-domains) to your project.
4 changes: 2 additions & 2 deletions docs/guide/troubleshooting.md
Expand Up @@ -8,12 +8,12 @@ If the suggestions here don't work, please try posting questions on [GitHub Disc

### `Error: Cannot find module 'C:\foo\bar&baz\vite\bin\vite.js'`

The path to your project folder may include `?`, which doesn't work with `npm` on Windows ([npm/cmd-shim#45](https://github.com/npm/cmd-shim/issues/45)).
The path to your project folder may include `&`, which doesn't work with `npm` on Windows ([npm/cmd-shim#45](https://github.com/npm/cmd-shim/issues/45)).

You will need to either:

- Switch to another package manager (e.g. `pnpm`, `yarn`)
- Remove `?` from the path to your project
- Remove `&` from the path to your project

## Dev Server

Expand Down
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -36,8 +36,8 @@
"ci-docs": "run-s build docs-build"
},
"devDependencies": {
"@babel/types": "^7.18.9",
"@microsoft/api-extractor": "^7.28.7",
"@babel/types": "^7.18.10",
"@microsoft/api-extractor": "^7.29.0",
"@rollup/plugin-typescript": "^8.3.4",
"@types/babel__core": "^7.1.19",
"@types/babel__standalone": "^7.1.4",
Expand All @@ -57,8 +57,8 @@
"@types/semver": "^7.3.10",
"@types/stylus": "^0.48.38",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"esbuild": "^0.14.47",
Expand All @@ -73,20 +73,20 @@
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.24.2",
"pnpm": "^7.8.0",
"pnpm": "^7.9.0",
"prettier": "2.7.1",
"prompts": "^2.4.2",
"rimraf": "^3.0.2",
"rollup": "^2.75.6",
"semver": "^7.3.7",
"simple-git-hooks": "^2.8.0",
"tslib": "^2.4.0",
"tsx": "^3.8.0",
"tsx": "^3.8.1",
"typescript": "^4.6.4",
"unbuild": "^0.7.6",
"vite": "workspace:*",
"vitepress": "^1.0.0-alpha.4",
"vitest": "^0.20.2",
"vitest": "^0.21.0",
"vue": "^3.2.37"
},
"simple-git-hooks": {
Expand All @@ -107,7 +107,7 @@
"eslint --cache --fix"
]
},
"packageManager": "pnpm@7.8.0",
"packageManager": "pnpm@7.9.0",
"pnpm": {
"overrides": {
"vite": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact-ts/package.json
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.10.0"
"preact": "^10.10.1"
},
"devDependencies": {
"@preact/preset-vite": "^2.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-preact/package.json
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"preact": "^10.10.0"
"preact": "^10.10.1"
},
"devDependencies": {
"@preact/preset-vite": "^2.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-react-ts/package.json
Expand Up @@ -13,7 +13,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.15",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.0.0",
"typescript": "^4.6.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-react/package.json
Expand Up @@ -13,7 +13,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.15",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.0.0",
"vite": "^3.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue-ts/package.json
Expand Up @@ -15,6 +15,6 @@
"@vitejs/plugin-vue": "^3.0.1",
"typescript": "^4.6.4",
"vite": "^3.0.4",
"vue-tsc": "^0.39.4"
"vue-tsc": "^0.39.5"
}
}
4 changes: 2 additions & 2 deletions packages/plugin-legacy/package.json
Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#readme",
"dependencies": {
"@babel/standalone": "^7.18.9",
"@babel/standalone": "^7.18.12",
"core-js": "^3.24.1",
"magic-string": "^0.26.2",
"regenerator-runtime": "^0.13.9",
Expand All @@ -46,7 +46,7 @@
"vite": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.18.9",
"@babel/core": "^7.18.10",
"vite": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions packages/plugin-react/package.json
Expand Up @@ -39,8 +39,8 @@
},
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
"dependencies": {
"@babel/core": "^7.18.9",
"@babel/plugin-transform-react-jsx": "^7.18.6",
"@babel/core": "^7.18.10",
"@babel/plugin-transform-react-jsx": "^7.18.10",
"@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.18.6",
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.18.9",
"@babel/core": "^7.18.10",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-typescript": "^7.18.8",
"@babel/plugin-transform-typescript": "^7.18.12",
"@vue/babel-plugin-jsx": "^1.1.1"
},
"devDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions packages/vite/CHANGELOG.md
@@ -1,3 +1,26 @@
## <small>3.0.5 (2022-08-09)</small>

* fix: allow tree-shake glob eager css in js (#9547) ([2e309d6](https://github.com/vitejs/vite/commit/2e309d6)), closes [#9547](https://github.com/vitejs/vite/issues/9547)
* fix: ignore tsconfig target when bundling config (#9457) ([c5e7895](https://github.com/vitejs/vite/commit/c5e7895)), closes [#9457](https://github.com/vitejs/vite/issues/9457)
* fix: log worker plugins in debug mode (#9553) ([c1fa219](https://github.com/vitejs/vite/commit/c1fa219)), closes [#9553](https://github.com/vitejs/vite/issues/9553)
* fix: tree-shake modulepreload polyfill (#9531) ([1f11a70](https://github.com/vitejs/vite/commit/1f11a70)), closes [#9531](https://github.com/vitejs/vite/issues/9531)
* fix: update dep types (fixes #9475) (#9489) ([937cecc](https://github.com/vitejs/vite/commit/937cecc)), closes [#9475](https://github.com/vitejs/vite/issues/9475) [#9489](https://github.com/vitejs/vite/issues/9489)
* fix(build): normalized output log (#9594) ([8bae103](https://github.com/vitejs/vite/commit/8bae103)), closes [#9594](https://github.com/vitejs/vite/issues/9594)
* fix(config): try catch unlink after load (#9577) ([d35a1e2](https://github.com/vitejs/vite/commit/d35a1e2)), closes [#9577](https://github.com/vitejs/vite/issues/9577)
* fix(config): use file url for import path (fixes #9471) (#9473) ([22084a6](https://github.com/vitejs/vite/commit/22084a6)), closes [#9471](https://github.com/vitejs/vite/issues/9471) [#9473](https://github.com/vitejs/vite/issues/9473)
* 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(ssr): check root import extension for external (#9494) ([ff89df5](https://github.com/vitejs/vite/commit/ff89df5)), closes [#9494](https://github.com/vitejs/vite/issues/9494)
* fix(ssr): use appendRight for import (#9554) ([dfec6ca](https://github.com/vitejs/vite/commit/dfec6ca)), closes [#9554](https://github.com/vitejs/vite/issues/9554)
* refactor(resolve): remove commonjs plugin handling (#9460) ([2042b91](https://github.com/vitejs/vite/commit/2042b91)), closes [#9460](https://github.com/vitejs/vite/issues/9460)
* chore: init imports var before use (#9569) ([905b8eb](https://github.com/vitejs/vite/commit/905b8eb)), closes [#9569](https://github.com/vitejs/vite/issues/9569)
* chore: node prefix lint (#9514) ([9e9cd23](https://github.com/vitejs/vite/commit/9e9cd23)), closes [#9514](https://github.com/vitejs/vite/issues/9514)
* chore: tidy up eslint config (#9468) ([f4addcf](https://github.com/vitejs/vite/commit/f4addcf)), closes [#9468](https://github.com/vitejs/vite/issues/9468)
* chore(deps): update all non-major dependencies (#9478) ([c530d16](https://github.com/vitejs/vite/commit/c530d16)), closes [#9478](https://github.com/vitejs/vite/issues/9478)
* docs: fix incomplete comment (#9466) ([5169c51](https://github.com/vitejs/vite/commit/5169c51)), closes [#9466](https://github.com/vitejs/vite/issues/9466)
* feat(ssr): debug failed node resolve (#9432) ([364aae1](https://github.com/vitejs/vite/commit/364aae1)), closes [#9432](https://github.com/vitejs/vite/issues/9432)



## <small>3.0.4 (2022-07-29)</small>

* fix: __VITE_PUBLIC_ASSET__hash__ in HTML (#9247) ([a2b24ee](https://github.com/vitejs/vite/commit/a2b24ee)), closes [#9247](https://github.com/vitejs/vite/issues/9247)
Expand Down

0 comments on commit 270d65e

Please sign in to comment.