poveste 0.5.3 → 0.6.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/node/bin.js +1 -1
- package/dist/node/build.d.ts.map +1 -1
- package/dist/node/build.js +31 -0
- package/dist/node/builtin-plugins/pinceau-tokens.js +2 -2
- package/dist/node/commands/port.d.ts +8 -0
- package/dist/node/commands/port.d.ts.map +1 -1
- package/dist/node/commands/port.js +11 -0
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/config.js +9 -2
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +3 -0
- package/dist/node/markdown.d.ts.map +1 -1
- package/dist/node/markdown.js +2 -10
- package/dist/node/server.d.ts.map +1 -1
- package/dist/node/server.js +16 -1
- package/dist/node/stories.d.ts.map +1 -1
- package/dist/node/stories.js +2 -10
- package/dist/node/util/watch-ignore.d.ts +3 -0
- package/dist/node/util/watch-ignore.d.ts.map +1 -0
- package/dist/node/util/watch-ignore.js +12 -0
- package/dist/node/virtual/resolved-generated-global-setup.d.ts.map +1 -1
- package/dist/node/virtual/resolved-generated-global-setup.js +13 -5
- package/dist/node/virtual/util.d.ts +11 -0
- package/dist/node/virtual/util.d.ts.map +1 -1
- package/dist/node/virtual/util.js +13 -0
- package/dist/node/vite.d.ts.map +1 -1
- package/dist/node/vite.js +12 -2
- package/package.json +5 -5
- package/src/node/__tests__/config.spec.ts +25 -0
- package/src/node/__tests__/port.spec.ts +33 -1
- package/src/node/__tests__/virtual-setup.spec.ts +13 -3
- package/src/node/__tests__/watch-ignore.spec.ts +33 -0
- package/src/node/bin.ts +1 -1
- package/src/node/build.ts +34 -0
- package/src/node/builtin-plugins/pinceau-tokens.ts +2 -2
- package/src/node/commands/port.ts +12 -0
- package/src/node/config.ts +10 -2
- package/src/node/index.ts +3 -0
- package/src/node/markdown.ts +2 -11
- package/src/node/server.ts +17 -1
- package/src/node/stories.ts +2 -11
- package/src/node/util/watch-ignore.ts +13 -0
- package/src/node/virtual/resolved-generated-global-setup.ts +13 -5
- package/src/node/virtual/util.ts +14 -0
- package/src/node/vite.ts +12 -1
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts +0 -11
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts.map +0 -1
- package/dist/node/builtin-plugins/tailwind-tokens.js +0 -660
- package/src/node/builtin-plugins/tailwind-tokens.ts +0 -694
package/dist/node/bin.js
CHANGED
|
@@ -4,7 +4,7 @@ import { dirname, resolve } from 'pathe';
|
|
|
4
4
|
import sade from 'sade';
|
|
5
5
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
const { version } = JSON.parse(fs.readFileSync(resolve(__dirname, '../../package.json'), 'utf8'));
|
|
7
|
-
process.env.NODE_ENV = 'development';
|
|
7
|
+
process.env.NODE_ENV = process.argv.includes('build') || process.argv.includes('preview') ? 'production' : 'development';
|
|
8
8
|
process.env.HISTOIRE = 'true';
|
|
9
9
|
process.env.POVESTE = 'true';
|
|
10
10
|
const program = sade('poveste');
|
package/dist/node/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAuD3C,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,iBA6OvC"}
|
package/dist/node/build.js
CHANGED
|
@@ -18,6 +18,23 @@ import { getViteConfigWithPlugins } from './vite.js';
|
|
|
18
18
|
const PRELOAD_MODULES = [
|
|
19
19
|
'vendor',
|
|
20
20
|
];
|
|
21
|
+
// Kept out of the shared `vendor` chunk because only the app UI imports them,
|
|
22
|
+
// while `vendor` is imported by the sandbox too.
|
|
23
|
+
//
|
|
24
|
+
// Shiki is the source panel's syntax highlighter: 386 grammars and 60 themes,
|
|
25
|
+
// and it was the bulk of an 11.5 MB `vendor`. The sandbox entry pulls seven Vue
|
|
26
|
+
// exports from that chunk and nothing else, but a grid renders one sandbox
|
|
27
|
+
// iframe per cell and each iframe is its own realm — so every cell parsed and
|
|
28
|
+
// executed all 11.5 MB again, with the HTTP cache saving only the download.
|
|
29
|
+
// That was 34% of a scroll profile spent in top-level vendor evaluation (#103).
|
|
30
|
+
//
|
|
31
|
+
// They go to a chunk of their own rather than being left to Rollup: leaving
|
|
32
|
+
// placement automatic emitted one chunk per grammar — 402 assets — and tripled
|
|
33
|
+
// the blocking time it was meant to cut.
|
|
34
|
+
const APP_ONLY_VENDORS = [
|
|
35
|
+
/[\\/]node_modules[\\/]shiki[\\/]/,
|
|
36
|
+
/[\\/]node_modules[\\/]@shikijs[\\/]/,
|
|
37
|
+
];
|
|
21
38
|
const PREFETCHED_MODULES = [
|
|
22
39
|
'StoryView',
|
|
23
40
|
'reactivity',
|
|
@@ -122,7 +139,21 @@ export async function build(ctx) {
|
|
|
122
139
|
// Force chunk strategy
|
|
123
140
|
config.build.rollupOptions.output = {
|
|
124
141
|
manualChunks(id) {
|
|
142
|
+
// Vite's runtime helpers (`\0vite/preload-helper.js` and friends) are
|
|
143
|
+
// virtual modules, so the node_modules routing below never sees them
|
|
144
|
+
// and their placement is left to the bundler — which parked
|
|
145
|
+
// `__vitePreload` inside the 10 MB `highlighter` chunk. Every chunk
|
|
146
|
+
// importing the helper then statically imported the whole highlighter,
|
|
147
|
+
// and the sandbox was back to evaluating it once per grid cell (#197),
|
|
148
|
+
// undoing exactly what `APP_ONLY_VENDORS` is for. Pin them somewhere
|
|
149
|
+
// harmless instead of leaving the choice to chunking heuristics.
|
|
150
|
+
if (id.replace(/^\0/, '').startsWith('vite/')) {
|
|
151
|
+
return 'app-runtime';
|
|
152
|
+
}
|
|
125
153
|
if (!id.includes('@poveste/app') && id.includes('node_modules')) {
|
|
154
|
+
if (APP_ONLY_VENDORS.some(test => test.test(id))) {
|
|
155
|
+
return 'highlighter';
|
|
156
|
+
}
|
|
126
157
|
for (const test of ctx.config.build?.excludeFromVendorsChunk ?? []) {
|
|
127
158
|
if ((typeof test === 'string' && id.includes(test)) || (test instanceof RegExp && test.test(id))) {
|
|
128
159
|
// Excluded from vendor chunk
|
|
@@ -57,8 +57,8 @@ export function pinceauTokens(_options = {}) {
|
|
|
57
57
|
}
|
|
58
58
|
function storyTemplate(pinceauConfig) {
|
|
59
59
|
pinceauConfig = pinceauConfig?.theme || pinceauConfig?.default?.theme || {};
|
|
60
|
-
|
|
61
|
-
import './style.css'
|
|
60
|
+
// No `import 'poveste-style'` — see the tailwind plugin's template (#219).
|
|
61
|
+
return `import './style.css'
|
|
62
62
|
import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
|
|
63
63
|
import {
|
|
64
64
|
HstColorShades,
|
|
@@ -7,4 +7,12 @@
|
|
|
7
7
|
* neither the flag nor the mistake. A non-numeric value fails the same way.
|
|
8
8
|
*/
|
|
9
9
|
export declare function resolvePort(value: unknown, command: string): number | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The HMR socket port for a book served on `devPort`. Derived from the dev port
|
|
12
|
+
* so each concurrent dev server's socket is as distinct as its book port (#175),
|
|
13
|
+
* offset clear of the usual dev-port range and wrapped so it stays a valid port
|
|
14
|
+
* for an unusually high `--port`. `@nuxt/vite-builder` otherwise pins every
|
|
15
|
+
* server to the framework default (24678), a constant that collides (#221).
|
|
16
|
+
*/
|
|
17
|
+
export declare function hmrPortFor(devPort: number | undefined): number;
|
|
10
18
|
//# sourceMappingURL=port.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../../src/node/commands/port.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoB/E"}
|
|
1
|
+
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../../src/node/commands/port.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoB/E;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG9D"}
|
|
@@ -22,3 +22,14 @@ export function resolvePort(value, command) {
|
|
|
22
22
|
}
|
|
23
23
|
return port;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The HMR socket port for a book served on `devPort`. Derived from the dev port
|
|
27
|
+
* so each concurrent dev server's socket is as distinct as its book port (#175),
|
|
28
|
+
* offset clear of the usual dev-port range and wrapped so it stays a valid port
|
|
29
|
+
* for an unusually high `--port`. `@nuxt/vite-builder` otherwise pins every
|
|
30
|
+
* server to the framework default (24678), a constant that collides (#221).
|
|
31
|
+
*/
|
|
32
|
+
export function hmrPortFor(devPort) {
|
|
33
|
+
const base = devPort ?? 6006;
|
|
34
|
+
return base < 45536 ? base + 20000 : base - 20000;
|
|
35
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/node/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAEV,aAAa,EAEd,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/node/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAEV,aAAa,EAEd,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAiB3C,wBAAgB,gBAAgB,IAAI,aAAa,CA0HhD;AAED,eAAO,MAAM,eAAe,UAU3B,CAAA;AAED,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAsB,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ1F;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAexF;AAED,eAAO,MAAM,gBAAgB,uBAK3B,CAAA;AAEF,eAAO,MAAM,WAAW,uBAwEtB,CAAA;AAEF,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAsB,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAgB7H;AA2BD,wBAAsB,aAAa,CAAC,GAAG,EAAE,OAAO,iBAoE/C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,0BAE1D;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,UAAU;QAClB;;WAEG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;QAChC;;WAEG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;KAClC;CACF"}
|
package/dist/node/config.js
CHANGED
|
@@ -5,7 +5,6 @@ import { createJiti } from 'jiti';
|
|
|
5
5
|
import path from 'pathe';
|
|
6
6
|
import pc from 'picocolors';
|
|
7
7
|
import { mergeConfig as mergeViteConfig, resolveConfig as resolveViteConfig, } from 'vite';
|
|
8
|
-
import { tailwindTokens } from './builtin-plugins/tailwind-tokens.js';
|
|
9
8
|
import { vanillaSupport } from './builtin-plugins/vanilla-support/plugin.js';
|
|
10
9
|
import { defaultColors } from './colors.js';
|
|
11
10
|
import { findUp } from './util/find-up.js';
|
|
@@ -14,7 +13,6 @@ export function getDefaultConfig() {
|
|
|
14
13
|
return {
|
|
15
14
|
plugins: [
|
|
16
15
|
vanillaSupport(),
|
|
17
|
-
tailwindTokens(),
|
|
18
16
|
],
|
|
19
17
|
outDir: '.poveste/dist',
|
|
20
18
|
storyMatch: [
|
|
@@ -224,6 +222,15 @@ export const mergeConfig = createDefu((obj, key, value) => {
|
|
|
224
222
|
obj[key] = mergeBuildConfig(obj[key], value);
|
|
225
223
|
return true;
|
|
226
224
|
}
|
|
225
|
+
// An ignore list adds to the defaults rather than replacing them. Under the
|
|
226
|
+
// replace rule below, `storyIgnored: ['**/fixtures/**']` silently dropped
|
|
227
|
+
// `**/node_modules/**`, and the watchers then crawled the pnpm store until
|
|
228
|
+
// the build died with EMFILE (#244). `storyMatch` stays on the replace rule:
|
|
229
|
+
// narrowing it is a legitimate use.
|
|
230
|
+
if (obj[key] && key === 'storyIgnored') {
|
|
231
|
+
obj[key] = [...new Set([...obj[key], ...value])];
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
227
234
|
// By default, arrays should be replaced
|
|
228
235
|
if (obj[key] && Array.isArray(obj[key])) {
|
|
229
236
|
obj[key] = value;
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAG3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,cAAc,iBAAiB,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { defaultColors } from './colors.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './plugin.js';
|
|
4
|
+
// A plugin that generates story source needs to reference poveste's own
|
|
5
|
+
// vendored copies of Vue and the controls from inside that generated code.
|
|
6
|
+
export { getInjectedImport } from './util/vendors.js';
|
|
4
7
|
export * from '@poveste/shared';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/node/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAK3C,OAAO,UAAU,MAAM,aAAa,CAAA;AAapC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,OAAO,QAE1D;AAyBD,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,OAAO,uBA0ExD;AAaD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,OAAO,8BAqBvD;AAED,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,OAAO;;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/node/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAK3C,OAAO,UAAU,MAAM,aAAa,CAAA;AAapC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,OAAO,QAE1D;AAyBD,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,OAAO,uBA0ExD;AAaD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,OAAO,8BAqBvD;AAED,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,OAAO;;GAuH5D;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAA"}
|
package/dist/node/markdown.js
CHANGED
|
@@ -6,12 +6,12 @@ import MarkdownIt from 'markdown-it';
|
|
|
6
6
|
import anchor from 'markdown-it-anchor';
|
|
7
7
|
import attrs from 'markdown-it-attrs';
|
|
8
8
|
import { full as emoji } from 'markdown-it-emoji';
|
|
9
|
-
import micromatch from 'micromatch';
|
|
10
9
|
import path from 'pathe';
|
|
11
10
|
import pc from 'picocolors';
|
|
12
11
|
import { bundledLanguages, createHighlighter } from 'shiki';
|
|
13
12
|
import { addStory, notifyStoryChange, removeStory } from './stories.js';
|
|
14
13
|
import { slugify } from './util/slugify.js';
|
|
14
|
+
import { createWatchIgnore } from './util/watch-ignore.js';
|
|
15
15
|
const onMarkdownListChangeHandlers = [];
|
|
16
16
|
export function onMarkdownListChange(handler) {
|
|
17
17
|
onMarkdownListChangeHandlers.push(handler);
|
|
@@ -136,15 +136,7 @@ export async function createMarkdownFilesWatcher(ctx) {
|
|
|
136
136
|
const md = await createMarkdownRendererWithPlugins(ctx);
|
|
137
137
|
const watcher = chokidar.watch('.', {
|
|
138
138
|
cwd: ctx.root,
|
|
139
|
-
ignored: (
|
|
140
|
-
if (ctx.config.storyIgnored.some(pattern => micromatch.isMatch(path, pattern))) {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
if (micromatch.isMatch(path, '**/*.story.md')) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
return stats?.isFile();
|
|
147
|
-
},
|
|
139
|
+
ignored: createWatchIgnore(ctx.config.storyIgnored, ['**/*.story.md']),
|
|
148
140
|
});
|
|
149
141
|
/**
|
|
150
142
|
* Initial scan is complete.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/node/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/node/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAc3C,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACxB;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB;;;;GA4OjF"}
|
package/dist/node/server.js
CHANGED
|
@@ -2,6 +2,7 @@ import { performance } from 'node:perf_hooks';
|
|
|
2
2
|
import pc from 'picocolors';
|
|
3
3
|
import { createServer as createViteServer, mergeConfig as mergeViteConfig } from 'vite';
|
|
4
4
|
import { useCollectStories } from './collect/index.js';
|
|
5
|
+
import { hmrPortFor } from './commands/port.js';
|
|
5
6
|
import { useModuleLoader } from './load.js';
|
|
6
7
|
import { createMarkdownFilesWatcher, onMarkdownListChange } from './markdown.js';
|
|
7
8
|
import { DevEventPluginApi, DevPluginApi } from './plugin.js';
|
|
@@ -12,7 +13,21 @@ import { getViteConfigWithPlugins } from './vite.js';
|
|
|
12
13
|
export async function createServer(ctx, options = {}) {
|
|
13
14
|
const getViteServer = async (collecting) => {
|
|
14
15
|
const { viteConfig, viteConfigFile } = await getViteConfigWithPlugins(collecting, ctx);
|
|
15
|
-
if (
|
|
16
|
+
if (collecting) {
|
|
17
|
+
// The collection server drives vite-node and has no browser, so it needs
|
|
18
|
+
// no HMR socket. Left enabled, `@nuxt/vite-builder` gives it one on the
|
|
19
|
+
// framework default port (24678) — see the book server below.
|
|
20
|
+
viteConfig.server.hmr = false;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// `@nuxt/vite-builder` pins the HMR socket to the constant 24678 on every
|
|
24
|
+
// server it configures, so two poveste dev servers on different `--port`s
|
|
25
|
+
// collide on it and the second silently loses HMR (#221). It only does
|
|
26
|
+
// this when `server.hmr` carries no port of its own (it fills the gap with
|
|
27
|
+
// `defu`), so pin the socket to a port derived from this book's `--port`,
|
|
28
|
+
// before the config is resolved: each dev server then owns a distinct one
|
|
29
|
+
// (#175).
|
|
30
|
+
viteConfig.server.hmr = { port: hmrPortFor(options.port ?? viteConfig.server.port) };
|
|
16
31
|
if (options.open) {
|
|
17
32
|
viteConfig.server.open = true;
|
|
18
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stories.d.ts","sourceRoot":"","sources":["../../src/node/stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"stories.d.ts","sourceRoot":"","sources":["../../src/node/stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAQ3C,KAAK,kBAAkB,GAAG,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,OAAO,CAAA;AAG7D;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,kBAAkB,QAExD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,eAAe,QAIvD;AAED,KAAK,sBAAsB,GAAG,MAAM,OAAO,CAAA;AAG3C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,QAEhE;AAED,wBAAgB,qBAAqB,SAIpC;AAID,wBAAsB,YAAY,CAAC,UAAU,EAAE,OAAO,yCAgCrD;AAMD,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,mBA0C5E;AAED,wBAAgB,WAAW,CAAC,gBAAgB,EAAE,MAAM,QAInD;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,OAAO,iBAWvD"}
|
package/dist/node/stories.js
CHANGED
|
@@ -3,6 +3,7 @@ import chokidar from 'chokidar';
|
|
|
3
3
|
import { globby } from 'globby';
|
|
4
4
|
import micromatch from 'micromatch';
|
|
5
5
|
import { basename, resolve } from 'pathe';
|
|
6
|
+
import { createWatchIgnore } from './util/watch-ignore.js';
|
|
6
7
|
const storyChangeHandlers = [];
|
|
7
8
|
/**
|
|
8
9
|
* Called when a new story is added or modified. Collecting should be done.
|
|
@@ -44,16 +45,7 @@ export async function watchStories(newContext) {
|
|
|
44
45
|
});
|
|
45
46
|
const watcher = chokidar.watch(baseWatchPaths, {
|
|
46
47
|
cwd: context.root,
|
|
47
|
-
ignored: (
|
|
48
|
-
if (resolvedStoryIgnored.some(pattern => micromatch.isMatch(path, pattern))) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
if (resolveStoryMatch.some(pattern => micromatch.isMatch(path, pattern))) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
// Allow directories to be traversed, only ignore files that don't match
|
|
55
|
-
return stats?.isFile() ?? false;
|
|
56
|
-
},
|
|
48
|
+
ignored: createWatchIgnore(resolvedStoryIgnored, resolveStoryMatch),
|
|
57
49
|
});
|
|
58
50
|
watcher
|
|
59
51
|
.on('add', (file) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-ignore.d.ts","sourceRoot":"","sources":["../../../src/node/util/watch-ignore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,UACvD,MAAM,UAAU,KAAK,KAAG,OAAO,CAK9C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import micromatch from 'micromatch';
|
|
2
|
+
// chokidar 4 passes absolute paths, so `**` must cross dot segments (`.claude/`, `node_modules/.pnpm`).
|
|
3
|
+
const options = { dot: true };
|
|
4
|
+
export function createWatchIgnore(ignored, included) {
|
|
5
|
+
return (path, stats) => {
|
|
6
|
+
if (micromatch.isMatch(path, ignored, options))
|
|
7
|
+
return true;
|
|
8
|
+
if (micromatch.isMatch(path, included, options))
|
|
9
|
+
return false;
|
|
10
|
+
return stats?.isFile() ?? false;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolved-generated-global-setup.d.ts","sourceRoot":"","sources":["../../../src/node/virtual/resolved-generated-global-setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAI5C,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"resolved-generated-global-setup.d.ts","sourceRoot":"","sources":["../../../src/node/virtual/resolved-generated-global-setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAI5C,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,OAAO,UA4BxD"}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { GENERATED_SETUP_CODE } from './index.js';
|
|
2
|
-
import { declareEmptySetupFns,
|
|
2
|
+
import { declareEmptySetupFns, getSetupFnGroups, ID_SEPARATOR } from './util.js';
|
|
3
3
|
export function resolvedGeneratedGlobalSetup(ctx) {
|
|
4
4
|
if (ctx.config.setupCode) {
|
|
5
|
+
const groups = getSetupFnGroups(ctx);
|
|
6
|
+
const canonicals = new Set(groups.map(g => g.canonical));
|
|
5
7
|
return [
|
|
6
8
|
// Import
|
|
7
9
|
`${ctx.config.setupCode.map((c, index) => `import * as setup_${index} from '${GENERATED_SETUP_CODE}${ID_SEPARATOR}${index}'`).join('\n')}`,
|
|
8
10
|
// List
|
|
9
11
|
`const setupList = [${ctx.config.setupCode.map((c, index) => `setup_${index}`).join(', ')}]`,
|
|
10
|
-
// Setups
|
|
11
|
-
...
|
|
12
|
+
// Setups: one real function per plugin, under its canonical name only.
|
|
13
|
+
...groups.map(g => `export async function ${g.canonical} (payload) {
|
|
12
14
|
for (const setup of setupList) {
|
|
13
|
-
if (setup?.${
|
|
14
|
-
await setup.${
|
|
15
|
+
if (setup?.${g.canonical}) {
|
|
16
|
+
await setup.${g.canonical}(payload)
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
}`),
|
|
20
|
+
// Aliases are declared `undefined`, not emitted as functions: only the
|
|
21
|
+
// canonical hook is callable, so `getSetupHook` sees one hook in our own
|
|
22
|
+
// generated module rather than warning that it exports two aliases (#231).
|
|
23
|
+
...[...new Set(groups.flatMap(g => g.aliases))]
|
|
24
|
+
.filter(name => !canonicals.has(name))
|
|
25
|
+
.map(name => `export const ${name} = undefined`),
|
|
18
26
|
].join('\n');
|
|
19
27
|
}
|
|
20
28
|
else {
|
|
@@ -5,6 +5,17 @@ export declare const ID_SEPARATOR = "__-__";
|
|
|
5
5
|
* `setupVanilla`, `setupVue3`, `setupSvelte4`.
|
|
6
6
|
*/
|
|
7
7
|
export declare function getSetupFnNames(ctx: Context): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Setup hooks grouped by the plugin that contributes them, canonical name first.
|
|
10
|
+
* A plugin's `setupFn` lists one hook under several names — `['setupVue3',
|
|
11
|
+
* 'setupVue']` is a single hook whose established name is `setupVue3` and whose
|
|
12
|
+
* alias is `setupVue`. The first is canonical; the rest are aliases kept so
|
|
13
|
+
* older setup files still resolve.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSetupFnGroups(ctx: Context): {
|
|
16
|
+
canonical: string;
|
|
17
|
+
aliases: string[];
|
|
18
|
+
}[];
|
|
8
19
|
/**
|
|
9
20
|
* Declares the setup hooks as named exports set to `undefined`.
|
|
10
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/node/virtual/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,YAAY,UAAU,CAAA;AAEnC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,YAE3C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,UAEhD;AAED,eAAO,MAAM,gBAAgB,UAE5B,CAAA"}
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/node/virtual/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,YAAY,UAAU,CAAA;AAEnC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,YAE3C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO;;;IAK5C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,UAEhD;AAED,eAAO,MAAM,gBAAgB,UAE5B,CAAA"}
|
|
@@ -6,6 +6,19 @@ export const ID_SEPARATOR = '__-__';
|
|
|
6
6
|
export function getSetupFnNames(ctx) {
|
|
7
7
|
return [...new Set(ctx.supportPlugins.flatMap(p => p.setupFn))];
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Setup hooks grouped by the plugin that contributes them, canonical name first.
|
|
11
|
+
* A plugin's `setupFn` lists one hook under several names — `['setupVue3',
|
|
12
|
+
* 'setupVue']` is a single hook whose established name is `setupVue3` and whose
|
|
13
|
+
* alias is `setupVue`. The first is canonical; the rest are aliases kept so
|
|
14
|
+
* older setup files still resolve.
|
|
15
|
+
*/
|
|
16
|
+
export function getSetupFnGroups(ctx) {
|
|
17
|
+
return ctx.supportPlugins.map((p) => {
|
|
18
|
+
const names = typeof p.setupFn === 'string' ? [p.setupFn] : p.setupFn;
|
|
19
|
+
return { canonical: names[0], aliases: names.slice(1) };
|
|
20
|
+
});
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* Declares the setup hooks as named exports set to `undefined`.
|
|
11
24
|
*
|
package/dist/node/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/node/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/node/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAuB3C,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,yBAmClF;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,YAAY,CAAA;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA+W9G"}
|
package/dist/node/vite.js
CHANGED
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { lookup as lookupMime } from 'mrmime';
|
|
4
4
|
import { dirname, join, relative } from 'pathe';
|
|
5
|
-
import { loadConfigFromFile as loadViteConfigFromFile, mergeConfig as mergeViteConfig, } from 'vite';
|
|
5
|
+
import { loadConfigFromFile as loadViteConfigFromFile, mergeConfig as mergeViteConfig, searchForWorkspaceRoot, } from 'vite';
|
|
6
6
|
import { APP_PATH, TEMP_PATH } from './alias.js';
|
|
7
7
|
import { createMarkdownPlugins } from './markdown.js';
|
|
8
8
|
import { notifyStoryChange } from './stories.js';
|
|
@@ -140,6 +140,10 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
140
140
|
TEMP_PATH,
|
|
141
141
|
ctx.resolvedViteConfig.root,
|
|
142
142
|
process.cwd(),
|
|
143
|
+
// Vite's own default, which setting `allow` at all replaces. In a
|
|
144
|
+
// workspace the app's deps resolve above the project — the
|
|
145
|
+
// bundled font under the root `node_modules` was refused (#252).
|
|
146
|
+
searchForWorkspaceRoot(process.cwd()),
|
|
143
147
|
...supportPluginAllowPaths,
|
|
144
148
|
...process.env.POVESTE_DEV
|
|
145
149
|
? [
|
|
@@ -156,7 +160,13 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
156
160
|
define: {
|
|
157
161
|
// We need to force this to be able to use `devtoolsRawSetupState`
|
|
158
162
|
'__VUE_PROD_DEVTOOLS__': 'true',
|
|
159
|
-
//
|
|
163
|
+
// Vue's esm-bundler build expects every feature flag to be injected;
|
|
164
|
+
// in a production build an undefined one logs a warning per realm.
|
|
165
|
+
'__VUE_OPTIONS_API__': 'true',
|
|
166
|
+
'__VUE_PROD_HYDRATION_MISMATCH_DETAILS__': 'false',
|
|
167
|
+
// `bin.ts` sets this per command: development for `dev`, production
|
|
168
|
+
// for `build` and `preview`. Every built book used to ship the
|
|
169
|
+
// development build of Vue, Pinia, vue-router and VueUse.
|
|
160
170
|
'process.env.NODE_ENV': JSON.stringify(isServer ? 'production' : process.env.NODE_ENV ?? 'development'),
|
|
161
171
|
...!isServer
|
|
162
172
|
? {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poveste",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"description": "A fast story book powered by Vite",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan"
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"sirv": "^3.0.0",
|
|
69
69
|
"unhead": "^3.1.0",
|
|
70
70
|
"vite-node": "^6.0.0",
|
|
71
|
-
"@poveste/app": "^0.
|
|
72
|
-
"@poveste/
|
|
73
|
-
"@poveste/controls": "^0.
|
|
74
|
-
"@poveste/
|
|
71
|
+
"@poveste/app": "^0.6.1",
|
|
72
|
+
"@poveste/vendors": "^0.6.1",
|
|
73
|
+
"@poveste/controls": "^0.6.1",
|
|
74
|
+
"@poveste/shared": "^0.6.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { getDefaultConfig, mergeConfig } from '../config.js'
|
|
3
|
+
|
|
4
|
+
// `mergeConfig(user, defaults)`: defu-style, the first argument wins.
|
|
5
|
+
describe('mergeConfig', () => {
|
|
6
|
+
it('adds user storyIgnored patterns to the defaults instead of replacing them', () => {
|
|
7
|
+
const merged = mergeConfig({ storyIgnored: ['**/fixtures/**'] }, getDefaultConfig())
|
|
8
|
+
|
|
9
|
+
expect(merged.storyIgnored).toEqual(expect.arrayContaining(['**/node_modules/**', '**/dist/**', '**/fixtures/**']))
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('does not duplicate a default a user spelled out again', () => {
|
|
13
|
+
const merged = mergeConfig({ storyIgnored: ['**/node_modules/**', '**/fixtures/**'] }, getDefaultConfig())
|
|
14
|
+
|
|
15
|
+
expect(merged.storyIgnored.filter(p => p === '**/node_modules/**')).toHaveLength(1)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
// Narrowing the match is a real use — `src/**/*.story.vue` to skip binary
|
|
19
|
+
// folders — so the replace rule is the right one there.
|
|
20
|
+
it('still lets a user narrow storyMatch', () => {
|
|
21
|
+
const merged = mergeConfig({ storyMatch: ['src/**/*.story.vue'] }, getDefaultConfig())
|
|
22
|
+
|
|
23
|
+
expect(merged.storyMatch).toEqual(['src/**/*.story.vue'])
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { resolvePort } from '../commands/port.js'
|
|
2
|
+
import { hmrPortFor, resolvePort } from '../commands/port.js'
|
|
3
3
|
|
|
4
4
|
describe('resolvePort', () => {
|
|
5
5
|
it('returns undefined when the flag was not passed', () => {
|
|
@@ -31,3 +31,35 @@ describe('resolvePort', () => {
|
|
|
31
31
|
expect(() => resolvePort(true, 'dev')).toThrow(/poveste dev --port 6006/)
|
|
32
32
|
})
|
|
33
33
|
})
|
|
34
|
+
|
|
35
|
+
// `@nuxt/vite-builder` otherwise pins every server's HMR socket to the constant
|
|
36
|
+
// 24678, so two dev servers on different `--port`s collide and the second
|
|
37
|
+
// silently loses HMR (#221). The socket has to be as unique as the book port.
|
|
38
|
+
describe('hmrPortFor', () => {
|
|
39
|
+
it('derives a port distinct from the dev port', () => {
|
|
40
|
+
expect(hmrPortFor(6006)).not.toBe(6006)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('gives distinct dev ports distinct sockets', () => {
|
|
44
|
+
expect(hmrPortFor(4567)).not.toBe(hmrPortFor(4568))
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('never lands on the framework default that collides', () => {
|
|
48
|
+
for (const p of [4567, 4568, 6006, 8080]) {
|
|
49
|
+
expect(hmrPortFor(p)).not.toBe(24678)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('stays within the valid port range, even for a high dev port', () => {
|
|
54
|
+
for (const p of [1024, 6006, 45535, 45536, 65535]) {
|
|
55
|
+
const hmr = hmrPortFor(p)
|
|
56
|
+
expect(hmr).toBeGreaterThanOrEqual(0)
|
|
57
|
+
expect(hmr).toBeLessThanOrEqual(65535)
|
|
58
|
+
expect(hmr).not.toBe(p)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('falls back to the default dev port when none was given', () => {
|
|
63
|
+
expect(hmrPortFor(undefined)).toBe(hmrPortFor(6006))
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -29,13 +29,23 @@ describe('virtual setup modules', () => {
|
|
|
29
29
|
}
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
it('
|
|
32
|
+
it('exports each plugin\'s canonical hook as a real function when there is setup code', () => {
|
|
33
33
|
const code = resolvedGeneratedGlobalSetup(contextFactory({ setupCode: ['export function setupVue3() {}'] }))
|
|
34
34
|
|
|
35
|
-
for (const
|
|
36
|
-
expect(code).toContain(`export async function ${
|
|
35
|
+
for (const canonical of ['setupVanilla', 'setupVue3', 'setupSvelte4']) {
|
|
36
|
+
expect(code).toContain(`export async function ${canonical} (payload)`)
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
|
+
|
|
40
|
+
// setupSvelte5 is an alias of setupSvelte4. Emitting both as functions made
|
|
41
|
+
// getSetupHook see two interchangeable hooks in poveste's own generated
|
|
42
|
+
// module and warn once per story (#231).
|
|
43
|
+
it('declares alias hooks undefined rather than as functions', () => {
|
|
44
|
+
const code = resolvedGeneratedGlobalSetup(contextFactory({ setupCode: ['export function setupVue3() {}'] }))
|
|
45
|
+
|
|
46
|
+
expect(code).toContain('export const setupSvelte5 = undefined')
|
|
47
|
+
expect(code).not.toContain('export async function setupSvelte5 (payload)')
|
|
48
|
+
})
|
|
39
49
|
})
|
|
40
50
|
|
|
41
51
|
describe('noop', () => {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Stats } from 'node:fs'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { createWatchIgnore } from '../util/watch-ignore.js'
|
|
4
|
+
|
|
5
|
+
const file = { isFile: () => true } as Stats
|
|
6
|
+
const dir = { isFile: () => false } as Stats
|
|
7
|
+
|
|
8
|
+
describe('createWatchIgnore', () => {
|
|
9
|
+
const root = '/repo/.claude/worktrees/feature/examples/vue3'
|
|
10
|
+
const ignored = createWatchIgnore(['**/node_modules/**', '**/dist/**'], ['**/*.story.md'])
|
|
11
|
+
|
|
12
|
+
it('ignores storyIgnored paths when the root sits under a dot directory', () => {
|
|
13
|
+
expect(ignored(`${root}/node_modules/foo/index.js`, file)).toBe(true)
|
|
14
|
+
expect(ignored(`${root}/node_modules/.pnpm/foo/node_modules/bar`, dir)).toBe(true)
|
|
15
|
+
expect(ignored(`${root}/dist/index.html`, file)).toBe(true)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('keeps included files when the root sits under a dot directory', () => {
|
|
19
|
+
expect(ignored(`${root}/src/Button.story.md`, file)).toBe(false)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('traverses directories and skips other files', () => {
|
|
23
|
+
expect(ignored(`${root}/src`, dir)).toBe(false)
|
|
24
|
+
expect(ignored(`${root}/src/Button.vue`, file)).toBe(true)
|
|
25
|
+
expect(ignored(`${root}/src/Button.vue`)).toBe(false)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('matches patterns resolved to absolute paths', () => {
|
|
29
|
+
const resolved = createWatchIgnore([`${root}/**/node_modules/**`], [`${root}/**/*.story.vue`])
|
|
30
|
+
expect(resolved(`${root}/node_modules/.pnpm/foo/node_modules/bar/index.js`, file)).toBe(true)
|
|
31
|
+
expect(resolved(`${root}/src/Button.story.vue`, file)).toBe(false)
|
|
32
|
+
})
|
|
33
|
+
})
|
package/src/node/bin.ts
CHANGED
|
@@ -7,7 +7,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
7
7
|
|
|
8
8
|
const { version } = JSON.parse(fs.readFileSync(resolve(__dirname, '../../package.json'), 'utf8'))
|
|
9
9
|
|
|
10
|
-
process.env.NODE_ENV = 'development'
|
|
10
|
+
process.env.NODE_ENV = process.argv.includes('build') || process.argv.includes('preview') ? 'production' : 'development'
|
|
11
11
|
process.env.HISTOIRE = 'true'
|
|
12
12
|
process.env.POVESTE = 'true'
|
|
13
13
|
|