All checks were successful
deploy-analiticaNucleo / deploy (push) Successful in 36s
- Replace external module references with empty stub file - Add .nuxt-stubs/empty.mjs to provide browser-compatible module - Update workaround to resolve server-only modules to stub file instead of marking as external
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
// Workaround for @nuxt/ui v4 import protection issue
|
|
// This is a temporary fix until @nuxt/ui properly handles ssr: false
|
|
|
|
import type { Plugin } from 'vite'
|
|
import { fileURLToPath } from 'url'
|
|
import { dirname, resolve } from 'path'
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = dirname(__filename)
|
|
const emptyModulePath = resolve(__dirname, '.nuxt-stubs/empty.mjs')
|
|
|
|
export function disableImportProtection(): Plugin {
|
|
return {
|
|
name: 'disable-import-protection-for-nuxt-ui',
|
|
enforce: 'pre',
|
|
resolveId(id, importer) {
|
|
// Server-only packages that should be stubbed for client bundle
|
|
const serverPackages = [
|
|
'@nuxt/kit',
|
|
'@tailwindcss/node',
|
|
'@tailwindcss/oxide',
|
|
'jiti'
|
|
]
|
|
|
|
for (const pkg of serverPackages) {
|
|
if (id === pkg || id.startsWith(pkg + '/')) {
|
|
return emptyModulePath
|
|
}
|
|
}
|
|
|
|
// Stub .node binary files
|
|
if (id.endsWith('.node')) {
|
|
return emptyModulePath
|
|
}
|
|
|
|
// Stub Node.js built-in modules for client bundle
|
|
const nodeModules = ['fs', 'path', 'url', 'fs/promises']
|
|
const nodePrefix = ['node:url', 'node:module', 'node:fs', 'node:path']
|
|
|
|
if (nodeModules.includes(id) || nodePrefix.includes(id) || id.startsWith('node:')) {
|
|
return emptyModulePath
|
|
}
|
|
}
|
|
}
|
|
}
|