-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: vite-dev-server refactor to enable version bumps and testing v…
…ite core perf improvements
- Loading branch information
Showing
21 changed files
with
689 additions
and
466 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
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,6 @@ | ||
export const configFiles = [ | ||
'vite.config.ts', | ||
'vite.config.js', | ||
'vite.config.mjs', | ||
'vite.config.cjs', | ||
] |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './inspect' | ||
|
||
export * from './cypress' |
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,25 @@ | ||
import debugFn from 'debug' | ||
import type { PluginOption } from 'vite' | ||
|
||
const debug = debugFn('cypress:vite-dev-server:plugins:inspect') | ||
|
||
export const CypressInspect = async (): Promise<(() => PluginOption) | null> => { | ||
if (!process.env.DEBUG) return null | ||
|
||
let Inspect | ||
|
||
try { | ||
Inspect = (await import('vite-plugin-inspect')).default | ||
debug('inspect was found', Inspect) | ||
} catch (err) { | ||
debug(`Tried to import the inspect plugin 'vite-plugin-inspect'. It's an optional peerDependency so install it if you'd like.`) | ||
debug(err) | ||
|
||
return null | ||
} | ||
|
||
return { | ||
...Inspect(), | ||
name: 'cypress:inspect', | ||
} | ||
} |
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,55 @@ | ||
/** | ||
* The logic inside of this file is heavily reused from | ||
* Vitest's own config resolution logic. | ||
* You can find it here https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/create.ts | ||
*/ | ||
import debugFn from 'debug' | ||
import { importModule } from 'local-pkg' | ||
import { relative, resolve } from 'pathe' | ||
import { mergeConfig } from 'vite' | ||
import { configFiles } from './constants' | ||
import { Cypress, CypressInspect } from './plugins/index' | ||
import type { StartDevServer } from './types' | ||
|
||
const debug = debugFn('cypress:vite-dev-server:resolve-config') | ||
|
||
export const createConfig = async ({ options, viteConfig: viteOverrides = {} }: StartDevServer) => { | ||
const root = options.config.projectRoot || resolve(process.cwd()) | ||
const { default: findUp } = await importModule('find-up') | ||
const configFile = await findUp(configFiles, { cwd: root } as { cwd: string }) | ||
|
||
// INFO logging, a lot is logged here. | ||
// debug('all dev-server options are', options) | ||
|
||
if (configFile) { | ||
debug('resolved config file at', configFile, 'using root', root) | ||
} else if (viteOverrides) { | ||
debug('Couldn\'t find a Vite config file, however we received a custom viteConfig', viteOverrides) | ||
} else { | ||
debug(` | ||
Didn\'t resolve a Vite config AND the user didn\'t pass in a custom viteConfig. | ||
Falling back to Vite\'s defaults.`) | ||
} | ||
|
||
const config = { | ||
root, | ||
base: `/${options.config.namespace}/src/`, | ||
configFile, | ||
optimizeDeps: { | ||
entries: [ | ||
...options.specs.map((s) => relative(root, s.relative)), | ||
options.config.supportFile ?? resolve(root, options.config.supportFile), | ||
].filter((v) => v != null), | ||
}, | ||
plugins: [ | ||
Cypress(options), | ||
await CypressInspect(), | ||
], | ||
} | ||
|
||
const finalConfig = mergeConfig(config, viteOverrides) | ||
|
||
debug('The resolved server config is', JSON.stringify(finalConfig, null, 2)) | ||
|
||
return finalConfig | ||
} |
Oops, something went wrong.
ae884fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
ae884fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
ae884fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: