Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed May 29, 2022
2 parents 773f234 + 337b197 commit b71e1ea
Show file tree
Hide file tree
Showing 44 changed files with 372 additions and 176 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Expand Up @@ -73,6 +73,10 @@ module.exports = defineConfig({

'@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/explicit-module-boundary-types': [
'error',
{ allowArgumentsExplicitlyTypedAsAny: true }
],
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] }
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v2.2.2

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v3
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v2.2.2

- name: Set node version to 16
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v2.2.2

- name: Set node version to 16.x
uses: actions/setup-node@v3
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -214,6 +214,8 @@ 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/types`. This way we can still expose the typing but bundle the dependency's source code.

Use `pnpm run check-dist-types` to check bundled types does not rely on types in `devDependencies`. If you are adding `dependencies`, make sure to configure `tsconfig.check.json`.

### Think before adding yet another option

We already have many config options, and we should avoid fixing an issue by adding yet another one. Before adding an option, try to think about:
Expand Down
8 changes: 4 additions & 4 deletions docs/.vitepress/config.ts
Expand Up @@ -35,7 +35,7 @@ export default defineConfig({
},

carbonAds: {
carbon: 'CEBIEK3N',
code: 'CEBIEK3N',
placement: 'vitejsdev'
},

Expand All @@ -53,9 +53,9 @@ export default defineConfig({
},

nav: [
{ text: 'Guide', link: '/guide/' },
{ text: 'Config', link: '/config/' },
{ text: 'Plugins', link: '/plugins/' },
{ text: 'Guide', link: '/guide/', activeMatch: '/guide/' },
{ text: 'Config', link: '/config/', activeMatch: '/config/' },
{ text: 'Plugins', link: '/plugins/', activeMatch: '/plugins/' },
{
text: 'Links',
items: [
Expand Down
22 changes: 22 additions & 0 deletions docs/.vitepress/theme/components/AsideSponsors.vue
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { computed } from 'vue'
import { VPDocAsideSponsors } from 'vitepress/theme'
import { useSponsor } from '../composables/sponsor'
const { data } = useSponsor()
const sponsors = computed(() => {
return (
data?.value.map((sponsor) => {
return {
size: sponsor.size === 'big' ? 'mini' : 'xmini',
items: sponsor.items
}
}) ?? []
)
})
</script>

<template>
<VPDocAsideSponsors v-if="data" :data="sponsors" />
</template>
1 change: 1 addition & 0 deletions docs/.vitepress/theme/components/HomeSponsors.vue
Expand Up @@ -9,6 +9,7 @@ const { data } = useSponsor()
<VPHomeSponsors
v-if="data"
message="Vite is free and open source, made possible by wonderful sponsors."
action-text="Become a sponsor"
action-link="https://github.com/sponsors/yyx990803"
:data="data"
/>
Expand Down
5 changes: 3 additions & 2 deletions docs/.vitepress/theme/index.ts
@@ -1,14 +1,15 @@
import { h } from 'vue'
import Theme from 'vitepress/theme'
import './styles/vars.css'
import './styles/custom.css'
import HomeSponsors from './components/HomeSponsors.vue'
import AsideSponsors from './components/AsideSponsors.vue'

export default {
...Theme,
Layout() {
return h(Theme.Layout, null, {
'home-features-after': () => h(HomeSponsors)
'home-features-after': () => h(HomeSponsors),
'aside-ads-before': () => h(AsideSponsors)
})
}
}
15 changes: 0 additions & 15 deletions docs/.vitepress/theme/styles/custom.css

This file was deleted.

19 changes: 19 additions & 0 deletions docs/.vitepress/theme/styles/vars.css
Expand Up @@ -38,6 +38,25 @@
#bd34fe 30%,
#41d1ff
);

--vp-home-hero-image-background-image: linear-gradient(
-45deg,
#bd34fe 50%,
#47caff 50%
);
--vp-home-hero-image-filter: blur(40px);
}

@media (min-width: 640px) {
:root {
--vp-home-hero-image-filter: blur(56px);
}
}

@media (min-width: 960px) {
:root {
--vp-home-hero-image-filter: blur(72px);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/env-and-mode.md
Expand Up @@ -16,7 +16,7 @@ Vite exposes env variables on the special **`import.meta.env`** object. Some bui

During production, these env variables are **statically replaced**. It is therefore necessary to always reference them using the full static string. For example, dynamic key access like `import.meta.env[key]` will not work.

It will also replace these strings appearing in JavaScript strings and Vue templates. This should be a rare case, but it can be unintended. You may see errors like `Missing Semicolon` or `Unexpected token` in this case, for example when `"process.env.NODE_ENV: "` is transformed to `""development": "`. There are ways to work around this behavior:
It will also replace these strings appearing in JavaScript strings and Vue templates. This should be a rare case, but it can be unintended. You may see errors like `Missing Semicolon` or `Unexpected token` in this case, for example when `"process.env.`<wbr>`NODE_ENV"` is transformed to `""development": "`. There are ways to work around this behavior:

- For JavaScript strings, you can break the string up with a Unicode zero-width space, e.g. `'import.meta\u200b.env.MODE'`.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/index.md
Expand Up @@ -116,7 +116,7 @@ Running `vite` starts the dev server using the current working directory as root
In a project where Vite is installed, you can use the `vite` binary in your npm scripts, or run it directly with `npx vite`. Here are the default npm scripts in a scaffolded Vite project:

<!-- prettier-ignore -->
```json5
```json
{
"scripts": {
"dev": "vite", // start dev server, aliases: `vite dev`, `vite serve`
Expand Down
6 changes: 6 additions & 0 deletions docs/index.md
@@ -1,10 +1,16 @@
---
layout: home

title: Vite
titleTemplate: Next Generation Frontend Tooling

hero:
name: Vite
text: Next Generation Frontend Tooling
tagline: Get ready for a development environment that can finally catch up with you.
image:
src: /logo-with-shadow.png
alt: Vite
actions:
- theme: brand
text: Get Started
Expand Down
Binary file added docs/public/logo-with-shadow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"format": "prettier --write .",
"lint": "eslint packages/*/{src,types}/** playground/**/__tests__/**/*.ts scripts/**",
"lint": "eslint packages/*/{src,types,__tests__}/** playground/**/__tests__/**/*.ts scripts/**",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
"test": "run-s test-unit test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
Expand Down Expand Up @@ -88,7 +88,7 @@
"typescript": "^4.6.4",
"unbuild": "^0.7.4",
"vite": "workspace:*",
"vitepress": "1.0.0-draft.4",
"vitepress": "1.0.0-draft.8",
"vitest": "^0.12.9",
"vue": "^3.2.35"
},
Expand Down
5 changes: 2 additions & 3 deletions packages/create-vite/__tests__/cli.spec.ts
@@ -1,9 +1,8 @@
/* eslint-disable node/no-extraneous-import */
import { join } from 'path'
import type { ExecaSyncReturnValue, SyncOptions } from 'execa'
import { commandSync } from 'execa'
import { mkdirpSync, readdirSync, remove, writeFileSync } from 'fs-extra'
import { join } from 'path'
import { test, expect, beforeAll, afterEach } from 'vitest'
import { afterEach, beforeAll, expect, test } from 'vitest'

const CLI_PATH = join(__dirname, '..')

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-legacy/src/index.ts
Expand Up @@ -517,7 +517,7 @@ export async function detectPolyfills(
code: string,
targets: any,
list: Set<string>
) {
): Promise<void> {
const babel = await loadBabel()
const { ast } = babel.transform(code, {
ast: true,
Expand Down
16 changes: 16 additions & 0 deletions packages/vite/CHANGELOG.md
@@ -1,3 +1,19 @@
## 3.0.0-alpha.7 (2022-05-27)

* fix: preserve annotations during build deps optimization (#8358) ([334cd9f](https://github.com/vitejs/vite/commit/334cd9f)), closes [#8358](https://github.com/vitejs/vite/issues/8358)
* refactor: `ExportData.imports` to `ExportData.hasImports` (#8355) ([168de2d](https://github.com/vitejs/vite/commit/168de2d)), closes [#8355](https://github.com/vitejs/vite/issues/8355)



## 3.0.0-alpha.6 (2022-05-27)

* fix: missing types for `es-module-lexer` (fixes #8349) (#8352) ([df2cc3d](https://github.com/vitejs/vite/commit/df2cc3d)), closes [#8349](https://github.com/vitejs/vite/issues/8349) [#8352](https://github.com/vitejs/vite/issues/8352)
* fix(optimizer): transpile before calling `transformGlobImport` (#8343) ([1dbc7cc](https://github.com/vitejs/vite/commit/1dbc7cc)), closes [#8343](https://github.com/vitejs/vite/issues/8343)
* feat: scan free dev server (#8319) ([3f742b6](https://github.com/vitejs/vite/commit/3f742b6)), closes [#8319](https://github.com/vitejs/vite/issues/8319)
* chore: remove unused dts from dist (#8346) ([de9f556](https://github.com/vitejs/vite/commit/de9f556)), closes [#8346](https://github.com/vitejs/vite/issues/8346)



## 3.0.0-alpha.5 (2022-05-26)

* feat: non-blocking esbuild optimization at build time (#8280) ([909cf9c](https://github.com/vitejs/vite/commit/909cf9c)), closes [#8280](https://github.com/vitejs/vite/issues/8280)
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/package.json
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "3.0.0-alpha.5",
"version": "3.0.0-alpha.7",
"type": "module",
"license": "MIT",
"author": "Evan You",
Expand Down Expand Up @@ -49,10 +49,11 @@
"dev": "rimraf dist && pnpm run build-bundle -w",
"build": "rimraf dist && run-s build-bundle build-types",
"build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
"build-types": "run-s build-temp-types patch-types roll-types",
"build-types": "run-s build-temp-types patch-types roll-types check-dist-types",
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
"patch-types": "esno scripts/patchTypes.ts",
"roll-types": "api-extractor run && rimraf temp",
"check-dist-types": "tsc --project tsconfig.check.json",
"lint": "eslint --ext .ts src/**",
"format": "prettier --write --parser typescript \"src/**/*.ts\"",
"prepublishOnly": "npm run build"
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/config.ts
Expand Up @@ -871,7 +871,7 @@ async function loadConfigFromBundledFile(
return config
}

export function isDepsOptimizerEnabled(config: ResolvedConfig) {
export function isDepsOptimizerEnabled(config: ResolvedConfig): boolean {
const { command, optimizeDeps } = config
const { disabled } = optimizeDeps
return !(
Expand Down
11 changes: 3 additions & 8 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Expand Up @@ -171,20 +171,15 @@ export function esbuildDepPlugin(
}

let contents = ''
const data = exportsData[id]
const [imports, exports] = data
if (!imports.length && !exports.length) {
const { hasImports, exports, hasReExports } = exportsData[id]
if (!hasImports && !exports.length) {
// cjs
contents += `export default require("${relativePath}");`
} else {
if (exports.includes('default')) {
contents += `import d from "${relativePath}";export default d;`
}
if (
data.hasReExports ||
exports.length > 1 ||
exports[0] !== 'default'
) {
if (hasReExports || exports.length > 1 || exports[0] !== 'default') {
contents += `\nexport * from "${relativePath}"`
}
}
Expand Down

0 comments on commit b71e1ea

Please sign in to comment.