mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-10-02 11:56:44 -05:00
Merge pull request #130 from misenhower/codex/fix-node-preview-startup
Fix backend startup without Vite environment
This commit is contained in:
@@ -6,8 +6,8 @@ import { getEmptyPreviewData, usePagePreviewStore } from './pagePreview.mjs';
|
||||
function defineEndpointStore(id, endpoint, transform = null) {
|
||||
return defineStore(`data/${id}`, () => {
|
||||
const loadedData = shallowRef(null);
|
||||
const preview = import.meta.env.DEV ? usePagePreviewStore() : null;
|
||||
const data = import.meta.env.DEV
|
||||
const preview = import.meta.env?.DEV ? usePagePreviewStore() : null;
|
||||
const data = import.meta.env?.DEV
|
||||
? computed(() => preview.mode === 'empty' ? getEmptyPreviewData(id) : loadedData.value)
|
||||
: loadedData;
|
||||
const isUpdating = ref(false);
|
||||
|
||||
20
src/stores/data.node.test.mjs
Normal file
20
src/stores/data.node.test.mjs
Normal file
@@ -0,0 +1,20 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('data stores in Node', () => {
|
||||
it('initializes shared stores without Vite', () => {
|
||||
const script = `
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import { useDataStore } from './src/stores/data.mjs';
|
||||
|
||||
setActivePinia(createPinia());
|
||||
useDataStore();
|
||||
`;
|
||||
|
||||
expect(() => execFileSync(process.execPath, [
|
||||
'--input-type=module',
|
||||
'--eval',
|
||||
script,
|
||||
], { cwd: process.cwd(), stdio: 'pipe' })).not.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const usePagePreviewStore = import.meta.env.DEV
|
||||
export const usePagePreviewStore = import.meta.env?.DEV
|
||||
? defineStore('debug/pagePreview', {
|
||||
state: () => ({ mode: 'live' }),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user