[READ-ONLY] Mirror of https://github.com/danielroe/cross-origin-storage. Load shared dependencies from Cross-Origin Storage (COS).
cross-origin-storage
experimental
nuxt
vite
vite-plugin
1import { execSync } from 'node:child_process'
2import { rmSync } from 'node:fs'
3import { fileURLToPath } from 'node:url'
4import { join } from 'node:path'
5import { describe, expect, it } from 'vitest'
6
7const fixtureDir = fileURLToPath(new URL('./fixtures/build-virtual', import.meta.url))
8
9describe('nuxt #app is rejected as a cos candidate', () => {
10 it('fails the build with a clear diagnostic, not a raw resolve error', () => {
11 // `#app` is stitched together from per-app build virtuals (`#build/*`,
12 // `#imports`, ...), so it is neither self-contained nor shareable across
13 // origins. The plugin must say so rather than emit a cryptic error.
14 rmSync(join(fixtureDir, '.output'), { recursive: true, force: true })
15 rmSync(join(fixtureDir, '.nuxt'), { recursive: true, force: true })
16
17 let output = ''
18 expect(() => {
19 try {
20 execSync('npx nuxi build', { cwd: fixtureDir, encoding: 'utf8', stdio: 'pipe' })
21 }
22 catch (error) {
23 output = `${(error as { stdout?: string }).stdout ?? ''}${(error as { stderr?: string }).stderr ?? ''}`
24 throw error
25 }
26 }).toThrow()
27
28 expect(output).toContain('cannot bundle managed package as a standalone chunk')
29 }, 240_000)
30})