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: option to disable pre-transform #6309

Merged
merged 3 commits into from Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -564,7 +564,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
)

// pre-transform known direct imports
if (staticImportedUrls.size) {
if (config.server.preTransformRequests && staticImportedUrls.size) {
staticImportedUrls.forEach((url) => {
transformRequest(unwrapId(removeImportQuery(url)), server, { ssr })
})
Expand Down
14 changes: 12 additions & 2 deletions packages/vite/src/node/server/index.ts
Expand Up @@ -95,6 +95,13 @@ export interface ServerOptions extends CommonServerOptions {
* Origin for the generated asset URLs.
*/
origin?: string
/**
* Pre-transform known direct imports
*
* @expiremental this options is expiremental and might be changed in the future
* @default true
*/
preTransformRequests?: boolean
}

export interface ResolvedServerOptions extends ServerOptions {
Expand Down Expand Up @@ -692,7 +699,10 @@ export function resolveServerOptions(
root: string,
raw?: ServerOptions
): ResolvedServerOptions {
const server = raw || {}
const server: ResolvedServerOptions = {
preTransformRequests: true,
...(raw as ResolvedServerOptions)
}
let allowDirs = server.fs?.allow
const deny = server.fs?.deny || ['.env', '.env.*', '*.{crt,pem}']

Expand All @@ -713,7 +723,7 @@ export function resolveServerOptions(
allow: allowDirs,
deny
}
return server as ResolvedServerOptions
return server
}

async function restartServer(server: ViteDevServer) {
Expand Down