Skip to content

Commit

Permalink
Merge pull request #1 from vitejs/main
Browse files Browse the repository at this point in the history
update from upstream
  • Loading branch information
ygj6 authored Apr 21, 2021
2 parents 7e98c07 + 61ea320 commit 7a3e689
Show file tree
Hide file tree
Showing 112 changed files with 1,331 additions and 340 deletions.
34 changes: 33 additions & 1 deletion .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Each test can be run under either dev server mode or build mode.

- You can also use `yarn test-serve [match]` or `yarn test-build [match]` to run tests in a specific playground package, e.g. `yarn test-serve css` will run tests for both `playground/css` and `playground/css-codesplit` under serve mode.

Note package matching is not aviable for the `yarn test` script, which always runs all tests.
Note package matching is not available for the `yarn test` script, which always runs all tests.

### Test Env and Helpers

Expand All @@ -43,6 +43,38 @@ test('should work', async () => {

Some common test helpers, e.g. `testDir`, `isBuild` or `editFile` are available in `packages/playground/testUtils.ts`.

### Extending the Test Suite

To add new tests, you should find a related playground to the fix or feature (or create a new one). As an example, static assets loading are tested in the [assets playground](https://github.com/vitejs/vite/tree/main/packages/playground/assets). In this Vite App, there is a test for `?raw` imports, with [a section is defined in the `index.html` for it](https://github.com/vitejs/vite/blob/71215533ac60e8ff566dc3467feabfc2c71a01e2/packages/playground/assets/index.html#L121):

```html
<h2>?raw import</h2>
<code class="raw"></code>
```

This will be modified [with the result of a file import](https://github.com/vitejs/vite/blob/71215533ac60e8ff566dc3467feabfc2c71a01e2/packages/playground/assets/index.html#L151):

```js
import rawSvg from './nested/fragment.svg?raw'
text('.raw', rawSvg)
```

Where the `text` util is defined as:

```js
function text(el, text) {
document.querySelector(el).textContent = text
}
```

In the [spec tests](https://github.com/vitejs/vite/blob/71215533ac60e8ff566dc3467feabfc2c71a01e2/packages/playground/assets/__tests__/assets.spec.ts#L180), the modifications to the DOM listed above are used to test this feature:

```js
test('?raw import', async () => {
expect(await page.textContent('.raw')).toMatch('SVG')
})
```

## Pull Request Guidelines

- Checkout a topic branch from a base branch, e.g. `main`, and merge back against that branch.
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

env:
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: --max-old-space-size=6144

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node_version: [12, 14, 15]
include:
- os: macos-latest
node_version: 14
- os: windows-latest
node_version: 14
fail-fast: false

name: 'Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}

- name: Get yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Set dependencies cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-${{ matrix.node_version }}-
- name: Versions
run: yarn versions

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build vite
run: yarn build-vite

- name: Build plugin-vue
run: yarn build-plugin-vue

- name: Test serve
run: yarn test-serve --runInBand

- name: Test build
run: yarn test-build --runInBand

lint:
runs-on: ubuntu-latest
name: 'Lint: node-14, ubuntu-latest'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set node version to 14
uses: actions/setup-node@v2
with:
node-version: 14

- name: Set dependencies cache
uses: actions/cache@v2
with:
path: ~/.cache/yarn
key: lint-dependencies-${{ hashFiles('yarn.lock') }}
restore-keys: |
lint-dependencies-${{ hashFiles('yarn.lock') }}
lint-dependencies-
- name: Prepare
run: |
yarn install --frozen-lockfile
yarn build-vite
yarn build-plugin-vue
- name: Lint
run: yarn lint
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team by DM at [Vite Land](chat.vitejs.dev). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team by DM at [Vite Land](https://chat.vitejs.dev). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Expand Down
5 changes: 4 additions & 1 deletion docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ module.exports = {

algolia: {
apiKey: 'b573aa848fd57fb47d693b531297403c',
indexName: 'vitejs'
indexName: 'vitejs',
searchParameters: {
facetFilters: ['tags:en']
}
},

carbonAds: {
Expand Down
7 changes: 7 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ export default async ({ command, mode }) => {

See [The `public` Directory](/guide/assets#the-public-directory) for more details.

### cacheDir

- **Type:** `string`
- **Default:** `"node_modules/.vite"`

Directory to save cache files. Files in this directory are pre-bundled deps or some other cache files that generated by vite, which can improve the performance. You can use `--force` flag or manually delete the directory to regenerate the cache files. The value can be either an absolute file system path or a path relative to project root.

### resolve.alias

- **Type:**
Expand Down
1 change: 1 addition & 0 deletions docs/guide/api-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const { createServer } = require('vite')
The `InlineConfig` interface extends `UserConfig` with additional properties:

- `configFile`: specify config file to use. If not set, Vite will try to automatically resolve one from project root. Set to `false` to disable auto resolving.
- `envFile`: Set to `false` to disable `.env` files.

## `ViteDevServer`

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo

### `configResolved`

- **Type:** `(config: ResolvedConfig) => void`
- **Kind:** `sync`, `sequential`
- **Type:** `(config: ResolvedConfig) => void | Promise<void>`
- **Kind:** `async`, `parallel`

Called after the Vite config is resolved. Use this hook to read and store the final resolved config. It is also useful when the plugin needs to do something different based the command is being run.

Expand Down
2 changes: 2 additions & 0 deletions docs/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ module.exports = {
}
```

If you specify a different root, remember that `__dirname` will still be the folder of your vite.config.js file when resolving the input paths. Therfore, you will need to add your `root` entry to the arguments for `resolve`.

## Library Mode

When you are developing a browser-oriented library, you are likely spending most of the time on a test/demo page that imports your actual library. With Vite, you can use your `index.html` for that purpose to get the smooth development experience.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const modules = {
Note that:

- This is a Vite-only feature and is not a web or ES standard.
- The glob patterns are treated like import specifiers: they must be either relative (start with `./`) or absolute (start with `/`, resolved relative to project root). Globbing from dependencies is not supported.
- The glob patterns are treated like import specifiers: they must be either relative (start with `./`) or absolute (start with `/`, resolved relative to project root).
- The glob matching is done via `fast-glob` - check out its documentation for [supported glob patterns](https://github.com/mrmlnc/fast-glob#pattern-syntax).

## Web Assembly
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/why.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Vite improves the dev server start time by first dividing the modules in an appl

- **Source code** often contains non-plain JavaScript that needs transforming (e.g. JSX, CSS or Vue/Svelte components), and will be edited very often. Also, not all source code needs to be loaded at the same time (e.g. with route-based code-splitting).

Vite serves source code over [native ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). This is essentially letting the browser taking over part of the job of a bundler: Vite only needs to transform and serve source code on demand, as the browser requests them. Code behind conditional dynamic imports are only processed if actually used on the current screen.
Vite serves source code over [native ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). This is essentially letting the browser take over part of the job of a bundler: Vite only needs to transform and serve source code on demand, as the browser requests it. Code behind conditional dynamic imports is only processed if actually used on the current screen.

![bundler based dev server](/images/bundler.png)

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
"@types/jest": "^26.0.19",
"@types/node": "^14.14.10",
"@types/semver": "^7.3.4",
"@typescript-eslint/parser": "^4.9.1",
"@typescript-eslint/parser": "^4.22.0",
"chalk": "^4.1.0",
"conventional-changelog-cli": "^2.1.1",
"cross-env": "^7.0.3",
"enquirer": "^2.3.6",
"eslint": "^7.15.0",
"eslint-define-config": "^1.0.3",
"eslint": "^7.24.0",
"eslint-define-config": "^1.0.7",
"eslint-plugin-node": "^11.1.0",
"execa": "^5.0.0",
"fs-extra": "^9.0.1",
"jest": "^26.6.3",
"lint-staged": "^10.5.3",
"lint-staged": "^10.5.4",
"minimist": "^1.2.5",
"node-fetch": "^2.6.1",
"npm-run-all": "^4.1.5",
Expand Down
16 changes: 16 additions & 0 deletions packages/create-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [2.2.4](https://github.com/vitejs/vite/compare/create-app@2.2.3...create-app@2.2.4) (2021-04-15)


### Bug Fixes

* **create-app:** change index.html templates' favicon.svg href to absolute URL ([#2620](https://github.com/vitejs/vite/issues/2620)) ([3816f6e](https://github.com/vitejs/vite/commit/3816f6edb67e6bdf94db98e82e8acff4029bfe48))
* **create-app:** the node in the svelte template is incorrectly mounted ([#2947](https://github.com/vitejs/vite/issues/2947)) ([0825f7e](https://github.com/vitejs/vite/commit/0825f7ee3574ae3f28f566da27835fbf3b210fac))


### Features

* **create-app:** add template vanilla-ts ([#2023](https://github.com/vitejs/vite/issues/2023)) ([89898d3](https://github.com/vitejs/vite/commit/89898d36cbe03bce9b6a7ab80a1c45de9989e56e))
* **create-app:** two-level prompt for framework and variants ([#2941](https://github.com/vitejs/vite/issues/2941)) ([176e55d](https://github.com/vitejs/vite/commit/176e55dd1bf0232f483697d35b95f6e29a47fd74))



## [2.2.3](https://github.com/vitejs/vite/compare/create-app@2.2.2...create-app@2.2.3) (2021-03-31)


Expand Down
1 change: 1 addition & 0 deletions packages/create-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ yarn create @vitejs/app my-vue-app --template vue
Currently supported template presets include:

- `vanilla`
- `vanilla-ts`
- `vue`
- `vue-ts`
- `react`
Expand Down
Loading

0 comments on commit 7a3e689

Please sign in to comment.