histoire 0.11.6 → 0.11.7
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/node/build.js +4 -2
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +0 -1
- package/dist/node/commands/dev.js +3 -3
- package/dist/node/config.js +1 -0
- package/dist/node/server.d.ts +1 -0
- package/dist/node/server.js +8 -3
- package/dist/node/vite.d.ts +5 -1
- package/dist/node/vite.js +6 -4
- package/package.json +5 -6
- package/src/node/build.ts +4 -2
- package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +0 -1
- package/src/node/commands/dev.ts +3 -3
- package/src/node/config.ts +1 -0
- package/src/node/server.ts +9 -4
- package/src/node/vite.ts +13 -6
package/dist/node/build.js
CHANGED
|
@@ -28,7 +28,8 @@ export async function build(ctx) {
|
|
|
28
28
|
const { stop } = await createMarkdownFilesWatcher(ctx);
|
|
29
29
|
await stop();
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const { viteConfig } = await getViteConfigWithPlugins(true, ctx);
|
|
32
|
+
const server = await createViteServer(viteConfig);
|
|
32
33
|
await server.pluginContainer.buildStart({});
|
|
33
34
|
const moduleLoader = useModuleLoader({
|
|
34
35
|
server,
|
|
@@ -54,7 +55,8 @@ export async function build(ctx) {
|
|
|
54
55
|
const storyCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ? 1 : 0), 0);
|
|
55
56
|
const variantCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ?? 0), 0);
|
|
56
57
|
const emptyStoryCount = ctx.storyFiles.length - storyCount;
|
|
57
|
-
const
|
|
58
|
+
const { viteConfig: buildViteConfigRaw } = await getViteConfigWithPlugins(false, ctx);
|
|
59
|
+
const buildViteConfig = mergeViteConfig(buildViteConfigRaw, {
|
|
58
60
|
mode: 'development',
|
|
59
61
|
build: {
|
|
60
62
|
lib: false,
|
|
@@ -9,12 +9,12 @@ export async function devCommand(options) {
|
|
|
9
9
|
const ctx = await createContext({
|
|
10
10
|
mode: 'dev',
|
|
11
11
|
});
|
|
12
|
-
const { server, close } = await createServer(ctx, { port: options.port });
|
|
12
|
+
const { server, viteConfigFile, close } = await createServer(ctx, { port: options.port });
|
|
13
13
|
server.printUrls();
|
|
14
14
|
// Histoire config watcher
|
|
15
15
|
let watcher;
|
|
16
|
-
if (
|
|
17
|
-
watcher = chokidar.watch(
|
|
16
|
+
if (viteConfigFile) {
|
|
17
|
+
watcher = chokidar.watch(viteConfigFile, {
|
|
18
18
|
ignoreInitial: true,
|
|
19
19
|
});
|
|
20
20
|
watcher.on('change', () => {
|
package/dist/node/config.js
CHANGED
|
@@ -139,6 +139,7 @@ export async function loadConfigFile(configFile) {
|
|
|
139
139
|
try {
|
|
140
140
|
const result = jiti(__filename, {
|
|
141
141
|
esmResolve: true,
|
|
142
|
+
requireCache: false,
|
|
142
143
|
})(configFile);
|
|
143
144
|
if (!result.default) {
|
|
144
145
|
throw new Error(`Expected default export in ${configFile}`);
|
package/dist/node/server.d.ts
CHANGED
package/dist/node/server.js
CHANGED
|
@@ -10,11 +10,15 @@ import { wrapLogError } from './util/log.js';
|
|
|
10
10
|
import { createMarkdownFilesWatcher, onMarkdownListChange } from './markdown.js';
|
|
11
11
|
export async function createServer(ctx, options = {}) {
|
|
12
12
|
const getViteServer = async (collecting) => {
|
|
13
|
-
const
|
|
13
|
+
const { viteConfig, viteConfigFile } = await getViteConfigWithPlugins(collecting, ctx);
|
|
14
|
+
const server = await createViteServer(viteConfig);
|
|
14
15
|
await server.pluginContainer.buildStart({});
|
|
15
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
server,
|
|
18
|
+
viteConfigFile,
|
|
19
|
+
};
|
|
16
20
|
};
|
|
17
|
-
const [server, nodeServer, , { stop: stopMdFileWatcher },] = await Promise.all([
|
|
21
|
+
const [{ server, viteConfigFile }, { server: nodeServer }, , { stop: stopMdFileWatcher },] = await Promise.all([
|
|
18
22
|
getViteServer(false),
|
|
19
23
|
getViteServer(true),
|
|
20
24
|
watchStories(ctx),
|
|
@@ -157,6 +161,7 @@ export async function createServer(ctx, options = {}) {
|
|
|
157
161
|
collect();
|
|
158
162
|
return {
|
|
159
163
|
server,
|
|
164
|
+
viteConfigFile,
|
|
160
165
|
close,
|
|
161
166
|
};
|
|
162
167
|
}
|
package/dist/node/vite.d.ts
CHANGED
|
@@ -23,4 +23,8 @@ export declare const RESOLVED_SUPPORT_PLUGINS_COLLECT: string;
|
|
|
23
23
|
export declare const MARKDOWN_FILES = "virtual:$histoire-markdown-files";
|
|
24
24
|
export declare const RESOLVED_MARKDOWN_FILES: string;
|
|
25
25
|
export declare function mergeHistoireViteConfig(viteConfig: InlineConfig, ctx: Context): Promise<InlineConfig>;
|
|
26
|
-
export
|
|
26
|
+
export interface ViteConfigWithPlugins {
|
|
27
|
+
viteConfig: InlineConfig;
|
|
28
|
+
viteConfigFile: string | null;
|
|
29
|
+
}
|
|
30
|
+
export declare function getViteConfigWithPlugins(isServer: boolean, ctx: Context): Promise<ViteConfigWithPlugins>;
|
package/dist/node/vite.js
CHANGED
|
@@ -3,7 +3,6 @@ import { relative, resolve, join, dirname } from 'pathe';
|
|
|
3
3
|
import { mergeConfig as mergeViteConfig, loadConfigFromFile as loadViteConfigFromFile, } from 'vite';
|
|
4
4
|
import { lookup as lookupMime } from 'mrmime';
|
|
5
5
|
import fs from 'fs-extra';
|
|
6
|
-
import ViteInspect from 'vite-plugin-inspect';
|
|
7
6
|
import { APP_PATH, TEMP_PATH } from './alias.js';
|
|
8
7
|
import { notifyStoryChange } from './stories.js';
|
|
9
8
|
import { makeTree } from './tree.js';
|
|
@@ -99,7 +98,6 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
99
98
|
}
|
|
100
99
|
return result;
|
|
101
100
|
}
|
|
102
|
-
plugins.push(ViteInspect());
|
|
103
101
|
plugins.push({
|
|
104
102
|
name: 'histoire-vite-plugin',
|
|
105
103
|
config() {
|
|
@@ -172,7 +170,7 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
172
170
|
else if (isServer && 'server' in setupFileConfig) {
|
|
173
171
|
file = setupFileConfig.server;
|
|
174
172
|
}
|
|
175
|
-
else if ('browser' in setupFileConfig) {
|
|
173
|
+
else if (!isServer && 'browser' in setupFileConfig) {
|
|
176
174
|
file = setupFileConfig.browser;
|
|
177
175
|
}
|
|
178
176
|
if (file) {
|
|
@@ -532,8 +530,12 @@ if (import.meta.hot) {
|
|
|
532
530
|
},
|
|
533
531
|
});
|
|
534
532
|
}
|
|
535
|
-
|
|
533
|
+
const viteConfig = mergeViteConfig(inlineConfig, {
|
|
536
534
|
configFile: false,
|
|
537
535
|
plugins,
|
|
538
536
|
});
|
|
537
|
+
return {
|
|
538
|
+
viteConfig,
|
|
539
|
+
viteConfigFile: userViteConfigFile?.path ?? null,
|
|
540
|
+
};
|
|
539
541
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"histoire": "./bin.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@histoire/app": "^0.11.
|
|
37
|
-
"@histoire/controls": "^0.11.
|
|
38
|
-
"@histoire/shared": "^0.11.
|
|
39
|
-
"@histoire/vendors": "^0.11.
|
|
36
|
+
"@histoire/app": "^0.11.7",
|
|
37
|
+
"@histoire/controls": "^0.11.7",
|
|
38
|
+
"@histoire/shared": "^0.11.7",
|
|
39
|
+
"@histoire/vendors": "^0.11.7",
|
|
40
40
|
"@types/flexsearch": "^0.7.3",
|
|
41
41
|
"@types/markdown-it": "^12.2.3",
|
|
42
42
|
"birpc": "^0.1.1",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"shiki": "0.10.1",
|
|
64
64
|
"sirv": "^2.0.2",
|
|
65
65
|
"tinypool": "^0.1.2",
|
|
66
|
-
"vite-plugin-inspect": "^0.7.5",
|
|
67
66
|
"vite-node": "0.23.4"
|
|
68
67
|
},
|
|
69
68
|
"peerDependencies": {
|
package/src/node/build.ts
CHANGED
|
@@ -45,7 +45,8 @@ export async function build (ctx: Context) {
|
|
|
45
45
|
await stop()
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const
|
|
48
|
+
const { viteConfig } = await getViteConfigWithPlugins(true, ctx)
|
|
49
|
+
const server = await createViteServer(viteConfig)
|
|
49
50
|
await server.pluginContainer.buildStart({})
|
|
50
51
|
|
|
51
52
|
const moduleLoader = useModuleLoader({
|
|
@@ -75,7 +76,8 @@ export async function build (ctx: Context) {
|
|
|
75
76
|
const variantCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ?? 0), 0)
|
|
76
77
|
const emptyStoryCount = ctx.storyFiles.length - storyCount
|
|
77
78
|
|
|
78
|
-
const
|
|
79
|
+
const { viteConfig: buildViteConfigRaw } = await getViteConfigWithPlugins(false, ctx)
|
|
80
|
+
const buildViteConfig: ViteInlineConfig = mergeViteConfig(buildViteConfigRaw, {
|
|
79
81
|
mode: 'development',
|
|
80
82
|
build: {
|
|
81
83
|
lib: false,
|
package/src/node/commands/dev.ts
CHANGED
|
@@ -15,13 +15,13 @@ export async function devCommand (options: DevOptions) {
|
|
|
15
15
|
const ctx = await createContext({
|
|
16
16
|
mode: 'dev',
|
|
17
17
|
})
|
|
18
|
-
const { server, close } = await createServer(ctx, { port: options.port })
|
|
18
|
+
const { server, viteConfigFile, close } = await createServer(ctx, { port: options.port })
|
|
19
19
|
server.printUrls()
|
|
20
20
|
|
|
21
21
|
// Histoire config watcher
|
|
22
22
|
let watcher: chokidar.FSWatcher
|
|
23
|
-
if (
|
|
24
|
-
watcher = chokidar.watch(
|
|
23
|
+
if (viteConfigFile) {
|
|
24
|
+
watcher = chokidar.watch(viteConfigFile, {
|
|
25
25
|
ignoreInitial: true,
|
|
26
26
|
})
|
|
27
27
|
watcher.on('change', () => {
|
package/src/node/config.ts
CHANGED
|
@@ -154,6 +154,7 @@ export async function loadConfigFile (configFile: string): Promise<Partial<Histo
|
|
|
154
154
|
try {
|
|
155
155
|
const result = jiti(__filename, {
|
|
156
156
|
esmResolve: true,
|
|
157
|
+
requireCache: false,
|
|
157
158
|
})(configFile)
|
|
158
159
|
if (!result.default) {
|
|
159
160
|
throw new Error(`Expected default export in ${configFile}`)
|
package/src/node/server.ts
CHANGED
|
@@ -17,14 +17,18 @@ export interface CreateServerOptions {
|
|
|
17
17
|
|
|
18
18
|
export async function createServer (ctx: Context, options: CreateServerOptions = {}) {
|
|
19
19
|
const getViteServer = async (collecting: boolean) => {
|
|
20
|
-
const
|
|
20
|
+
const { viteConfig, viteConfigFile } = await getViteConfigWithPlugins(collecting, ctx)
|
|
21
|
+
const server = await createViteServer(viteConfig)
|
|
21
22
|
await server.pluginContainer.buildStart({})
|
|
22
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
server,
|
|
25
|
+
viteConfigFile,
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
const [
|
|
26
|
-
server,
|
|
27
|
-
nodeServer,
|
|
30
|
+
{ server, viteConfigFile },
|
|
31
|
+
{ server: nodeServer },
|
|
28
32
|
,
|
|
29
33
|
{ stop: stopMdFileWatcher },
|
|
30
34
|
] = await Promise.all([
|
|
@@ -199,6 +203,7 @@ export async function createServer (ctx: Context, options: CreateServerOptions =
|
|
|
199
203
|
|
|
200
204
|
return {
|
|
201
205
|
server,
|
|
206
|
+
viteConfigFile,
|
|
202
207
|
close,
|
|
203
208
|
}
|
|
204
209
|
}
|
package/src/node/vite.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from 'vite'
|
|
10
10
|
import { lookup as lookupMime } from 'mrmime'
|
|
11
11
|
import fs from 'fs-extra'
|
|
12
|
-
import ViteInspect from 'vite-plugin-inspect'
|
|
13
12
|
import { APP_PATH, TEMP_PATH } from './alias.js'
|
|
14
13
|
import { Context } from './context.js'
|
|
15
14
|
import { notifyStoryChange } from './stories.js'
|
|
@@ -97,7 +96,12 @@ export async function mergeHistoireViteConfig (viteConfig: InlineConfig, ctx: Co
|
|
|
97
96
|
return viteConfig
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
export
|
|
99
|
+
export interface ViteConfigWithPlugins {
|
|
100
|
+
viteConfig: InlineConfig
|
|
101
|
+
viteConfigFile: string | null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context): Promise<ViteConfigWithPlugins> {
|
|
101
105
|
const userViteConfigFile = await loadViteConfigFromFile({ command: ctx.mode === 'dev' ? 'serve' : 'build', mode: ctx.mode })
|
|
102
106
|
const userViteConfig = mergeViteConfig(userViteConfigFile?.config ?? {}, { server: { port: 6006 } })
|
|
103
107
|
|
|
@@ -117,8 +121,6 @@ export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context)
|
|
|
117
121
|
return result
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
plugins.push(ViteInspect())
|
|
121
|
-
|
|
122
124
|
plugins.push({
|
|
123
125
|
name: 'histoire-vite-plugin',
|
|
124
126
|
|
|
@@ -191,7 +193,7 @@ export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context)
|
|
|
191
193
|
file = setupFileConfig
|
|
192
194
|
} else if (isServer && 'server' in setupFileConfig) {
|
|
193
195
|
file = setupFileConfig.server
|
|
194
|
-
} else if ('browser' in setupFileConfig) {
|
|
196
|
+
} else if (!isServer && 'browser' in setupFileConfig) {
|
|
195
197
|
file = setupFileConfig.browser
|
|
196
198
|
}
|
|
197
199
|
if (file) {
|
|
@@ -574,8 +576,13 @@ if (import.meta.hot) {
|
|
|
574
576
|
})
|
|
575
577
|
}
|
|
576
578
|
|
|
577
|
-
|
|
579
|
+
const viteConfig = mergeViteConfig(inlineConfig, {
|
|
578
580
|
configFile: false,
|
|
579
581
|
plugins,
|
|
580
582
|
}) as InlineConfig
|
|
583
|
+
|
|
584
|
+
return {
|
|
585
|
+
viteConfig,
|
|
586
|
+
viteConfigFile: userViteConfigFile?.path ?? null,
|
|
587
|
+
}
|
|
581
588
|
}
|