forked from vitejs/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'vitejs:main' into fix-vitejs#3295
- Loading branch information
Showing
46 changed files
with
671 additions
and
614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## [2.6.4](https://github.com/vitejs/vite/compare/[email protected]@2.6.4) (2021-09-22) | ||
|
||
|
||
|
||
## [2.6.3](https://github.com/vitejs/vite/compare/[email protected]@2.6.3) (2021-09-21) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { defineConfig } from 'vite' | ||
import reactRefresh from '@vitejs/plugin-react-refresh' | ||
import react from '@vitejs/plugin-react' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [reactRefresh()] | ||
plugins: [react()] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { defineConfig } from 'vite' | ||
import reactRefresh from '@vitejs/plugin-react-refresh' | ||
import react from '@vitejs/plugin-react' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [reactRefresh()] | ||
plugins: [react()] | ||
}) |
16 changes: 16 additions & 0 deletions
16
packages/playground/optimize-missing-deps/__test__/optimize-missing-deps.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { port } from './serve' | ||
import fetch from 'node-fetch' | ||
import { untilUpdated } from '../../testUtils' | ||
|
||
const url = `http://localhost:${port}` | ||
|
||
test('*', async () => { | ||
await page.goto(url) | ||
// reload page to get optimized missing deps | ||
await page.reload() | ||
await untilUpdated(() => page.textContent('div'), 'Client') | ||
|
||
// raw http request | ||
const aboutHtml = await (await fetch(url)).text() | ||
expect(aboutHtml).toMatch('Server') | ||
}) |
36 changes: 36 additions & 0 deletions
36
packages/playground/optimize-missing-deps/__test__/serve.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// @ts-check | ||
// this is automtically detected by scripts/jestPerTestSetup.ts and will replace | ||
// the default e2e test serve behavior | ||
|
||
const path = require('path') | ||
|
||
const port = (exports.port = 9529) | ||
|
||
/** | ||
* @param {string} root | ||
* @param {boolean} isProd | ||
*/ | ||
exports.serve = async function serve(root, isProd) { | ||
const { createServer } = require(path.resolve(root, 'server.js')) | ||
const { app, vite } = await createServer(root, isProd) | ||
|
||
return new Promise((resolve, reject) => { | ||
try { | ||
const server = app.listen(port, () => { | ||
resolve({ | ||
// for test teardown | ||
async close() { | ||
await new Promise((resolve) => { | ||
server.close(resolve) | ||
}) | ||
if (vite) { | ||
await vite.close() | ||
} | ||
} | ||
}) | ||
}) | ||
} catch (e) { | ||
reject(e) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<!--app-html--> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { sayName } from 'missing-dep' | ||
|
||
export const name = sayName() |
5 changes: 5 additions & 0 deletions
5
packages/playground/optimize-missing-deps/missing-dep/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { name } from 'multi-entry-dep' | ||
|
||
export function sayName() { | ||
return name | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/playground/optimize-missing-deps/missing-dep/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "missing-dep", | ||
"version": "0.0.0", | ||
"main": "index.js", | ||
"dependencies": { | ||
"multi-entry-dep": "file:../multi-entry-dep" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/playground/optimize-missing-deps/multi-entry-dep/index.browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.name = 'Client' |
3 changes: 3 additions & 0 deletions
3
packages/playground/optimize-missing-deps/multi-entry-dep/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const path = require('path') | ||
|
||
exports.name = path.normalize('./Server') |
8 changes: 8 additions & 0 deletions
8
packages/playground/optimize-missing-deps/multi-entry-dep/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "multi-entry-dep", | ||
"version": "0.0.0", | ||
"main": "index.js", | ||
"browser": { | ||
"./index.js": "./index.browser.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "optimize-missing-deps", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "node server" | ||
}, | ||
"workspaces": { | ||
"packages": [ | ||
"./*" | ||
] | ||
}, | ||
"dependencies": { | ||
"missing-dep": "file:./missing-dep", | ||
"multi-entry-dep": "file:./multi-entry-dep" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// @ts-check | ||
const fs = require('fs') | ||
const path = require('path') | ||
const express = require('express') | ||
|
||
const isTest = process.env.NODE_ENV === 'test' || !!process.env.VITE_TEST_BUILD | ||
|
||
async function createServer(root = process.cwd()) { | ||
const resolve = (p) => path.resolve(__dirname, p) | ||
|
||
const app = express() | ||
|
||
/** | ||
* @type {import('vite').ViteDevServer} | ||
*/ | ||
const vite = await require('vite').createServer({ | ||
root, | ||
logLevel: isTest ? 'error' : 'info', | ||
server: { middlewareMode: 'ssr' } | ||
}) | ||
app.use(vite.middlewares) | ||
|
||
app.use('*', async (req, res) => { | ||
try { | ||
let template = fs.readFileSync(resolve('index.html'), 'utf-8') | ||
template = await vite.transformIndexHtml(req.originalUrl, template) | ||
|
||
// this will import missing deps nest built-in deps that should not be optimized | ||
const { name } = await vite.ssrLoadModule('./main.js') | ||
|
||
// this will import missing deps that should be optimized correctly | ||
const appHtml = `<div id="app">${name}</div> | ||
<script type='module'> | ||
import { name } from './main.js' | ||
document.getElementById('app').innerText = name | ||
</script>` | ||
|
||
const html = template.replace(`<!--app-html-->`, appHtml) | ||
|
||
res.status(200).set({ 'Content-Type': 'text/html' }).end(html) | ||
} catch (e) { | ||
vite.ssrFixStacktrace(e) | ||
console.log(e.stack) | ||
res.status(500).end(e.stack) | ||
} | ||
}) | ||
|
||
return { app, vite } | ||
} | ||
|
||
if (!isTest) { | ||
createServer().then(({ app }) => | ||
app.listen(3000, () => { | ||
console.log('http://localhost:3000') | ||
}) | ||
) | ||
} | ||
|
||
// for test use | ||
exports.createServer = createServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
# 1.0.0-beta.0 (2021-09-20) | ||
## [1.0.1](https://github.com/vitejs/vite/compare/[email protected]@1.0.1) (2021-09-22) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **deps:** update all non-major dependencies ([#4545](https://github.com/vitejs/vite/issues/4545)) ([a44fd5d](https://github.com/vitejs/vite/commit/a44fd5d38679da0be2536103e83af730cda73a95)) | ||
* disable `inputSourceMap` option of babel ([#4834](https://github.com/vitejs/vite/issues/4834)) ([ba89bd6](https://github.com/vitejs/vite/commit/ba89bd6df9231da85cebd089199bc4ad097af243)), closes [#4055](https://github.com/vitejs/vite/issues/4055) | ||
* **plugin-react:** inconsistent error warning ([#5031](https://github.com/vitejs/vite/issues/5031)) ([89ba8ce](https://github.com/vitejs/vite/commit/89ba8cedb8636968516bc38b37e1d2d5ed6234bb)) | ||
|
||
|
||
### Features | ||
|
||
# 1.0.0 (TBD) | ||
* **plugin-react:** pre-optimize jsx-dev-runtime ([#5036](https://github.com/vitejs/vite/issues/5036)) ([a34dd27](https://github.com/vitejs/vite/commit/a34dd2725e64fedf626e23ba9ced480f5465a59b)) | ||
|
||
|
||
|
||
# [1.0.0](https://github.com/vitejs/vite/compare/[email protected]@1.0.0) (2021-09-22) | ||
|
||
See the [readme](https://github.com/aleclarson/vite/blob/f8129ce6e87684eb7a4edd8106351c5d98207d7b/packages/plugin-react/README.md#vitejsplugin-react-) for more information. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.