mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-25 06:04:54 +00:00
> spark-template@0.0.0 prebuild
> mkdir -p /tmp/dist || true
> spark-template@0.0.0 build
> tsc -b --noCheck && vite build
vite v7.3.1 building client environment for production...
<script src="/runtime-config.js"> in "/index.html" can't be bundled without type="module" attribute
✓ 37 modules transformed.
✗ Build failed in 1.07s
error during build:
[vite]: Rollup failed to resolve import "@github/spark/hooks" from "/workspaces/low-code-react-app-b/src/hooks/use-project-state.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
at viteLog (file:///workspaces/low-code-react-app-b/node_modules/vite/dist/node/chunks/config.js:33635:57)
at file:///workspaces/low-code-react-app-b/node_modules/vite/dist/node/chunks/config.js:33669:73
at onwarn (file:///workspaces/low-code-react-app-b/node_modules/@vitejs/plugin-react-swc/index.js:76:7)
at file:///workspaces/low-code-react-app-b/node_modules/vite/dist/node/chunks/config.js:33669:28
at onRollupLog (file:///workspaces/low-code-react-app-b/node_modules/vite/dist/node/chunks/config.js:33664:63)
at onLog (file:///workspaces/low-code-react-app-b/node_modules/vite/dist/node/chunks/config.js:33467:4)
at file:///workspaces/low-code-react-app-b/node_modules/rollup/dist/es/shared/node-entry.js:20961:32
at Object.logger [as onLog] (file:///workspaces/low-code-react-app-b/node_modules/rollup/dist/es/shared/node-entry.js:22848:9)
at ModuleLoader.handleInvalidResolvedId (file:///workspaces/low-code-react-app-b/node_modules/rollup/dist/es/shared/node-entry.js:21592:26)
at file:///workspaces/low-code-react-app-b/node_modules/rollup/dist/es/shared/node-entry.js:21550:26
@johndoe6345789 ➜ /workspaces/low-code-react-app-b (main) $
31 lines
764 B
TypeScript
31 lines
764 B
TypeScript
import { useKV } from '@/hooks/use-kv'
|
|
|
|
export type DataSourceType = 'kv' | 'static' | 'computed'
|
|
|
|
export interface DataSourceConfig<T = any> {
|
|
type: DataSourceType
|
|
key?: string
|
|
defaultValue?: T
|
|
compute?: (allData: Record<string, any>) => T
|
|
dependencies?: string[]
|
|
}
|
|
|
|
export function useKVDataSource<T = any>(key: string, defaultValue?: T) {
|
|
return useKV(key, defaultValue)
|
|
}
|
|
|
|
export function useStaticDataSource<T = any>(defaultValue: T) {
|
|
return [defaultValue, () => {}, () => {}] as const
|
|
}
|
|
|
|
export function useComputedDataSource<T = any>(
|
|
compute: (allData: Record<string, any>) => T,
|
|
dependencies: Record<string, any>
|
|
) {
|
|
return compute(dependencies)
|
|
}
|
|
|
|
export function useMultipleDataSources(_sources: DataSourceConfig[]) {
|
|
return {}
|
|
}
|