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

perf(resolve): avoid isWorkerRequest and clean up .ts imported a .js #12571

Merged
merged 3 commits into from Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 2 additions & 6 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -48,7 +48,6 @@ import {
loadPackageData,
resolvePackageData,
} from '../packages'
import { isWorkerRequest } from './worker'

const normalizedClientEntry = normalizePath(CLIENT_ENTRY)
const normalizedEnvEntry = normalizePath(ENV_ENTRY)
Expand Down Expand Up @@ -177,16 +176,13 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
}

if (importer) {
const _importer = isWorkerRequest(importer)
? splitFileAndPostfix(importer).file
: importer
if (
isTsRequest(_importer) ||
isTsRequest(cleanUrl(importer)) ||
resolveOpts.custom?.depScan?.loader?.startsWith('ts')
) {
options.isFromTsImporter = true
} else {
const moduleLang = this.getModuleInfo(_importer)?.meta?.vite?.lang
const moduleLang = this.getModuleInfo(importer)?.meta?.vite?.lang
options.isFromTsImporter = moduleLang && isTsRequest(`.${moduleLang}`)
}
}
Expand Down
8 changes: 0 additions & 8 deletions packages/vite/src/node/plugins/worker.ts
Expand Up @@ -32,14 +32,6 @@ export type WorkerType = 'classic' | 'module' | 'ignore'
export const WORKER_FILE_ID = 'worker_file'
const workerCache = new WeakMap<ResolvedConfig, WorkerCache>()

export function isWorkerRequest(id: string): boolean {
const query = parseRequest(id)
if (query && query[WORKER_FILE_ID] != null) {
return true
}
return false
}

function saveEmitWorkerAsset(
config: ResolvedConfig,
asset: EmittedAsset,
Expand Down