From 196c849b8a54466f6c60875aa9ecb87f2cc9a891 Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Wed, 11 Feb 2026 12:45:46 -0500 Subject: [PATCH] refactor(utils): update import paths and normalize type definitions Refactor the parse-query utility to improve import paths for BundleQuery and JSON5. This change enhances code clarity and consistency by aligning with the new directory structure. Additionally, the NormalizedBundleQuery type definition has been adjusted for better type safety. Should verify by checking the functionality of query parsing in various scenarios. Signed-off-by: Okiki Ojo --- edge/_shared/utils/parse-query.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/edge/_shared/utils/parse-query.ts b/edge/_shared/utils/parse-query.ts index 17e3ee1..cd41180 100644 --- a/edge/_shared/utils/parse-query.ts +++ b/edge/_shared/utils/parse-query.ts @@ -9,9 +9,9 @@ * - Config JSON5 parsing */ -import type { BundleQuery, NormalizedBundleQuery } from '../../endpoints/_schemas.ts' +import type { BundleQuery } from '../bundle/schema.ts' import { lzstring, parsePackageName, deepMerge } from '@bundle/utils' -import JSON5 from '../vendor/json5.ts' +import JSON5 from '@bundle/utils/json5' const { decompressFromURL } = lzstring @@ -26,6 +26,21 @@ export const DEFAULT_INPUT = [ 'export { default } from "spring-easing";', ].join('\n') +export type NormalizedBundleQuery = { + packages: string[] + modules: Array<[string, 'import' | 'export']> + treeshakeExports: string[] + exportAll: boolean + inputCode: string + config: Record + tsx: boolean + minify?: boolean + sourcemap?: '' | 'true' | 'false' | 'inline' | 'external' | 'both' + format?: 'esm' | 'cjs' | 'iife' + polyfill: boolean + metafile: boolean +} + // ============================================================================= // Treeshake Parsing // ============================================================================= @@ -256,7 +271,7 @@ export function normalizeBundleQuery(raw: BundleQuery): NormalizedBundleQuery { const tsx = Boolean(raw.tsx || raw.jsx || (config as Record).tsx) // Minify: explicit minify=true/false, or inverse of pretty - let minify: boolean | null = null + let minify: boolean | undefined = undefined if (raw.minify !== undefined) { minify = raw.minify } else if (raw.pretty !== undefined) { @@ -264,10 +279,10 @@ export function normalizeBundleQuery(raw: BundleQuery): NormalizedBundleQuery { } // Sourcemap - const sourcemap = raw.sourcemap ?? null + const sourcemap = raw.sourcemap ?? undefined // Format - const format = raw.format ?? null + const format = raw.format ?? undefined // Feature flags const polyfill = Boolean(raw.polyfill) -- knotmirror 0.0.1