Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: scan free dev server #8319

Merged
merged 68 commits into from May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
305eefc
feat: non-blocking needs interop
patak-dev Apr 1, 2022
bfff06a
chore: update jsxLoader hint
patak-dev Apr 2, 2022
19e7168
fix: avoid the breaking change
patak-dev Apr 2, 2022
5837ce9
fix: handle edge case and simplify
patak-dev Apr 3, 2022
5291442
chore: merge main
patak-dev May 9, 2022
628399e
chore: merge main
patak-dev May 9, 2022
29ee41e
chore: merge main
patak-dev May 11, 2022
9199c63
chore: merge main
patak-dev May 12, 2022
2530ea6
chore: merge main
patak-dev May 13, 2022
3b58a43
feat: build time esbuild based deps optimization
patak-dev May 21, 2022
5f3cd98
chore: lint, remove unused import
patak-dev May 21, 2022
92b0609
chore: merge main
patak-dev May 22, 2022
fbd4c0f
feat: scan free one pass optimization during build
patak-dev May 22, 2022
c7f4485
chore: merge main
patak-dev May 22, 2022
027b50f
fix: handle dynamic import
patak-dev May 22, 2022
40e0a26
chore: merge main
patak-dev May 22, 2022
a635b41
chore: merge feat/non-blocking-need-es-interop
patak-dev May 22, 2022
f9d8e41
refactor: simplify for non-blocking needInterop
patak-dev May 22, 2022
386391c
test: skip three non-supported tests
patak-dev May 22, 2022
dcd3b5e
chore: merge main
patak-dev May 23, 2022
14b70f7
fix: optimizeDeps.include support
patak-dev May 23, 2022
f7488f6
chore: merge main
patak-dev May 23, 2022
8dc6def
chore: format
patak-dev May 23, 2022
ff76fbb
chore: merge main
patak-dev May 23, 2022
8093499
test: try to exclude external component
patak-dev May 23, 2022
0872fe4
chore: fix ssr-vue test
bluwy May 24, 2022
1c38395
chore: update ssr-react tests
bluwy May 24, 2022
fc47ae8
feat: improve run optimizer when iddle logic
patak-dev May 24, 2022
fd4c815
test: revert skip for resolve test
patak-dev May 24, 2022
51e4c97
feat: shared optimizedDeps for worker builds
patak-dev May 24, 2022
d5fdaf9
feat: don't block deps processing in workers sources
patak-dev May 24, 2022
63b62bb
chore: merge feat/non-blocking-need-es-interop
patak-dev May 24, 2022
58cbd2c
test: don't skip ssr-vue /external test
patak-dev May 24, 2022
7216c98
fix: build
patak-dev May 24, 2022
46f5d8b
test: add nested-deps, but skip test-package-e-included
patak-dev May 24, 2022
ec453fb
chore: don't use commonjs plugins in workers
patak-dev May 24, 2022
9f2f6e9
test: update nested-deps include/exclude config
patak-dev May 24, 2022
04c2a65
test: exclude doesn't support nested, thanks @bluwy
patak-dev May 24, 2022
3e6e54e
chore: merge main
patak-dev May 24, 2022
7ed333e
chore: TODO, skip nested exclude test
patak-dev May 24, 2022
9cdc833
feat: support watch mode
patak-dev May 24, 2022
216290e
chore: format
patak-dev May 24, 2022
d08b766
Merge branch 'main' into feat/non-blocking-need-es-interop
patak-dev May 24, 2022
e460893
feat: scan free dev server
patak-dev May 25, 2022
fb1fe27
chore: format
patak-dev May 25, 2022
b88a120
chore: clean up
patak-dev May 25, 2022
8ba5f2e
fix: optimize-missing-deps, remove skip for darwin
patak-dev May 25, 2022
95aac5e
chore: lint
patak-dev May 25, 2022
76a2015
test: skip test again in darwin, seems Vitest has an issue here in CI
patak-dev May 25, 2022
ef14106
Merge branch 'feat/non-blocking-need-es-interop' into feat/non-blocki…
antfu May 25, 2022
bbe6903
chore: fix typo
patak-dev May 25, 2022
72b1f04
chore: clean up
patak-dev May 25, 2022
889257e
chore: runOptimizerWhenIdle clean up
patak-dev May 25, 2022
2a9801e
chore: name constant delay time
patak-dev May 25, 2022
809fdb8
chore: clean up
patak-dev May 25, 2022
0b4762b
chore: merge
patak-dev May 25, 2022
71297e0
fix: build
patak-dev May 25, 2022
13e5a48
feat: optimizedDeps.devScan opt-in config
patak-dev May 25, 2022
4cd8653
chore: simplify expression
patak-dev May 25, 2022
a69857b
chore: update comment
patak-dev May 25, 2022
3bcfc8e
chore: fix build, Promise<any>
patak-dev May 25, 2022
8133edc
chore: merge main
patak-dev May 25, 2022
e7cac66
refactor: optimizedDeps -> depsOptimizer
patak-dev May 26, 2022
ec1a639
chore: lint
patak-dev May 26, 2022
6bdd7e1
refactor: avoid config and server dep in resolvePlugin
patak-dev May 26, 2022
af443a9
refactor: optimizeDeps.disabled: boolean | 'dev' | 'build'
patak-dev May 26, 2022
94ac5a6
chore: merge
patak-dev May 26, 2022
483f544
chore: merge main
patak-dev May 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/plugin-react/src/index.ts
Expand Up @@ -2,7 +2,6 @@ import path from 'path'
import type { ParserOptions, TransformOptions, types as t } from '@babel/core'
import * as babel from '@babel/core'
import { createFilter } from '@rollup/pluginutils'
import resolve from 'resolve'
import { normalizePath } from 'vite'
import type { Plugin, PluginOption, ResolvedConfig } from 'vite'
import {
Expand Down Expand Up @@ -362,7 +361,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
}
}

const runtimeId = 'react/jsx-runtime'
// const runtimeId = 'react/jsx-runtime'
// Adapted from https://github.com/alloc/vite-react-jsx
const viteReactJsx: Plugin = {
name: 'vite:react-jsx',
Expand All @@ -373,10 +372,14 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
include: ['react/jsx-dev-runtime']
}
}
},
}
// TODO: this optimization may not be necesary and it is breacking esbuild+rollup compat,
// see https://github.com/vitejs/vite/pull/7246#discussion_r861552185
// We could still do the same trick and resolve to the optimized dependency here
/*
resolveId(id: string) {
return id === runtimeId ? id : null
},
},
load(id: string) {
if (id === runtimeId) {
const runtimePath = resolve.sync(runtimeId, {
Expand All @@ -391,7 +394,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
...exports.map((name) => `export const ${name} = jsxRuntime.${name}`)
].join('\n')
}
}
} */
}

return [viteBabel, viteReactRefresh, useAutomaticRuntime && viteReactJsx]
Expand Down
17 changes: 16 additions & 1 deletion packages/vite/src/node/build.ts
Expand Up @@ -35,6 +35,7 @@ import { resolveSSRExternal, shouldExternalizeForSSR } from './ssr/ssrExternal'
import { ssrManifestPlugin } from './ssr/ssrManifestPlugin'
import type { DepOptimizationMetadata } from './optimizer'
import { findKnownImports, getDepsCacheDir } from './optimizer'
import { createOptimizedDeps } from './optimizer/registerMissing'
import { assetImportMetaUrlPlugin } from './plugins/assetImportMetaUrl'
import { loadFallbackPlugin } from './plugins/loadFallback'
import type { PackageData } from './packages'
Expand Down Expand Up @@ -124,6 +125,13 @@ export interface BuildOptions {
* https://rollupjs.org/guide/en/#big-list-of-options
*/
rollupOptions?: RollupOptions
/**
* Optimize deps with esbuild during build in the same way as in dev
* When this is enabled, `@rollup/plugin-commonjs` isn't included
* @default true
* @experimental
*/
optimizeDeps?: boolean
/**
* Options to pass on to `@rollup/plugin-commonjs`
*/
Expand Down Expand Up @@ -228,6 +236,7 @@ export function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions {
reportCompressedSize: true,
chunkSizeWarningLimit: 500,
watch: null,
optimizeDeps: true,
...raw,
commonjsOptions: {
include: [/node_modules/],
Expand Down Expand Up @@ -283,7 +292,9 @@ export function resolveBuildPlugins(config: ResolvedConfig): {
pre: [
...(options.watch ? [ensureWatchPlugin()] : []),
watchPackageDataPlugin(config),
commonjsPlugin(options.commonjsOptions),
...(!options.optimizeDeps || options.ssr
? [commonjsPlugin(options.commonjsOptions)]
: []),
dataURIPlugin(),
assetImportMetaUrlPlugin(config),
...(options.rollupOptions.plugins
Expand Down Expand Up @@ -390,6 +401,10 @@ async function doBuild(
)
}

if (options.optimizeDeps && !ssr) {
await createOptimizedDeps(config)
}

const rollupOptions: RollupOptions = {
input,
context: 'globalThis',
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/node/cli.ts
Expand Up @@ -25,6 +25,7 @@ interface GlobalCLIOptions {
filter?: string
m?: string
mode?: string
force?: boolean
}

/**
Expand Down Expand Up @@ -152,6 +153,10 @@ cli
)
.option('--manifest [name]', `[boolean | string] emit build manifest json`)
.option('--ssrManifest [name]', `[boolean | string] emit ssr manifest json`)
.option(
'--force',
`[boolean] force the optimizer to ignore the cache and re-bundle (experimental)`
)
.option(
'--emptyOutDir',
`[boolean] force empty outDir when it's outside of root`
Expand All @@ -169,6 +174,7 @@ cli
configFile: options.config,
logLevel: options.logLevel,
clearScreen: options.clearScreen,
force: options.force,
build: buildOptions
})
} catch (e) {
Expand Down
5 changes: 5 additions & 0 deletions packages/vite/src/node/config.ts
Expand Up @@ -144,6 +144,11 @@ export interface UserConfig {
* Preview specific options, e.g. host, port, https...
*/
preview?: PreviewOptions
/**
* Force dep pre-optimization regardless of whether deps have changed.
* @experimental
*/
force?: boolean
patak-dev marked this conversation as resolved.
Show resolved Hide resolved
/**
* Dep optimization options
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/index.ts
Expand Up @@ -36,7 +36,8 @@ export type {
DepOptimizationResult,
DepOptimizationProcessing,
OptimizedDepInfo,
OptimizedDeps
OptimizedDeps,
ExportsData
} from './optimizer'
export type { Plugin } from './plugin'
export type { PackageCache, PackageData } from './packages'
Expand Down