mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
workflow: switch to pnpm (#5060)
This commit is contained in:
parent
6011665ca2
commit
3e1cce01d0
17
.eslintrc.js
17
.eslintrc.js
@ -29,7 +29,14 @@ module.exports = defineConfig({
|
||||
'node/no-missing-import': [
|
||||
'error',
|
||||
{
|
||||
allowModules: ['types', 'estree', 'testUtils', 'stylus'],
|
||||
allowModules: [
|
||||
'types',
|
||||
'estree',
|
||||
'testUtils',
|
||||
'less',
|
||||
'sass',
|
||||
'stylus'
|
||||
],
|
||||
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
|
||||
}
|
||||
],
|
||||
@ -37,7 +44,7 @@ module.exports = defineConfig({
|
||||
'error',
|
||||
{
|
||||
// for try-catching yarn pnp
|
||||
allowModules: ['pnpapi'],
|
||||
allowModules: ['pnpapi', 'vite'],
|
||||
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
|
||||
}
|
||||
],
|
||||
@ -91,6 +98,12 @@ module.exports = defineConfig({
|
||||
'no-console': ['error']
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['packages/vite/types/**'],
|
||||
rules: {
|
||||
'node/no-extraneous-import': 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['packages/playground/**'],
|
||||
rules: {
|
||||
|
59
.github/workflows/ci.yml
vendored
59
.github/workflows/ci.yml
vendored
@ -33,44 +33,34 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.15.1
|
||||
|
||||
- name: Set node version to ${{ matrix.node_version }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node_version }}
|
||||
cache: "pnpm"
|
||||
|
||||
- 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: Install deps
|
||||
run: pnpm install
|
||||
|
||||
- name: Build vite
|
||||
run: yarn ci-build-vite
|
||||
run: pnpm run ci-build-vite
|
||||
|
||||
- name: Build plugin-vue
|
||||
run: yarn build-plugin-vue
|
||||
run: pnpm run build-plugin-vue
|
||||
|
||||
- name: Build plugin-react
|
||||
run: yarn build-plugin-react
|
||||
run: pnpm run build-plugin-react
|
||||
|
||||
- name: Test serve
|
||||
run: yarn test-serve --runInBand
|
||||
run: pnpm run test-serve -- --runInBand
|
||||
|
||||
- name: Test build
|
||||
run: yarn test-build --runInBand
|
||||
run: pnpm run test-build -- --runInBand
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
@ -80,25 +70,24 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.15.1
|
||||
|
||||
- name: Set node version to 14
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
cache: "pnpm"
|
||||
|
||||
- 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: Install deps
|
||||
run: pnpm install
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn ci-build-vite
|
||||
yarn build-plugin-vue
|
||||
pnpm run ci-build-vite
|
||||
pnpm run build-plugin-vue
|
||||
|
||||
- name: Lint
|
||||
run: yarn lint
|
||||
run: pnpm run lint
|
||||
|
@ -6,5 +6,6 @@ packages/plugin-vue/dist/
|
||||
packages/*/CHANGELOG.md
|
||||
LICENSE.md
|
||||
.prettierignore
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
||||
pnpm-workspace.yaml
|
||||
packages/playground/tsconfig-json-load-error/has-error/tsconfig.json
|
||||
|
@ -4,15 +4,15 @@ Hi! We are really excited that you are interested in contributing to Vite. Befor
|
||||
|
||||
## Repo Setup
|
||||
|
||||
The Vite repo is a monorepo using Yarn workspaces. The package manager used to install and link dependencies must be [Yarn v1](https://classic.yarnpkg.com/).
|
||||
The Vite repo is a monorepo using pnpm workspaces. The package manager used to install and link dependencies must be [pnpm](https://pnpm.io/).
|
||||
|
||||
To development and test the core `vite` package:
|
||||
|
||||
1. Go to `packages/vite` and run `yarn dev`. This starts `rollup` in watch mode.
|
||||
1. Go to `packages/vite` and run `pnpm run dev`. This starts `rollup` in watch mode.
|
||||
|
||||
2. Run `yarn link` in `packages/vite`. This links `vite` globally so that you can:
|
||||
2. Run `pnpm link` in `packages/vite`. This links `vite` globally so that you can:
|
||||
|
||||
- Run `yarn link vite` in another Vite project to use the locally built Vite;
|
||||
- Run `pnpm link vite` in another Vite project to use the locally built Vite;
|
||||
- Use the `vite` binary anywhere.
|
||||
|
||||
## Running Tests
|
||||
@ -21,15 +21,15 @@ Each package under `packages/playground/` contains a `__tests__` directory. The
|
||||
|
||||
Each test can be run under either dev server mode or build mode.
|
||||
|
||||
- `yarn test` by default runs every test in both serve and build mode.
|
||||
- `pnpm test` by default runs every test in both serve and build mode.
|
||||
|
||||
- `yarn test-serve` runs tests only under serve mode.
|
||||
- `pnpm run test-serve` runs tests only under serve mode. This is just calling `jest` so you can pass any Jest flags to this command. Since Jest will attempt to run tests in parallel, if your machine has many cores this may cause flaky test failures with multiple Playwright instances running at the same time. You can force the tests to run in series with `pnpm run test-serve -- --runInBand`.
|
||||
|
||||
- `yarn test-build` runs tests only under build mode.
|
||||
- `pnpm run test-build` runs tests only under 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.
|
||||
- You can also use `pnpm run test-serve -- [match]` or `pnpm run test-build -- [match]` to run tests in a specific playground package, e.g. `pnpm run test-serve -- css` will run tests for both `playground/css` and `playground/css-codesplit` under serve mode.
|
||||
|
||||
Note package matching is not available for the `yarn test` script, which always runs all tests.
|
||||
Note package matching is not available for the `pnpm test` script, which always runs all tests.
|
||||
|
||||
### Test Env and Helpers
|
||||
|
||||
@ -75,6 +75,20 @@ test('?raw import', async () => {
|
||||
})
|
||||
```
|
||||
|
||||
## Note on Test Dependencies
|
||||
|
||||
In many test cases we need to mock dependencies using `link:` and `file:` protocols (which are supported by package managers like `yarn` and `pnpm`). However, `pnpm` treats `link:` and `file:` the same way and always use symlinks. This can be undesirable in cases where we want the dependency to be actually copied into `node_modules`.
|
||||
|
||||
To work around this, playground packages that uses the `file:` protocol should also include the following `postinstall` script:
|
||||
|
||||
```jsonc
|
||||
"scripts": {
|
||||
//...
|
||||
"postinstall": "node ../../../scripts/patchFileDeps"
|
||||
}
|
||||
|
||||
This script patches the dependencies using `file:` protocol to match the copying behavior instead of linking.
|
||||
|
||||
## 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.
|
||||
@ -92,7 +106,7 @@ You can set the `DEBUG` environment variable to turn on debugging logs. E.g. `DE
|
||||
|
||||
- If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `fix: update entities encoding/decoding (fix #3899)`.
|
||||
- Provide a detailed description of the bug in the PR. Live demo preferred.
|
||||
- Add appropriate test coverage if applicable. You can check the coverage of your code addition by running `yarn test --coverage`.
|
||||
- Add appropriate test coverage if applicable.
|
||||
|
||||
- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging.
|
||||
|
||||
|
@ -126,18 +126,18 @@ You can specify additional CLI options like `--port` or `--https`. For a full li
|
||||
|
||||
## 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 ([Yarn 1.x](https://classic.yarnpkg.com/lang/en/) is required):
|
||||
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):
|
||||
|
||||
```bash
|
||||
git clone https://github.com/vitejs/vite.git
|
||||
cd vite
|
||||
yarn
|
||||
pnpm install
|
||||
cd packages/vite
|
||||
yarn build
|
||||
yarn link
|
||||
pnpm run build
|
||||
pnpm link # you can use your preferred package manager for this step
|
||||
```
|
||||
|
||||
Then go to your Vite based project and run `yarn link vite`. Now restart the development server (`yarn dev`) to ride on the bleeding edge!
|
||||
Then go to your Vite based project and run `pnpm link vite` (or the package manager that you used to link `vite` globally). Now restart the development server to ride on the bleeding edge!
|
||||
|
||||
## Community
|
||||
|
||||
|
@ -11,8 +11,8 @@ const config: Config.InitialOptions = {
|
||||
globalTeardown: './scripts/jestGlobalTeardown.js',
|
||||
testEnvironment: './scripts/jestEnv.js',
|
||||
setupFilesAfterEnv: ['./scripts/jestPerTestSetup.ts'],
|
||||
watchPathIgnorePatterns: ['<rootDir>/temp'],
|
||||
modulePathIgnorePatterns: ['<rootDir>/temp'],
|
||||
watchPathIgnorePatterns: ['<rootDir>/packages/temp'],
|
||||
modulePathIgnorePatterns: ['<rootDir>/packages/temp'],
|
||||
moduleNameMapper: {
|
||||
testUtils: '<rootDir>/packages/playground/testUtils.ts'
|
||||
},
|
||||
|
6
netlify.toml
Normal file
6
netlify.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[build.environment]
|
||||
NODE_VERSION = "16"
|
||||
NPM_FLAGS = "--version" # prevent Netlify npm install
|
||||
[build]
|
||||
publish = "docs/.vitepress/dist"
|
||||
command = "npx pnpm i --store=node_modules/.pnpm-store && npm run ci-docs"
|
20
package.json
20
package.json
@ -9,6 +9,7 @@
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"preinstall": "node scripts/preinstall",
|
||||
"format": "prettier --write .",
|
||||
"lint": "eslint packages/*/{src,types}/**",
|
||||
"test": "run-s test-serve test-build",
|
||||
@ -20,10 +21,10 @@
|
||||
"build-docs": "vitepress build docs",
|
||||
"serve-docs": "vitepress serve docs",
|
||||
"build": "run-s build-vite build-plugin-vue build-plugin-react",
|
||||
"build-vite": "cd packages/vite && yarn build",
|
||||
"build-plugin-vue": "cd packages/plugin-vue && yarn build",
|
||||
"build-plugin-react": "cd packages/plugin-react && yarn build",
|
||||
"ci-build-vite": "cd packages/vite && yarn ci-build",
|
||||
"build-vite": "cd packages/vite && npm run build",
|
||||
"build-plugin-vue": "cd packages/plugin-vue && npm run build",
|
||||
"build-plugin-react": "cd packages/plugin-react && npm run build",
|
||||
"ci-build-vite": "cd packages/vite && npm run ci-build",
|
||||
"ci-docs": "run-s build-vite build-plugin-vue build-docs"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -57,7 +58,10 @@
|
||||
"ts-node": "^10.1.0",
|
||||
"typescript": "~4.3.5",
|
||||
"vitepress": "^0.19.1",
|
||||
"yorkie": "^2.0.0"
|
||||
"yorkie": "^2.0.0",
|
||||
"rollup": "^2.57.0",
|
||||
"esbuild": "^0.13.2",
|
||||
"vite": "workspace:*"
|
||||
},
|
||||
"gitHooks": {
|
||||
"pre-commit": "lint-staged --concurrent false",
|
||||
@ -73,5 +77,11 @@
|
||||
"packages/**/*.d.ts": [
|
||||
"eslint --ext .ts"
|
||||
]
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"vite": "workspace:*",
|
||||
"@vitejs/plugin-vue": "workspace:*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.2.13"
|
||||
"vue": "^3.2.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^1.9.0",
|
||||
|
@ -7,7 +7,7 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.2.13"
|
||||
"vue": "^3.2.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^1.9.0",
|
||||
|
@ -9,6 +9,9 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.2.13"
|
||||
"vue": "^3.2.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"resolve-linked": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.2.13"
|
||||
"vue": "^3.2.16"
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@
|
||||
"react-dom": "^17.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^1.0.0"
|
||||
"@vitejs/plugin-react": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { isBuild } from '../../testUtils'
|
||||
|
||||
const json = require('../test.json')
|
||||
const deepJson = require('@vue/runtime-core/package.json')
|
||||
const deepJson = require('vue/package.json')
|
||||
const stringified = JSON.stringify(json)
|
||||
const deepStringified = JSON.stringify(deepJson)
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
<script type="module">
|
||||
import json, { hello } from './test.json'
|
||||
import deepJson, { name } from '@vue/runtime-core/package.json'
|
||||
import deepJson, { name } from 'vue/package.json'
|
||||
|
||||
text('.full', JSON.stringify(json))
|
||||
text('.named', hello)
|
||||
|
@ -7,5 +7,8 @@
|
||||
"build": "vite build",
|
||||
"debug": "node --inspect-brk ../../vite/bin/vite",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vue": "^3.2.16"
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-legacy": "^1.0.0"
|
||||
"@vitejs/plugin-legacy": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"nested-include": "file:./nested-include"
|
||||
"nested-include": "link:./nested-include"
|
||||
}
|
||||
}
|
||||
|
@ -6,22 +6,27 @@
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"debug": "node --inspect-brk ../../vite/bin/vite",
|
||||
"serve": "vite preview"
|
||||
"serve": "vite preview",
|
||||
"postinstall": "node ../../../scripts/patchFileDeps"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"clipboard": "^2.0.6",
|
||||
"dep-cjs-compiled-from-cjs": "file:./dep-cjs-compiled-from-cjs",
|
||||
"dep-cjs-compiled-from-esm": "file:./dep-cjs-compiled-from-esm",
|
||||
"dep-esbuild-plugin-transform": "file:./dep-esbuild-plugin-transform",
|
||||
"dep-linked": "link:./dep-linked",
|
||||
"dep-linked-include": "link:./dep-linked-include",
|
||||
"dep-esbuild-plugin-transform": "link:./dep-esbuild-plugin-transform",
|
||||
"dep-cjs-compiled-from-esm": "file:./dep-cjs-compiled-from-esm",
|
||||
"dep-cjs-compiled-from-cjs": "file:./dep-cjs-compiled-from-cjs",
|
||||
"nested-exclude": "link:./nested-exclude",
|
||||
"lodash-es": "^4.17.20",
|
||||
"nested-exclude": "file:./nested-exclude",
|
||||
"phoenix": "^1.5.7",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"resolve-linked": "0.0.0",
|
||||
"vue": "^3.2.13",
|
||||
"vue": "^3.2.16",
|
||||
"vuex": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
'dep-linked-include',
|
||||
// required since it isn't in node_modules and is ignored by the optimizer otherwise
|
||||
'dep-esbuild-plugin-transform',
|
||||
'nested-exclude>nested-include'
|
||||
],
|
||||
include: ['dep-linked-include', 'nested-exclude > nested-include'],
|
||||
exclude: ['nested-exclude'],
|
||||
esbuildOptions: {
|
||||
plugins: [
|
||||
|
@ -3,15 +3,14 @@
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "node server"
|
||||
},
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
"./*"
|
||||
]
|
||||
"dev": "node server",
|
||||
"postinstall": "node ../../../scripts/patchFileDeps"
|
||||
},
|
||||
"dependencies": {
|
||||
"missing-dep": "file:./missing-dep",
|
||||
"multi-entry-dep": "file:./multi-entry-dep"
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "^4.17.1"
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.2.13",
|
||||
"vue": "^3.2.16",
|
||||
"vue-router": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^1.0.0"
|
||||
"@vitejs/plugin-vue": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -1,108 +0,0 @@
|
||||
// @ts-check
|
||||
// this is automtically detected by scripts/jestPerTestSetup.ts and will replace
|
||||
// the default e2e test serve behavior
|
||||
|
||||
const path = require('path')
|
||||
const http = require('http')
|
||||
const sirv = require('sirv')
|
||||
const fs = require('fs')
|
||||
|
||||
const port = (exports.port = 9527)
|
||||
|
||||
/**
|
||||
* @param {string} root
|
||||
* @param {boolean} isBuildTest
|
||||
*/
|
||||
exports.serve = async function serve(root, isBuildTest) {
|
||||
const testDist = path.resolve(__dirname, '../moduleA/dist')
|
||||
|
||||
if (fs.existsSync(testDist)) {
|
||||
emptyDir(testDist)
|
||||
} else {
|
||||
fs.mkdirSync(testDist, { recursive: true })
|
||||
}
|
||||
|
||||
fs.symlinkSync(
|
||||
path.resolve(testDist, '../src/index.js'),
|
||||
path.resolve(testDist, 'symlinks-moduleA.esm.js')
|
||||
)
|
||||
|
||||
if (!isBuildTest) {
|
||||
const { createServer } = require('vite')
|
||||
process.env.VITE_INLINE = 'inline-serve'
|
||||
let viteServer = await (
|
||||
await createServer({
|
||||
root: root,
|
||||
logLevel: 'silent',
|
||||
server: {
|
||||
watch: {
|
||||
usePolling: true,
|
||||
interval: 100
|
||||
},
|
||||
host: true,
|
||||
fs: {
|
||||
strict: !isBuildTest
|
||||
}
|
||||
},
|
||||
build: {
|
||||
target: 'esnext'
|
||||
}
|
||||
})
|
||||
).listen()
|
||||
// use resolved port/base from server
|
||||
const base = viteServer.config.base === '/' ? '' : viteServer.config.base
|
||||
const url =
|
||||
(global.viteTestUrl = `http://localhost:${viteServer.config.server.port}${base}`)
|
||||
await page.goto(url)
|
||||
|
||||
return viteServer
|
||||
} else {
|
||||
const { build } = require('vite')
|
||||
await build({
|
||||
root,
|
||||
logLevel: 'silent',
|
||||
configFile: path.resolve(__dirname, '../vite.config.js')
|
||||
})
|
||||
|
||||
// start static file server
|
||||
const serve = sirv(path.resolve(root, 'dist'))
|
||||
const httpServer = http.createServer((req, res) => {
|
||||
if (req.url === '/ping') {
|
||||
res.statusCode = 200
|
||||
res.end('pong')
|
||||
} else {
|
||||
serve(req, res)
|
||||
}
|
||||
})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const server = httpServer.listen(port, async () => {
|
||||
await page.goto(`http://localhost:${port}`)
|
||||
resolve({
|
||||
// for test teardown
|
||||
async close() {
|
||||
await new Promise((resolve) => {
|
||||
server.close(resolve)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function emptyDir(dir) {
|
||||
for (const file of fs.readdirSync(dir)) {
|
||||
const abs = path.resolve(dir, file)
|
||||
if (fs.lstatSync(abs).isDirectory()) {
|
||||
emptyDir(abs)
|
||||
fs.rmdirSync(abs)
|
||||
} else {
|
||||
fs.unlinkSync(abs)
|
||||
}
|
||||
}
|
||||
}
|
1
packages/playground/preserve-symlinks/moduleA/linked.js
Symbolic link
1
packages/playground/preserve-symlinks/moduleA/linked.js
Symbolic link
@ -0,0 +1 @@
|
||||
./src/index.js
|
@ -1,17 +1,5 @@
|
||||
{
|
||||
"name": "@symlinks/moduleA",
|
||||
"version": "0.0.0",
|
||||
"module": "dist/symlinks-moduleA.esm.js",
|
||||
"main": "dist/symlinks-moduleA.cjs.js",
|
||||
"preconstruct": {
|
||||
"entrypoints": [
|
||||
"index.js"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "preconstruct dev"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@preconstruct/cli": "^2.0.6"
|
||||
}
|
||||
"main": "linked.js"
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
{
|
||||
"name": "preserveSymlinks",
|
||||
"name": "preserve-symlinks",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "vite --force",
|
||||
"build": "vite build",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"workspaces": {},
|
||||
"dependencies": {
|
||||
"@symlinks/moduleA": "link:./moduleA"
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
// https://vitejs.dev/config/
|
||||
module.exports = {
|
||||
resolve: {
|
||||
preserveSymlinks: false
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-pipeline-operator": "^7.14.5",
|
||||
"@emotion/babel-plugin": "^11.3.0",
|
||||
"@vitejs/plugin-react": "^1.0.0"
|
||||
"@vitejs/plugin-react": "workspace:*"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
|
@ -13,7 +13,7 @@
|
||||
"react-dom": "^17.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^1.0.0"
|
||||
"@vitejs/plugin-react": "workspace:*"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
|
@ -15,6 +15,7 @@
|
||||
"resolve-custom-main-field": "link:./custom-main-field",
|
||||
"resolve-custom-condition": "link:./custom-condition",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"normalize.css": "^8.0.1"
|
||||
"normalize.css": "^8.0.1",
|
||||
"resolve-linked": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "node server",
|
||||
"build": "yarn build:client && yarn build:server",
|
||||
"build": "npm run build:client && npm run build:server",
|
||||
"build:client": "vite build --outDir dist/client",
|
||||
"build:server": "vite build --ssr src/entry-server.jsx --outDir dist/server",
|
||||
"generate": "vite build --outDir dist/static && yarn build:server && node prerender",
|
||||
"generate": "vite build --outDir dist/static && npm run build:server && node prerender",
|
||||
"serve": "cross-env NODE_ENV=production node server",
|
||||
"debug": "node --inspect-brk server"
|
||||
},
|
||||
@ -18,7 +18,7 @@
|
||||
"react-router-dom": "^5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^1.0.0",
|
||||
"@vitejs/plugin-react": "workspace:*",
|
||||
"compression": "^1.7.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"express": "^4.17.1",
|
||||
|
@ -4,23 +4,23 @@
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"dev": "node server",
|
||||
"build": "yarn build:client && yarn build:server",
|
||||
"build:noExternal": "yarn build:client && yarn build:server:noExternal",
|
||||
"build": "npm run build:client && npm run build:server",
|
||||
"build:noExternal": "npm run build:client && npm run build:server:noExternal",
|
||||
"build:client": "vite build --ssrManifest --outDir dist/client",
|
||||
"build:server": "vite build --ssr src/entry-server.js --outDir dist/server",
|
||||
"build:server:noExternal": "vite build --config vite.config.noexternal.js --ssr src/entry-server.js --outDir dist/server",
|
||||
"generate": "vite build --ssrManifest --outDir dist/static && yarn build:server && node prerender",
|
||||
"generate": "vite build --ssrManifest --outDir dist/static && npm run build:server && node prerender",
|
||||
"serve": "cross-env NODE_ENV=production node server",
|
||||
"debug": "node --inspect-brk server"
|
||||
},
|
||||
"dependencies": {
|
||||
"example-external-component": "file:example-external-component",
|
||||
"vue": "^3.2.13",
|
||||
"vue": "^3.2.16",
|
||||
"vue-router": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^1.0.0",
|
||||
"@vitejs/plugin-vue-jsx": "^1.1.2",
|
||||
"@vitejs/plugin-vue": "workspace:*",
|
||||
"@vitejs/plugin-vue-jsx": "workspace:*",
|
||||
"dep-import-type": "link:./dep-import-type",
|
||||
"compression": "^1.7.4",
|
||||
"cross-env": "^7.0.3",
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Pre-render the app into static HTML.
|
||||
// run `yarn generate` and then `dist/static` can be served as a static site.
|
||||
// run `npm run generate` and then `dist/static` can be served as a static site.
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
@ -10,6 +10,7 @@
|
||||
"react": "^17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"miniflare": "^1.3.3"
|
||||
"miniflare": "^1.3.3",
|
||||
"resolve-linked": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@
|
||||
"dependencies": {
|
||||
"autoprefixer": "^10.3.0",
|
||||
"tailwindcss": "^2.2.4",
|
||||
"vue": "^3.2.13"
|
||||
"vue": "^3.2.16",
|
||||
"vue-router": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^1.0.0",
|
||||
"vue-router": "^4.0.0"
|
||||
"@vitejs/plugin-vue": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ export const isBuild = !!process.env.VITE_TEST_BUILD
|
||||
|
||||
const testPath = expect.getState().testPath
|
||||
const testName = slash(testPath).match(/playground\/([\w-]+)\//)?.[1]
|
||||
export const testDir = path.resolve(__dirname, '../../temp', testName)
|
||||
export const testDir = path.resolve(__dirname, '../../packages/temp', testName)
|
||||
|
||||
const hexToNameMap: Record<string, string> = {}
|
||||
Object.keys(colors).forEach((color) => {
|
||||
|
@ -8,8 +8,11 @@
|
||||
"debug": "node --inspect-brk ../../vite/bin/vite",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.2.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue-jsx": "^1.0.0",
|
||||
"@vitejs/plugin-vue": "^1.3.0"
|
||||
"@vitejs/plugin-vue-jsx": "workspace:*",
|
||||
"@vitejs/plugin-vue": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,15 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash-es": "^4.17.20"
|
||||
"lodash-es": "^4.17.20",
|
||||
"vue": "^3.2.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^1.0.0",
|
||||
"@vitejs/plugin-vue": "workspace:*",
|
||||
"js-yaml": "^3.14.1",
|
||||
"less": "^3.13.0",
|
||||
"pug": "^3.0.0",
|
||||
"sass": "^1.30.0"
|
||||
"sass": "^1.30.0",
|
||||
"stylus": "^0.54.8"
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,5 @@
|
||||
"@rollup/pluginutils": "^4.1.1",
|
||||
"react-refresh": "^0.10.0",
|
||||
"resolve": "^1.20.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "link:../vite"
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
"rollup": "^2.57.0",
|
||||
"slash": "^3.0.0",
|
||||
"source-map": "^0.6.1",
|
||||
"vue": "^3.2.14",
|
||||
"@vue/compiler-sfc": "^3.2.14"
|
||||
"vue": "^3.2.16",
|
||||
"@vue/compiler-sfc": "^3.2.16"
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,12 +31,12 @@
|
||||
"scripts": {
|
||||
"predev": "rimraf dist",
|
||||
"dev": "rollup -c -w",
|
||||
"prebuild": "rimraf dist && yarn lint",
|
||||
"prebuild": "rimraf dist && npm run lint",
|
||||
"build": "run-s build-bundle build-types",
|
||||
"build-bundle": "rollup -c",
|
||||
"build-types": "run-s build-temp-types patch-types roll-types",
|
||||
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
|
||||
"ci-build": "rimraf dist && yarn run-s build-bundle build-types",
|
||||
"ci-build": "rimraf dist && run-s build-bundle build-types",
|
||||
"patch-types": "node scripts/patchTypes",
|
||||
"roll-types": "api-extractor run && rimraf temp",
|
||||
"lint": "eslint --ext .ts src/**",
|
||||
@ -46,7 +46,7 @@
|
||||
},
|
||||
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.13.1",
|
||||
"esbuild": "^0.13.2",
|
||||
"postcss": "^8.3.7",
|
||||
"resolve": "^1.20.0",
|
||||
"rollup": "^2.57.0"
|
||||
|
3
packages/vite/types/package.json
Normal file
3
packages/vite/types/package.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"//": "this file is just here to make pnpm happy with --frozen-lockfile"
|
||||
}
|
8768
pnpm-lock.yaml
Normal file
8768
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
3
pnpm-workspace.yaml
Normal file
3
pnpm-workspace.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
packages:
|
||||
- 'packages/*'
|
||||
- 'packages/playground/**'
|
@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
const os = require('os')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
@ -17,5 +18,14 @@ module.exports = async () => {
|
||||
|
||||
await fs.mkdirp(DIR)
|
||||
await fs.writeFile(path.join(DIR, 'wsEndpoint'), browserServer.wsEndpoint())
|
||||
await fs.remove(path.resolve(__dirname, '../temp'))
|
||||
|
||||
const tempDir = path.resolve(__dirname, '../packages/temp')
|
||||
await fs.remove(tempDir)
|
||||
await fs.copy(path.resolve(__dirname, '../packages/playground'), tempDir, {
|
||||
dereference: false,
|
||||
filter(file) {
|
||||
file = file.replace(/\\/g, '/')
|
||||
return !file.includes('__tests__') && !file.match(/dist(\/|$)/)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ const path = require('path')
|
||||
module.exports = async () => {
|
||||
await global.__BROWSER_SERVER__.close()
|
||||
if (!process.env.VITE_PRESERVE_BUILD_ARTIFACTS) {
|
||||
await fs.remove(path.resolve(__dirname, '../temp'))
|
||||
await fs.remove(path.resolve(__dirname, '../packages/temp'))
|
||||
}
|
||||
}
|
||||
|
@ -62,19 +62,7 @@ beforeAll(async () => {
|
||||
// start a vite server in that directory.
|
||||
if (testName) {
|
||||
const playgroundRoot = resolve(__dirname, '../packages/playground')
|
||||
const srcDir = resolve(playgroundRoot, testName)
|
||||
tempDir = resolve(__dirname, '../temp', testName)
|
||||
await fs.copy(srcDir, tempDir, {
|
||||
dereference: true,
|
||||
filter(file) {
|
||||
file = slash(file)
|
||||
return (
|
||||
!file.includes('__tests__') &&
|
||||
!file.includes('node_modules') &&
|
||||
!file.match(/dist(\/|$)/)
|
||||
)
|
||||
}
|
||||
})
|
||||
tempDir = resolve(__dirname, '../packages/temp/', testName)
|
||||
|
||||
// when `root` dir is present, use it as vite's root
|
||||
let testCustomRoot = resolve(tempDir, 'root')
|
||||
@ -83,9 +71,14 @@ beforeAll(async () => {
|
||||
const testCustomServe = resolve(dirname(testPath), 'serve.js')
|
||||
if (fs.existsSync(testCustomServe)) {
|
||||
// test has custom server configuration.
|
||||
const { serve } = require(testCustomServe)
|
||||
server = await serve(rootDir, isBuildTest)
|
||||
return
|
||||
const { serve, preServe } = require(testCustomServe)
|
||||
if (preServe) {
|
||||
await preServe(rootDir, isBuildTest)
|
||||
}
|
||||
if (serve) {
|
||||
server = await serve(rootDir, isBuildTest)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const options: UserConfig = {
|
||||
|
30
scripts/patchFileDeps.js
Normal file
30
scripts/patchFileDeps.js
Normal file
@ -0,0 +1,30 @@
|
||||
// pnpm treats file: protocols as link:, so it doesn't copy the actual files
|
||||
// into node_modules, causing Vite to still consider those deps linked.
|
||||
// This script is called from postinstall hooks in playground packages that
|
||||
// uses the file: protocol, and copies the file: deps into node_modules.
|
||||
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const root = process.cwd()
|
||||
const pkg = require(path.join(root, 'package.json'))
|
||||
|
||||
let hasPatched
|
||||
for (const [key, val] of Object.entries(pkg.dependencies)) {
|
||||
if (val.startsWith('file:')) {
|
||||
hasPatched = true
|
||||
const src = path.resolve(root, val.slice('file:'.length))
|
||||
const dest = path.resolve(root, 'node_modules', key)
|
||||
fs.removeSync(dest)
|
||||
fs.copySync(src, dest, {
|
||||
dereference: true
|
||||
})
|
||||
console.log(`patched ${val}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPatched) {
|
||||
// remove node_modules/.ignored as pnpm will think our patched files are
|
||||
// installed by another package manager and move them into this directory.
|
||||
// On further installs it will error out if this directory is not empty.
|
||||
fs.removeSync(path.resolve(root, 'node_modules', '.ignored'))
|
||||
}
|
7
scripts/preinstall.js
Normal file
7
scripts/preinstall.js
Normal file
@ -0,0 +1,7 @@
|
||||
if (!/pnpm/.test(process.env.npm_execpath || '')) {
|
||||
console.warn(
|
||||
`\u001b[33mThis repository requires using pnpm as the package manager ` +
|
||||
` for scripts to work properly.\u001b[39m\n`
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
@ -141,13 +141,13 @@ async function main() {
|
||||
|
||||
step('\nBuilding package...')
|
||||
if (!skipBuild && !isDryRun) {
|
||||
await run('yarn', ['build'])
|
||||
await run('pnpm', ['run', 'build'])
|
||||
} else {
|
||||
console.log(`(skipped)`)
|
||||
}
|
||||
|
||||
step('\nGenerating changelog...')
|
||||
await run('yarn', ['changelog'])
|
||||
await run('pnpm', ['run', 'changelog'])
|
||||
|
||||
const { stdout } = await run('git', ['diff'], { stdio: 'pipe' })
|
||||
if (stdout) {
|
||||
@ -199,6 +199,8 @@ async function publishPackage(version, runIfNotDry) {
|
||||
publicArgs.push(`--tag`, args.tag)
|
||||
}
|
||||
try {
|
||||
// important: we still use Yarn 1 to publish since we rely on its specific
|
||||
// behavior
|
||||
await runIfNotDry('yarn', publicArgs, {
|
||||
stdio: 'pipe'
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user