diff --git a/packages/router-plugin/tests/code-splitter-ambient-declarations.test.ts b/packages/router-plugin/tests/code-splitter-ambient-declarations.test.ts deleted file mode 100644 index b9690208ad..0000000000 --- a/packages/router-plugin/tests/code-splitter-ambient-declarations.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { parseSync, transformWithOxc } from 'vite' -import { describe, expect, it } from 'vitest' -import { compileRouteModules } from './regression-helpers' - -/** The module record a bundler sees once TypeScript is erased. */ -async function runtimeModuleInfo(code: string) { - const { code: javascript } = await transformWithOxc(code, 'module.tsx', { - jsx: 'preserve', - typescript: { onlyRemoveTypeImports: true }, - }) - return parseSync('module.jsx', javascript, { sourceType: 'module' }).module -} - -/** - * Every value a module imports from the shared module must be exported by the - * shared module at runtime; otherwise bundlers fail with a missing export and - * browsers refuse to link the module. - */ -async function missingSharedImports(modules: Record) { - const sharedExports = new Set() - if (modules.shared) { - for (const entry of (await runtimeModuleInfo(modules.shared)) - .staticExports) { - for (const item of entry.entries) { - if (item.exportName.name) { - sharedExports.add(item.exportName.name) - } - } - } - } - const missing: Array = [] - for (const [name, code] of Object.entries(modules)) { - if (name === 'shared') { - continue - } - for (const declaration of (await runtimeModuleInfo(code)).staticImports) { - if (!declaration.moduleRequest.value.includes('tsr-shared')) { - continue - } - for (const entry of declaration.entries) { - const imported = entry.importName.name ?? 'default' - if (!entry.isType && !sharedExports.has(imported)) { - missing.push(`${name} imports ${imported}`) - } - } - } - } - return missing -} - -// Ambient declarations (`declare ...`) have no runtime binding: the value is -// provided by the environment (a