client-bundle-purity.spec.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. /**
  2. * Pins shared client-bundle preset rules: module-edge purity, source-map
  3. * chaining, and physical watch dependencies hidden behind virtual CSS Modules.
  4. */
  5. import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
  6. import { tmpdir } from 'node:os'
  7. import { dirname, join, relative } from 'node:path'
  8. import { fileURLToPath } from 'node:url'
  9. import { build, type TsdownBundle, type UserConfig } from 'tsdown'
  10. import { describe, expect, it, onTestFinished, vi } from 'vitest'
  11. import { clientBundle, requestedExternals, staticLinked } from '../packages/client/tsdown.client.ts'
  12. type ResolveId = (source: string) => null | { id: string; external: boolean }
  13. interface CssModulePlugin {
  14. name: string
  15. resolveId?: (source: string, importer: string | undefined) => null | string
  16. load?: (this: { addWatchFile: (id: string) => void }, id: string) => Promise<unknown>
  17. }
  18. interface SourceMapPlugin {
  19. name: string
  20. load?: (id: string) => Promise<unknown>
  21. }
  22. interface InputIsolationPlugin {
  23. name: string
  24. generateBundle: (this: {
  25. getModuleInfo(id: string): { importedIds: string[]; dynamicallyImportedIds: string[] } | null
  26. }, options: unknown, bundle: Record<string, {
  27. type: 'chunk'
  28. modules: Record<string, object>
  29. imports: string[]
  30. dynamicImports: string[]
  31. }>) => void
  32. }
  33. /** A representative dynamic bundle using the shared client baseline. */
  34. const REQUESTING_PACKAGE = '@deepseek-ai/dsh-client-ui-conversation'
  35. function clientConfigs(id = REQUESTING_PACKAGE) {
  36. return clientBundle(id, ['lib/types/index.js', 'lib/types/invariant.js'])(
  37. { env: { DSH_BUILD_FACE: 'client' } },
  38. ).filter(config => config.platform === 'browser')
  39. }
  40. describe('client bundle build faces', () => {
  41. it('watches source in development and consumes emitted JavaScript in the Client build', () => {
  42. const bundle = clientBundle('@deepseek-ai/dsh-client-test', ['lib/types/index.js'])
  43. const development = bundle({ env: {} }).find(config => config.platform === 'browser')
  44. const artifact = bundle({ env: { DSH_BUILD_FACE: 'client' } })
  45. .find(config => config.platform === 'browser')
  46. expect(development?.entry).toEqual({ client: 'src/client/index.ts' })
  47. expect(artifact?.entry).toEqual({ client: 'lib/types/client/index.js' })
  48. })
  49. })
  50. function clientSourceMapPath(packagePath: string): string {
  51. return fileURLToPath(new URL(`../packages/${packagePath}/lib/client.js.map`, import.meta.url))
  52. }
  53. function purityResolveId(id = REQUESTING_PACKAGE): ResolveId {
  54. // libEntry is spelled at every call site (no default) so the
  55. // package-invariants text check can see the invariant entry per package.
  56. const configs = clientConfigs(id)
  57. const plugins = (configs[0] as { plugins: { name: string; resolveId?: unknown }[] }).plugins
  58. const gate = plugins.find(p => p.name === 'dsh-client-bundle-purity')
  59. if (gate?.resolveId === undefined) throw new Error('purity plugin missing from client config')
  60. return gate.resolveId as ResolveId
  61. }
  62. function cssModulePlugin(): CssModulePlugin {
  63. const configs = clientConfigs()
  64. const plugins = (configs[0] as { plugins: CssModulePlugin[] }).plugins
  65. const plugin = plugins.find(candidate => candidate.name === 'dsh-css-modules-inline')
  66. if (plugin?.resolveId === undefined || plugin.load === undefined) {
  67. throw new Error('CSS Modules plugin missing from client config')
  68. }
  69. return plugin
  70. }
  71. function sourceMapPlugin(): SourceMapPlugin {
  72. const configs = clientConfigs()
  73. const plugins = (configs[0] as { plugins: SourceMapPlugin[] }).plugins
  74. const plugin = plugins.find(candidate => candidate.name === 'dsh-tsc-sourcemap')
  75. if (plugin?.load === undefined) throw new Error('tsc sourcemap plugin missing from client config')
  76. return plugin
  77. }
  78. describe('client bundle purity gate', () => {
  79. const resolveId = purityResolveId()
  80. it('leaves default externals and non-scoped specifiers alone', () => {
  81. expect(resolveId('@deepseek-ai/dsh-client-store')).toBeNull()
  82. expect(resolveId('@deepseek-ai/dsh-client-ui-slots')).toBeNull()
  83. expect(resolveId('@deepseek-ai/dsh-client-ui-primitives')).toBeNull()
  84. expect(resolveId('react')).toBeNull()
  85. expect(resolveId('zod')).toBeNull()
  86. })
  87. it('rejects the retired web-react platform package', () => {
  88. expect(() => resolveId('@deepseek-ai/dsh-client-web-react')).toThrow(/purity/)
  89. expect(() => resolveId('@deepseek-ai/dsh-client-web-react/store')).toThrow(/purity/)
  90. })
  91. it('lets inline-safe libraries inline', () => {
  92. expect(resolveId('@deepseek-ai/dsh-session/surface')).toBeNull()
  93. expect(resolveId('@deepseek-ai/dsh-brand')).toBeNull()
  94. expect(resolveId('@deepseek-ai/dsh-deque')).toBeNull()
  95. expect(resolveId('@deepseek-ai/dsh-util-values')).toBeNull()
  96. expect(resolveId('@deepseek-ai/dsh-token-meter/client')).toBeNull()
  97. expect(() => resolveId('@deepseek-ai/dsh-token-meter')).toThrow(/purity/)
  98. expect(() => resolveId('@deepseek-ai/dsh-token-meter/client/internal')).toThrow(/purity/)
  99. expect(resolveId('@deepseek-ai/dsh-host-open-in-app/shared')).toBeNull()
  100. expect(() => resolveId('@deepseek-ai/dsh-host-open-in-app')).toThrow(/purity/)
  101. })
  102. it('admits only the pure spill notice entry, not its Host policy', () => {
  103. expect(resolveId('@deepseek-ai/dsh-spill-policy/notice')).toBeNull()
  104. expect(resolveId('@deepseek-ai/dsh-output-retention')).toBeNull()
  105. expect(() => resolveId('@deepseek-ai/dsh-spill-policy')).toThrow(/purity/)
  106. expect(() => resolveId('@deepseek-ai/dsh-spill-policy/notice/internal')).toThrow(/purity/)
  107. })
  108. it('lets exact generated Remote contributions inline without admitting their package implementation', () => {
  109. expect(resolveId('@deepseek-ai/dsh-goal/remote')).toBeNull()
  110. expect(() => resolveId('@deepseek-ai/dsh-goal')).toThrow(/purity/)
  111. expect(() => resolveId('@deepseek-ai/dsh-goal/client')).toThrow(/purity/)
  112. expect(() => resolveId('@deepseek-ai/dsh-goal/remote/nested')).toThrow(/purity/)
  113. })
  114. it('throws on any other @deepseek-ai leak', () => {
  115. expect(() => resolveId('@deepseek-ai/dsh-agent')).toThrow(/purity/)
  116. expect(() => resolveId('@deepseek-ai/dsh-client-web')).toThrow(/purity/)
  117. })
  118. it('throws on cross-plugin value imports — bare plugin names and /client subpaths alike', () => {
  119. expect(() => resolveId('@deepseek-ai/dsh-client-connection')).toThrow(/purity/)
  120. expect(() => resolveId('@deepseek-ai/dsh-client-ui-session')).toThrow(/purity/)
  121. expect(() => resolveId('@deepseek-ai/dsh-client-ui-layout/client')).toThrow(/purity/)
  122. })
  123. it('admits package-specific requests only for the declaring bundle', () => {
  124. const requesting = purityResolveId('@deepseek-ai/dsh-api-session-controller')
  125. expect(requesting('@deepseek-ai/dsh-api-gateway/client')).toBeNull()
  126. expect(() => resolveId('@deepseek-ai/dsh-api-gateway/client')).toThrow(/purity/)
  127. })
  128. it('externalizes the baseline independently of each package manifest', () => {
  129. const requesting = clientConfigs()[0]?.deps as { neverBundle: (specifier: string) => boolean }
  130. const plain = clientConfigs('@deepseek-ai/dsh-client-connection')[0]?.deps as {
  131. neverBundle: (specifier: string) => boolean
  132. }
  133. expect(requesting.neverBundle('react')).toBe(true)
  134. expect(requesting.neverBundle('zod')).toBe(false)
  135. expect(plain.neverBundle('react')).toBe(true)
  136. expect(plain.neverBundle('@deepseek-ai/dsh-client-store')).toBe(true)
  137. })
  138. })
  139. describe('client bundle experimental input isolation', () => {
  140. const experimental = '@deepseek-ai/dsh-experimental-client-ui-agent-team'
  141. function fixture() {
  142. const root = mkdtempSync(join(tmpdir(), 'dsh-client-inputs-'))
  143. onTestFinished(() => { rmSync(root, { recursive: true, force: true }) })
  144. const owner = join(root, 'client')
  145. const entry = join(owner, 'lib/types/client/index.js')
  146. const prototype = join(root, 'prototype/src/index.js')
  147. for (const file of [entry, prototype]) mkdirSync(dirname(file), { recursive: true })
  148. writeFileSync(join(owner, 'package.json'), JSON.stringify({ name: REQUESTING_PACKAGE, type: 'module' }))
  149. writeFileSync(join(root, 'prototype/package.json'), JSON.stringify({ name: experimental, type: 'module' }))
  150. writeFileSync(prototype, 'export const marker = "experimental sentinel"\n')
  151. return { root, owner, entry, prototype }
  152. }
  153. function config(kind: 'static' | 'dynamic', id = REQUESTING_PACKAGE): UserConfig {
  154. const configs = kind === 'static'
  155. ? staticLinked(id, ['lib/types/client/index.js'])({ env: { DSH_BUILD_FACE: 'client' } })
  156. : clientConfigs(id)
  157. const browser = configs.find(config => config.platform === 'browser')
  158. if (browser === undefined) throw new Error('client config missing')
  159. return browser
  160. }
  161. async function bundle(owner: string, config: UserConfig): Promise<string> {
  162. let builds: TsdownBundle[] = []
  163. try {
  164. builds = await build({
  165. ...config, cwd: owner, config: false, tsconfig: false,
  166. write: false, clean: false, exports: false, report: false, logLevel: 'silent',
  167. })
  168. return builds.flatMap(build => build.chunks.filter(chunk => chunk.type === 'chunk').map(chunk => chunk.code)).join('\n')
  169. } finally {
  170. for (const build of builds) await build[Symbol.asyncDispose]()
  171. }
  172. }
  173. function importPath(from: string, to: string): string {
  174. return relative(dirname(from), to).replaceAll('\\', '/')
  175. }
  176. function checkCompilerModule(module: string, imports?: string[]): void {
  177. const plugins = config('dynamic').plugins as InputIsolationPlugin[]
  178. const plugin = plugins.find(plugin => plugin.name === 'dsh-client-input-isolation')
  179. if (plugin === undefined) throw new Error('client input isolation plugin missing')
  180. plugin.generateBundle.call({
  181. getModuleInfo: () => imports === undefined ? null : { importedIds: imports, dynamicallyImportedIds: [] },
  182. }, {}, {
  183. 'client.js': { type: 'chunk', modules: { [module]: {} }, imports: [], dynamicImports: [] },
  184. })
  185. }
  186. it('accepts the exact compiler runtime helper without a source module record', () => {
  187. expect(() => { checkCompilerModule('\0rolldown/runtime.js') }).not.toThrow()
  188. })
  189. it.each(['\0rolldown/other.js', '\0rolldown/runtime.js?user', '\0other/runtime.js'])(
  190. 'rejects the unrecorded module %j',
  191. (module) => {
  192. expect(() => { checkCompilerModule(module) }).toThrow(/has no bundler module record/)
  193. },
  194. )
  195. it('checks runtime helper dependencies when the compiler supplies a module record', () => {
  196. expect(() => { checkCompilerModule('\0rolldown/runtime.js', [experimental]) })
  197. .toThrow(/client bundle isolation.*experimental/)
  198. })
  199. it.each(['static', 'dynamic'] as const)('rejects experimental files folded into a %s client artifact', async (kind) => {
  200. const { owner, entry, prototype } = fixture()
  201. writeFileSync(entry, `export { marker } from ${JSON.stringify(importPath(entry, prototype))}\n`)
  202. await expect(bundle(owner, config(kind))).rejects.toThrow(/client bundle isolation.*experimental/)
  203. expect(existsSync(join(owner, 'lib/client.js'))).toBe(false)
  204. expect(existsSync(join(owner, 'lib/index.js'))).toBe(false)
  205. })
  206. it('proves the static library otherwise hides the experimental input in its emitted JavaScript', async () => {
  207. const { owner, entry, prototype } = fixture()
  208. writeFileSync(entry, `export { marker } from ${JSON.stringify(importPath(entry, prototype))}\n`)
  209. const guarded = config('static')
  210. const plugins = guarded.plugins as Array<{ name: string }>
  211. const unguarded: UserConfig = {
  212. ...guarded,
  213. plugins: plugins.filter(plugin => plugin.name !== 'dsh-client-input-isolation'),
  214. outputOptions: { sourcemapExcludeSources: false },
  215. }
  216. await expect(bundle(owner, unguarded)).resolves.toContain('experimental sentinel')
  217. await expect(bundle(owner, guarded)).rejects.toThrow(/client bundle isolation.*experimental/)
  218. })
  219. it.each(['static', 'dynamic'] as const)('allows an experimental %s artifact to keep its own inputs', async (kind) => {
  220. const { owner, entry, prototype } = fixture()
  221. writeFileSync(entry, `export { marker } from ${JSON.stringify(importPath(entry, prototype))}\n`)
  222. await expect(bundle(owner, config(kind, experimental))).resolves.toContain('experimental sentinel')
  223. })
  224. it('rejects experimental ownership preserved only by an emitted compiler source map', async () => {
  225. const { owner, entry, prototype } = fixture()
  226. writeFileSync(entry, 'export const marker = "experimental sentinel"\n//# sourceMappingURL=index.js.map\n')
  227. writeFileSync(`${entry}.map`, JSON.stringify({
  228. version: 3, names: [], mappings: 'AAAA', sources: [importPath(entry, prototype)],
  229. sourcesContent: ['export const marker = "experimental sentinel"\n'],
  230. }))
  231. await expect(bundle(owner, config('static'))).rejects.toThrow(/client bundle isolation.*experimental/)
  232. })
  233. it('checks the resolved module when an import alias conceals its experimental package', async () => {
  234. const { owner, entry, prototype } = fixture()
  235. writeFileSync(entry, 'export { marker } from "./ordinary.js"\n')
  236. await expect(bundle(owner, { ...config('static'), alias: { './ordinary.js': prototype } }))
  237. .rejects.toThrow(/client bundle isolation.*experimental/)
  238. })
  239. it('rejects an experimental runtime import left external by a static client library', async () => {
  240. const { owner, entry } = fixture()
  241. writeFileSync(entry, `export * from ${JSON.stringify(experimental)}\n`)
  242. await expect(bundle(owner, config('static'))).rejects.toThrow(/client bundle isolation.*experimental/)
  243. })
  244. it.each([false, true])('checks omitted source-map files against their package owner (experimental: %s)', async (experimentalSource) => {
  245. const { root, owner, entry } = fixture()
  246. const dependency = join(root, 'dependency')
  247. mkdirSync(dependency)
  248. writeFileSync(join(dependency, 'package.json'), JSON.stringify({ name: experimentalSource ? experimental : 'ordinary-library' }))
  249. writeFileSync(entry, 'export const marker = "mapped sentinel"\n//# sourceMappingURL=index.js.map\n')
  250. writeFileSync(`${entry}.map`, JSON.stringify({
  251. version: 3, names: [], mappings: 'AAAA', sourceRoot: importPath(entry, dependency),
  252. sources: ['unshipped.ts'], sourcesContent: ['export const marker = "mapped sentinel"\n'],
  253. }))
  254. const result = bundle(owner, config('static'))
  255. if (experimentalSource) await expect(result).rejects.toThrow(/client bundle isolation.*experimental/)
  256. else await expect(result).resolves.toContain('mapped sentinel')
  257. })
  258. it.each(['.css', '.module.css', '.css?inline'])('rejects experimental %s inputs behind client CSS virtual loaders', async (extension) => {
  259. const { owner, entry, prototype } = fixture()
  260. const css = join(dirname(prototype), `style${extension.replace('?inline', '')}`)
  261. writeFileSync(css, 'body { color: red; }\n')
  262. const specifier = `${importPath(entry, css)}${extension.endsWith('?inline') ? '?inline' : ''}`
  263. writeFileSync(entry, extension === '.css'
  264. ? `import ${JSON.stringify(specifier)}\nexport const marker = true\n`
  265. : `export { default as style } from ${JSON.stringify(specifier)}\n`)
  266. await expect(bundle(owner, config('dynamic'))).rejects.toThrow(/client bundle isolation.*experimental/)
  267. })
  268. it.each(['static', 'dynamic'] as const)('keeps ordinary %s bundles and source maps buildable', async (kind) => {
  269. const { owner, entry } = fixture()
  270. const source = join(owner, 'src/client/index.ts')
  271. mkdirSync(dirname(source), { recursive: true })
  272. writeFileSync(source, 'export const marker = "stable sentinel"\n')
  273. writeFileSync(entry, 'export const marker = "stable sentinel"\n//# sourceMappingURL=index.js.map\n')
  274. writeFileSync(`${entry}.map`, JSON.stringify({
  275. version: 3, names: [], mappings: 'AAAA', sources: [importPath(entry, source)],
  276. sourcesContent: ['export const marker = "stable sentinel"\n'],
  277. }))
  278. await expect(bundle(owner, config(kind))).resolves.toContain('stable sentinel')
  279. })
  280. })
  281. describe('client bundle module requests', () => {
  282. it('requests what the declaration lists', () => {
  283. const requests = requestedExternals('@deepseek-ai/dsh-client-fixture', {
  284. external: ['react', 'react/jsx-runtime', '@deepseek-ai/dsh-client-ui-slots'],
  285. })
  286. expect([...requests].sort()).toEqual([
  287. '@deepseek-ai/dsh-client-ui-slots', 'react', 'react/jsx-runtime',
  288. ])
  289. })
  290. it('requests nothing when the declaration is absent', () => {
  291. expect(requestedExternals('@deepseek-ai/dsh-client-fixture', {}).size).toBe(0)
  292. })
  293. it('rejects a malformed declaration instead of reading past it', () => {
  294. expect(() => requestedExternals('@deepseek-ai/dsh-client-fixture', { external: 'react' }))
  295. .toThrow(/dsh\.client\.external must be a string array/)
  296. })
  297. })
  298. describe('client bundle debug artifacts', () => {
  299. it('emits source maps for plugin TS and TSX outside the Vite module graph', () => {
  300. const configs = clientConfigs()
  301. expect(configs[0]?.sourcemap).toBe(true)
  302. expect(configs[0]?.outputOptions).toMatchObject({ sourcemapExcludeSources: false })
  303. })
  304. it('chains emitted tsc maps when the production Client build consumes lib/types', async () => {
  305. const root = mkdtempSync(join(tmpdir(), 'dsh-client-sourcemap-'))
  306. try {
  307. const entry = join(root, 'lib', 'types', 'client', 'index.js')
  308. const source = join(root, 'src', 'client', 'index.ts')
  309. const map = { version: 3, names: [], mappings: 'AAAA', sources: ['../../../src/client/index.ts'] }
  310. mkdirSync(join(root, 'lib', 'types', 'client'), { recursive: true })
  311. mkdirSync(join(root, 'src', 'client'), { recursive: true })
  312. writeFileSync(entry, 'export const marker = true\n//# sourceMappingURL=index.js.map\n')
  313. writeFileSync(`${entry}.map`, JSON.stringify(map))
  314. writeFileSync(source, 'export const marker: true = true\n')
  315. await expect(sourceMapPlugin().load!(entry)).resolves.toEqual({
  316. code: 'export const marker = true',
  317. map: { ...map, sourcesContent: ['export const marker: true = true\n'] },
  318. })
  319. } finally {
  320. rmSync(root, { recursive: true, force: true })
  321. }
  322. })
  323. it('maps first-party sources to their repository package paths', () => {
  324. const configs = clientConfigs('@deepseek-ai/dsh-client-ui-goal')
  325. const outputOptions = configs[0]?.outputOptions
  326. if (typeof outputOptions !== 'object' || outputOptions === null) throw new Error('client output options missing')
  327. const transform = outputOptions.sourcemapPathTransform
  328. if (transform === undefined) throw new Error('client sourcemap path transform missing')
  329. const source = transform('../src/client/GoalBar.tsx', clientSourceMapPath('client/ui-goal'))
  330. expect(source).toBe('../../../packages/client/ui-goal/src/client/GoalBar.tsx')
  331. const resolved = new URL(source, 'https://dsh.test/plugins/@deepseek-ai/dsh-client-ui-goal/client.js.map')
  332. expect(resolved.pathname).toBe('/packages/client/ui-goal/src/client/GoalBar.tsx')
  333. })
  334. it('maps dual-face host sources to the host package group', () => {
  335. const configs = clientConfigs('@deepseek-ai/dsh-host-directory-picker-native')
  336. const outputOptions = configs[0]?.outputOptions
  337. if (typeof outputOptions !== 'object' || outputOptions === null) throw new Error('client output options missing')
  338. const transform = outputOptions.sourcemapPathTransform
  339. if (transform === undefined) throw new Error('client sourcemap path transform missing')
  340. const source = transform('../src/client/index.ts', clientSourceMapPath('host/directory-picker-native'))
  341. expect(source).toBe('../../../packages/host/directory-picker-native/src/client/index.ts')
  342. })
  343. it('maps inlined workspace sources to packages and leaves dependencies outside it unchanged', () => {
  344. const configs = clientConfigs('@deepseek-ai/dsh-client-connection')
  345. const outputOptions = configs[0]?.outputOptions
  346. if (typeof outputOptions !== 'object' || outputOptions === null) throw new Error('client output options missing')
  347. const transform = outputOptions.sourcemapPathTransform
  348. if (transform === undefined) throw new Error('client sourcemap path transform missing')
  349. const sourceMapPath = clientSourceMapPath('client/connection')
  350. const workspaceSource = transform('../src/rpc.ts', sourceMapPath)
  351. expect(workspaceSource).toBe('../../../packages/client/connection/src/rpc.ts')
  352. const resolved = new URL(workspaceSource, 'https://dsh.test/plugins/@deepseek-ai/dsh-client-connection/client.js.map')
  353. expect(resolved.pathname).toBe('/packages/client/connection/src/rpc.ts')
  354. const dependencySource = '../../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/index.js'
  355. expect(transform(dependencySource, sourceMapPath)).toBe(dependencySource)
  356. })
  357. })
  358. describe('client bundle CSS Modules watch graph', () => {
  359. it('registers the physical stylesheet read behind a virtual module', async () => {
  360. const plugin = cssModulePlugin()
  361. const importer = fileURLToPath(new URL(
  362. '../packages/client/ui-conversation/src/client/queue/QueueDock.tsx',
  363. import.meta.url,
  364. ))
  365. const stylesheet = fileURLToPath(new URL(
  366. '../packages/client/ui-conversation/src/client/queue/QueueDock.module.css',
  367. import.meta.url,
  368. ))
  369. const virtualId = plugin.resolveId?.('./QueueDock.module.css', importer)
  370. if (virtualId === null || virtualId === undefined) throw new Error('CSS Modules import was not resolved')
  371. const addWatchFile = vi.fn()
  372. await plugin.load?.call({ addWatchFile }, virtualId)
  373. expect(addWatchFile).toHaveBeenCalledExactlyOnceWith(stylesheet)
  374. })
  375. })