histoire 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled/SandboxVue3.js +41 -1
- package/dist/bundled/index2.js +2 -0
- package/dist/client/app/App.vue +2 -0
- package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +21 -0
- package/dist/client/app/components/sandbox/RouterLinkStub.js +43 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +4 -0
- package/dist/client/server/vue3/Story.vue +17 -2
- package/dist/client/server/vue3/Variant.vue +3 -1
- package/dist/node/collect/index.js +1 -0
- package/dist/node/config.d.ts +20 -0
- package/dist/node/stories.js +2 -2
- package/dist/node/vite.js +3 -0
- package/package.json +2 -2
- package/src/client/app/App.vue +2 -0
- package/src/client/app/components/sandbox/RouterLinkStub.ts +49 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +4 -0
- package/src/client/server/vue3/Story.vue +17 -2
- package/src/client/server/vue3/Variant.vue +3 -1
- package/src/node/collect/index.ts +1 -0
- package/src/node/config.ts +20 -0
- package/src/node/stories.ts +3 -3
- package/src/node/vite.ts +3 -0
|
@@ -14,7 +14,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
import { Text, vModelText, vModelSelect, vModelRadio, vModelCheckbox, vModelDynamic, defineComponent, ref, createApp, onMounted, watch, onUnmounted, openBlock, createElementBlock } from "vue";
|
|
17
|
+
import { Text, vModelText, vModelSelect, vModelRadio, vModelCheckbox, vModelDynamic, defineComponent, computed, h, ref, createApp, onMounted, watch, onUnmounted, openBlock, createElementBlock } from "vue";
|
|
18
18
|
import { pascal } from "case";
|
|
19
19
|
import { a as applyStateToVariant } from "./state.js";
|
|
20
20
|
import * as setup from "$histoire-setup";
|
|
@@ -509,6 +509,45 @@ function serializeAndCleanJs(value) {
|
|
|
509
509
|
function cleanupExpression(expr) {
|
|
510
510
|
return expr.replace(/\$setup\./g, "");
|
|
511
511
|
}
|
|
512
|
+
const defaultRoute = {
|
|
513
|
+
path: "/",
|
|
514
|
+
name: void 0,
|
|
515
|
+
redirectedFrom: void 0,
|
|
516
|
+
params: {},
|
|
517
|
+
query: {},
|
|
518
|
+
hash: "",
|
|
519
|
+
fullPath: "/",
|
|
520
|
+
matched: [],
|
|
521
|
+
meta: {},
|
|
522
|
+
href: "/"
|
|
523
|
+
};
|
|
524
|
+
const RouterLinkStub = defineComponent({
|
|
525
|
+
name: "RouterLinkStub",
|
|
526
|
+
compatConfig: { MODE: 3 },
|
|
527
|
+
props: {
|
|
528
|
+
to: {
|
|
529
|
+
type: [String, Object],
|
|
530
|
+
required: true
|
|
531
|
+
},
|
|
532
|
+
custom: {
|
|
533
|
+
type: Boolean,
|
|
534
|
+
default: false
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
render() {
|
|
538
|
+
var _a, _b;
|
|
539
|
+
const route = computed(() => defaultRoute);
|
|
540
|
+
const children = (_b = (_a = this.$slots) == null ? void 0 : _a.default) == null ? void 0 : _b.call(_a, {
|
|
541
|
+
route,
|
|
542
|
+
href: computed(() => route.value.href),
|
|
543
|
+
isActive: computed(() => false),
|
|
544
|
+
isExactActive: computed(() => false),
|
|
545
|
+
navigate: async () => {
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
return this.custom ? children : h("a", void 0, children);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
512
551
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
513
552
|
name: "SandboxVue3",
|
|
514
553
|
props: {
|
|
@@ -615,6 +654,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
615
654
|
return vnodes;
|
|
616
655
|
}
|
|
617
656
|
});
|
|
657
|
+
app.component("RouterLink", RouterLinkStub);
|
|
618
658
|
if (typeof (generatedSetup == null ? void 0 : generatedSetup.setupVue3) === "function") {
|
|
619
659
|
await generatedSetup.setupVue3({
|
|
620
660
|
app,
|
package/dist/bundled/index2.js
CHANGED
|
@@ -702,6 +702,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
702
702
|
const files$1 = ref(files.map((file) => mapFile(file)));
|
|
703
703
|
const tree$1 = ref(tree);
|
|
704
704
|
onUpdate((newFiles, newTree) => {
|
|
705
|
+
loading.value = false;
|
|
705
706
|
files$1.value = newFiles.map((file) => {
|
|
706
707
|
const existingFile = files$1.value.find((f) => f.id === file.id);
|
|
707
708
|
return mapFile(file, existingFile);
|
|
@@ -742,6 +743,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
742
743
|
const loading = ref(false);
|
|
743
744
|
if (import.meta.hot && !files.length) {
|
|
744
745
|
loading.value = true;
|
|
746
|
+
console.log("loading...");
|
|
745
747
|
import.meta.hot.on("histoire:all-stories-loaded", () => {
|
|
746
748
|
loading.value = false;
|
|
747
749
|
});
|
package/dist/client/app/App.vue
CHANGED
|
@@ -26,6 +26,7 @@ const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
|
|
|
26
26
|
const tree = ref<Tree>(rawTree)
|
|
27
27
|
|
|
28
28
|
onUpdate((newFiles: StoryFile[], newTree: Tree) => {
|
|
29
|
+
loading.value = false
|
|
29
30
|
files.value = newFiles.map(file => {
|
|
30
31
|
const existingFile = files.value.find(f => f.id === file.id)
|
|
31
32
|
return mapFile(file, existingFile)
|
|
@@ -78,6 +79,7 @@ const loading = ref(false)
|
|
|
78
79
|
|
|
79
80
|
if (import.meta.hot && !rawFiles.length) {
|
|
80
81
|
loading.value = true
|
|
82
|
+
console.log('loading...')
|
|
81
83
|
import.meta.hot.on('histoire:all-stories-loaded', () => {
|
|
82
84
|
loading.value = false
|
|
83
85
|
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const RouterLinkStub: import("vue").DefineComponent<{
|
|
2
|
+
to: {
|
|
3
|
+
type: (ObjectConstructor | StringConstructor)[];
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
custom: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: boolean;
|
|
9
|
+
};
|
|
10
|
+
}, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
to: {
|
|
12
|
+
type: (ObjectConstructor | StringConstructor)[];
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
custom: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
19
|
+
}>>, {
|
|
20
|
+
custom: boolean;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// From: https://github.com/vuejs/test-utils/blob/main/src/components/RouterLinkStub.ts
|
|
2
|
+
import { defineComponent, h, computed } from 'vue';
|
|
3
|
+
// match return type of router.resolve: RouteLocation & { href: string }
|
|
4
|
+
const defaultRoute = {
|
|
5
|
+
path: '/',
|
|
6
|
+
name: undefined,
|
|
7
|
+
redirectedFrom: undefined,
|
|
8
|
+
params: {},
|
|
9
|
+
query: {},
|
|
10
|
+
hash: '',
|
|
11
|
+
fullPath: '/',
|
|
12
|
+
matched: [],
|
|
13
|
+
meta: {},
|
|
14
|
+
href: '/',
|
|
15
|
+
};
|
|
16
|
+
// TODO: Borrow typings from vue-router-next
|
|
17
|
+
export const RouterLinkStub = defineComponent({
|
|
18
|
+
name: 'RouterLinkStub',
|
|
19
|
+
compatConfig: { MODE: 3 },
|
|
20
|
+
props: {
|
|
21
|
+
to: {
|
|
22
|
+
type: [String, Object],
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
custom: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
render() {
|
|
31
|
+
const route = computed(() => defaultRoute);
|
|
32
|
+
// mock reasonable return values to mimic vue-router's useLink
|
|
33
|
+
const children = this.$slots?.default?.({
|
|
34
|
+
route,
|
|
35
|
+
href: computed(() => route.value.href),
|
|
36
|
+
isActive: computed(() => false),
|
|
37
|
+
isExactActive: computed(() => false),
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
39
|
+
navigate: async () => { },
|
|
40
|
+
});
|
|
41
|
+
return this.custom ? children : h('a', undefined, children);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -3,6 +3,7 @@ import { App, createApp, onMounted, onUnmounted, PropType, ref, watch } from 'vu
|
|
|
3
3
|
import { Story, Variant, PropDefinition, AutoPropComponentDefinition } from '../../types'
|
|
4
4
|
import { getTagName } from '../../codegen/vue3'
|
|
5
5
|
import { applyStateToVariant } from '../../util/state'
|
|
6
|
+
import { RouterLinkStub } from './RouterLinkStub'
|
|
6
7
|
// @ts-expect-error virtual module id
|
|
7
8
|
import * as setup from '$histoire-setup'
|
|
8
9
|
// @ts-expect-error virtual module id
|
|
@@ -125,6 +126,9 @@ async function mountVariant () {
|
|
|
125
126
|
},
|
|
126
127
|
})
|
|
127
128
|
|
|
129
|
+
// Stubs
|
|
130
|
+
app.component('RouterLink', RouterLinkStub)
|
|
131
|
+
|
|
128
132
|
if (typeof generatedSetup?.setupVue3 === 'function') {
|
|
129
133
|
await generatedSetup.setupVue3({
|
|
130
134
|
app,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject, onMounted, PropType, provide, useAttrs } from 'vue'
|
|
3
|
-
import type { StoryFile, Story, Variant } from '
|
|
3
|
+
import type { StoryFile, Story, Variant } from '../../../node/types'
|
|
4
|
+
|
|
5
|
+
const stub = { name: 'StubbedComponent', render: () => null }
|
|
4
6
|
|
|
5
7
|
export default defineComponent({
|
|
8
|
+
name: 'HistoireStory',
|
|
9
|
+
|
|
6
10
|
inheritAttrs: false,
|
|
7
11
|
|
|
8
12
|
props: {
|
|
@@ -87,13 +91,24 @@ export default defineComponent({
|
|
|
87
91
|
render () {
|
|
88
92
|
let suppressError = false
|
|
89
93
|
try {
|
|
90
|
-
|
|
94
|
+
const vnodes = this.$slots.default?.({
|
|
91
95
|
get state () {
|
|
92
96
|
// No variant tags
|
|
93
97
|
suppressError = true
|
|
94
98
|
return {}
|
|
95
99
|
},
|
|
96
100
|
})
|
|
101
|
+
|
|
102
|
+
// Auto stub components
|
|
103
|
+
if (Array.isArray(vnodes)) {
|
|
104
|
+
for (const vnode of vnodes) {
|
|
105
|
+
if (typeof vnode.type === 'object' && (vnode.type as any).name !== 'HistoireVariant') {
|
|
106
|
+
vnode.type = stub
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return vnodes
|
|
97
112
|
} catch (e) {
|
|
98
113
|
if (!suppressError) {
|
|
99
114
|
console.error(e)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject } from 'vue'
|
|
3
|
-
import type { Story, Variant } from '
|
|
3
|
+
import type { Story, Variant } from '../../../node/types'
|
|
4
4
|
|
|
5
5
|
export default defineComponent({
|
|
6
|
+
name: 'HistoireVariant',
|
|
7
|
+
|
|
6
8
|
props: {
|
|
7
9
|
title: {
|
|
8
10
|
type: String,
|
package/dist/node/config.d.ts
CHANGED
|
@@ -134,6 +134,26 @@ export interface HistoireConfig {
|
|
|
134
134
|
* Transpile dependencies when collecting stories on Node.js
|
|
135
135
|
*/
|
|
136
136
|
viteNodeInlineDeps?: RegExp[];
|
|
137
|
+
/**
|
|
138
|
+
* Determine the transform method of modules
|
|
139
|
+
*/
|
|
140
|
+
viteNodeTransformMode?: {
|
|
141
|
+
/**
|
|
142
|
+
* Use SSR transform pipeline for the specified files.
|
|
143
|
+
* Vite plugins will receive `ssr: true` flag when processing those files.
|
|
144
|
+
*
|
|
145
|
+
* @default [/\.([cm]?[jt]sx?|json)$/]
|
|
146
|
+
*/
|
|
147
|
+
ssr?: RegExp[];
|
|
148
|
+
/**
|
|
149
|
+
* First do a normal transform pipeline (targeting browser),
|
|
150
|
+
* then then do a SSR rewrite to run the code in Node.
|
|
151
|
+
* Vite plugins will receive `ssr: false` flag when processing those files.
|
|
152
|
+
*
|
|
153
|
+
* @default other than `ssr`
|
|
154
|
+
*/
|
|
155
|
+
web?: RegExp[];
|
|
156
|
+
};
|
|
137
157
|
}
|
|
138
158
|
export declare type ConfigMode = 'build' | 'dev';
|
|
139
159
|
export declare function getDefaultConfig(): HistoireConfig;
|
package/dist/node/stories.js
CHANGED
|
@@ -49,8 +49,8 @@ export function addStory(relativeFilePath) {
|
|
|
49
49
|
return file;
|
|
50
50
|
}
|
|
51
51
|
export function removeStory(relativeFilePath) {
|
|
52
|
-
const
|
|
53
|
-
const index = context.storyFiles.findIndex((file) => file.
|
|
52
|
+
const absoluteFilePath = getAbsoluteFilePath(relativeFilePath);
|
|
53
|
+
const index = context.storyFiles.findIndex((file) => file.path === absoluteFilePath);
|
|
54
54
|
if (index !== -1)
|
|
55
55
|
context.storyFiles.splice(index, 1);
|
|
56
56
|
}
|
package/dist/node/vite.js
CHANGED
|
@@ -77,6 +77,9 @@ export async function getViteConfigWithPlugins(server, ctx) {
|
|
|
77
77
|
fs: {
|
|
78
78
|
allow: [DIST_PATH, TEMP_PATH, resolvedViteConfig.root, process.cwd()],
|
|
79
79
|
},
|
|
80
|
+
watch: {
|
|
81
|
+
ignored: [`!**/node_modules/.histoire/**`],
|
|
82
|
+
},
|
|
80
83
|
},
|
|
81
84
|
define: {
|
|
82
85
|
// We need to force this to be able to use `devtoolsRawSetupState`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"histoire": "./bin.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@histoire/controls": "^0.7.
|
|
36
|
+
"@histoire/controls": "^0.7.1",
|
|
37
37
|
"@iconify/vue": "^3.2.1",
|
|
38
38
|
"@types/markdown-it": "^12.2.3",
|
|
39
39
|
"@vueuse/core": "^8.2.5",
|
package/src/client/app/App.vue
CHANGED
|
@@ -26,6 +26,7 @@ const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
|
|
|
26
26
|
const tree = ref<Tree>(rawTree)
|
|
27
27
|
|
|
28
28
|
onUpdate((newFiles: StoryFile[], newTree: Tree) => {
|
|
29
|
+
loading.value = false
|
|
29
30
|
files.value = newFiles.map(file => {
|
|
30
31
|
const existingFile = files.value.find(f => f.id === file.id)
|
|
31
32
|
return mapFile(file, existingFile)
|
|
@@ -78,6 +79,7 @@ const loading = ref(false)
|
|
|
78
79
|
|
|
79
80
|
if (import.meta.hot && !rawFiles.length) {
|
|
80
81
|
loading.value = true
|
|
82
|
+
console.log('loading...')
|
|
81
83
|
import.meta.hot.on('histoire:all-stories-loaded', () => {
|
|
82
84
|
loading.value = false
|
|
83
85
|
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// From: https://github.com/vuejs/test-utils/blob/main/src/components/RouterLinkStub.ts
|
|
2
|
+
|
|
3
|
+
import { defineComponent, h, computed } from 'vue'
|
|
4
|
+
|
|
5
|
+
// match return type of router.resolve: RouteLocation & { href: string }
|
|
6
|
+
const defaultRoute = {
|
|
7
|
+
path: '/',
|
|
8
|
+
name: undefined as string | undefined,
|
|
9
|
+
redirectedFrom: undefined as object | undefined,
|
|
10
|
+
params: {},
|
|
11
|
+
query: {},
|
|
12
|
+
hash: '',
|
|
13
|
+
fullPath: '/',
|
|
14
|
+
matched: [] as object[],
|
|
15
|
+
meta: {},
|
|
16
|
+
href: '/',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// TODO: Borrow typings from vue-router-next
|
|
20
|
+
export const RouterLinkStub = defineComponent({
|
|
21
|
+
name: 'RouterLinkStub',
|
|
22
|
+
|
|
23
|
+
compatConfig: { MODE: 3 },
|
|
24
|
+
|
|
25
|
+
props: {
|
|
26
|
+
to: {
|
|
27
|
+
type: [String, Object],
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
custom: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
render () {
|
|
37
|
+
const route = computed(() => defaultRoute)
|
|
38
|
+
// mock reasonable return values to mimic vue-router's useLink
|
|
39
|
+
const children = this.$slots?.default?.({
|
|
40
|
+
route,
|
|
41
|
+
href: computed(() => route.value.href),
|
|
42
|
+
isActive: computed(() => false),
|
|
43
|
+
isExactActive: computed(() => false),
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
45
|
+
navigate: async () => {},
|
|
46
|
+
})
|
|
47
|
+
return this.custom ? children : h('a', undefined, children)
|
|
48
|
+
},
|
|
49
|
+
})
|
|
@@ -3,6 +3,7 @@ import { App, createApp, onMounted, onUnmounted, PropType, ref, watch } from 'vu
|
|
|
3
3
|
import { Story, Variant, PropDefinition, AutoPropComponentDefinition } from '../../types'
|
|
4
4
|
import { getTagName } from '../../codegen/vue3'
|
|
5
5
|
import { applyStateToVariant } from '../../util/state'
|
|
6
|
+
import { RouterLinkStub } from './RouterLinkStub'
|
|
6
7
|
// @ts-expect-error virtual module id
|
|
7
8
|
import * as setup from '$histoire-setup'
|
|
8
9
|
// @ts-expect-error virtual module id
|
|
@@ -125,6 +126,9 @@ async function mountVariant () {
|
|
|
125
126
|
},
|
|
126
127
|
})
|
|
127
128
|
|
|
129
|
+
// Stubs
|
|
130
|
+
app.component('RouterLink', RouterLinkStub)
|
|
131
|
+
|
|
128
132
|
if (typeof generatedSetup?.setupVue3 === 'function') {
|
|
129
133
|
await generatedSetup.setupVue3({
|
|
130
134
|
app,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject, onMounted, PropType, provide, useAttrs } from 'vue'
|
|
3
|
-
import type { StoryFile, Story, Variant } from '
|
|
3
|
+
import type { StoryFile, Story, Variant } from '../../../node/types'
|
|
4
|
+
|
|
5
|
+
const stub = { name: 'StubbedComponent', render: () => null }
|
|
4
6
|
|
|
5
7
|
export default defineComponent({
|
|
8
|
+
name: 'HistoireStory',
|
|
9
|
+
|
|
6
10
|
inheritAttrs: false,
|
|
7
11
|
|
|
8
12
|
props: {
|
|
@@ -87,13 +91,24 @@ export default defineComponent({
|
|
|
87
91
|
render () {
|
|
88
92
|
let suppressError = false
|
|
89
93
|
try {
|
|
90
|
-
|
|
94
|
+
const vnodes = this.$slots.default?.({
|
|
91
95
|
get state () {
|
|
92
96
|
// No variant tags
|
|
93
97
|
suppressError = true
|
|
94
98
|
return {}
|
|
95
99
|
},
|
|
96
100
|
})
|
|
101
|
+
|
|
102
|
+
// Auto stub components
|
|
103
|
+
if (Array.isArray(vnodes)) {
|
|
104
|
+
for (const vnode of vnodes) {
|
|
105
|
+
if (typeof vnode.type === 'object' && (vnode.type as any).name !== 'HistoireVariant') {
|
|
106
|
+
vnode.type = stub
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return vnodes
|
|
97
112
|
} catch (e) {
|
|
98
113
|
if (!suppressError) {
|
|
99
114
|
console.error(e)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { defineComponent, inject } from 'vue'
|
|
3
|
-
import type { Story, Variant } from '
|
|
3
|
+
import type { Story, Variant } from '../../../node/types'
|
|
4
4
|
|
|
5
5
|
export default defineComponent({
|
|
6
|
+
name: 'HistoireVariant',
|
|
7
|
+
|
|
6
8
|
props: {
|
|
7
9
|
title: {
|
|
8
10
|
type: String,
|
package/src/node/config.ts
CHANGED
|
@@ -153,6 +153,26 @@ export interface HistoireConfig {
|
|
|
153
153
|
* Transpile dependencies when collecting stories on Node.js
|
|
154
154
|
*/
|
|
155
155
|
viteNodeInlineDeps?: RegExp[]
|
|
156
|
+
/**
|
|
157
|
+
* Determine the transform method of modules
|
|
158
|
+
*/
|
|
159
|
+
viteNodeTransformMode?: {
|
|
160
|
+
/**
|
|
161
|
+
* Use SSR transform pipeline for the specified files.
|
|
162
|
+
* Vite plugins will receive `ssr: true` flag when processing those files.
|
|
163
|
+
*
|
|
164
|
+
* @default [/\.([cm]?[jt]sx?|json)$/]
|
|
165
|
+
*/
|
|
166
|
+
ssr?: RegExp[]
|
|
167
|
+
/**
|
|
168
|
+
* First do a normal transform pipeline (targeting browser),
|
|
169
|
+
* then then do a SSR rewrite to run the code in Node.
|
|
170
|
+
* Vite plugins will receive `ssr: false` flag when processing those files.
|
|
171
|
+
*
|
|
172
|
+
* @default other than `ssr`
|
|
173
|
+
*/
|
|
174
|
+
web?: RegExp[]
|
|
175
|
+
}
|
|
156
176
|
}
|
|
157
177
|
|
|
158
178
|
export type ConfigMode = 'build' | 'dev'
|
package/src/node/stories.ts
CHANGED
|
@@ -53,7 +53,7 @@ export function addStory (relativeFilePath: string) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const file: StoryFile = {
|
|
56
|
-
id: fileId,
|
|
56
|
+
id: fileId, // The file id will be changed by the story id after it is collected
|
|
57
57
|
path: absoluteFilePath,
|
|
58
58
|
fileName,
|
|
59
59
|
moduleId: `/${relativeFilePath}`,
|
|
@@ -63,8 +63,8 @@ export function addStory (relativeFilePath: string) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export function removeStory (relativeFilePath: string) {
|
|
66
|
-
const
|
|
67
|
-
const index = context.storyFiles.findIndex((file) => file.
|
|
66
|
+
const absoluteFilePath = getAbsoluteFilePath(relativeFilePath)
|
|
67
|
+
const index = context.storyFiles.findIndex((file) => file.path === absoluteFilePath)
|
|
68
68
|
if (index !== -1) context.storyFiles.splice(index, 1)
|
|
69
69
|
}
|
|
70
70
|
|
package/src/node/vite.ts
CHANGED
|
@@ -93,6 +93,9 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
|
|
|
93
93
|
fs: {
|
|
94
94
|
allow: [DIST_PATH, TEMP_PATH, resolvedViteConfig.root, process.cwd()],
|
|
95
95
|
},
|
|
96
|
+
watch: {
|
|
97
|
+
ignored: [`!**/node_modules/.histoire/**`],
|
|
98
|
+
},
|
|
96
99
|
},
|
|
97
100
|
define: {
|
|
98
101
|
// We need to force this to be able to use `devtoolsRawSetupState`
|