@storybook/builder-vite 0.2.4 → 0.2.6
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/index.d.ts +1 -0
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/index.ts +13 -11
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare type ViteFinal = (config: InlineConfig, options: Options) => Inli
|
|
|
6
6
|
export declare type StorybookViteConfig = StorybookConfig & {
|
|
7
7
|
viteFinal: ViteFinal;
|
|
8
8
|
};
|
|
9
|
+
export declare function bail(e?: Error): Promise<void>;
|
|
9
10
|
export declare const start: ViteBuilder['start'];
|
|
10
11
|
export declare const build: ViteBuilder['build'];
|
|
11
12
|
export declare const corePresets: never[];
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.previewPresets = exports.corePresets = exports.build = exports.start = void 0;
|
|
27
|
+
exports.previewPresets = exports.corePresets = exports.build = exports.start = exports.bail = void 0;
|
|
28
28
|
const fs = __importStar(require("fs"));
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
30
|
const transform_iframe_html_1 = require("./transform-iframe-html");
|
|
@@ -49,8 +49,19 @@ function iframeMiddleware(options, server) {
|
|
|
49
49
|
res.status(200).send(transformed);
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
+
let server;
|
|
53
|
+
async function bail(e) {
|
|
54
|
+
try {
|
|
55
|
+
return await server.close();
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
console.warn('unable to close vite server');
|
|
59
|
+
}
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
exports.bail = bail;
|
|
52
63
|
const start = async ({ startTime, options, router, server: devServer }) => {
|
|
53
|
-
|
|
64
|
+
server = await (0, vite_server_1.createViteServer)(options, devServer);
|
|
54
65
|
// Just mock this endpoint (which is really Webpack-specific) so we don't get spammed with 404 in browser devtools
|
|
55
66
|
// TODO: we should either show some sort of progress from Vite, or just try to disable the whole Loader in the Manager UI.
|
|
56
67
|
router.get('/progress', (req, res) => {
|
|
@@ -59,15 +70,6 @@ const start = async ({ startTime, options, router, server: devServer }) => {
|
|
|
59
70
|
});
|
|
60
71
|
router.use(await iframeMiddleware(options, server));
|
|
61
72
|
router.use(server.middlewares);
|
|
62
|
-
async function bail(e) {
|
|
63
|
-
try {
|
|
64
|
-
return await server.close();
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
console.warn('unable to close vite server');
|
|
68
|
-
}
|
|
69
|
-
throw e;
|
|
70
|
-
}
|
|
71
73
|
return {
|
|
72
74
|
bail,
|
|
73
75
|
stats: null,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;AAErC,uCAAyB;AACzB,2CAA6B;AAC7B,mEAA8D;AAC9D,+CAAiD;AACjD,mCAA6C;AAkB7C,SAAS,gBAAgB,CAAC,OAAwB,EAAE,MAAqB;IACvE,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC9B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAAE;YAC3C,IAAI,EAAE,CAAC;YACP,OAAO;SACR;QAED,yIAAyI;QACzI,2CAA2C;QAC3C,IAAI,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE;YACzC,IAAI,EAAE,CAAC;YACP,OAAO;SACR;QAED,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,E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AAE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;KACrC,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,KAAK,SAkBhB;AAEK,MAAM,KAAK,GAAyB,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAC/D,OAAO,IAAA,aAAS,EAAC,OAA0B,CAAC,CAAC;AAC/C,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB;AAEW,QAAA,WAAW,GAAG,EAAE,CAAC;AACjB,QAAA,cAAc,GAAG,EAAE,CAAC","sourcesContent":["// noinspection JSUnusedGlobalSymbols\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { transformIframeHtml } from './transform-iframe-html';\nimport { createViteServer } from './vite-server';\nimport { build as viteBuild } from './build';\n\nimport type { Builder, StorybookConfig, Options } from '@storybook/core-common';\nimport type { RequestHandler, Request, Response } from 'express';\nimport type { InlineConfig, UserConfig, ViteDevServer } from 'vite';\nimport type { ExtendedOptions } from './types';\n\n// Storybook's Stats are optional Webpack related property\nexport type ViteStats = null;\n\nexport type ViteBuilder = Builder<UserConfig, ViteStats>;\n\nexport type ViteFinal = (config: InlineConfig, options: Options) => InlineConfig | Promise<InlineConfig>;\n\nexport type StorybookViteConfig = StorybookConfig & {\n viteFinal: ViteFinal;\n};\n\nfunction iframeMiddleware(options: ExtendedOptions, server: ViteDevServer): RequestHandler {\n return async (req, res, next) => {\n if (!req.url.match(/^\\/iframe\\.html($|\\?)/)) {\n next();\n return;\n }\n\n // We need to handle `html-proxy` params for style tag HMR https://github.com/storybookjs/builder-vite/issues/266#issuecomment-1055677865\n // e.g. /iframe.html?html-proxy&index=0.css\n if (req.query['html-proxy'] !== undefined) {\n next();\n return;\n }\n\n const indexHtml = fs.readFileSync(path.resolve(__dirname, '..', 'input', 'iframe.html'), 'utf-8');\n const generated = await transformIframeHtml(indexHtml, options);\n const transformed = await server.transformIndexHtml('/iframe.html', generated);\n res.setHeader('Content-Type', 'text/html');\n res.status(200).send(transformed);\n };\n}\n\nlet server: ViteDevServer;\n\nexport async function bail(e?: Error): Promise<void> {\n try {\n return await server.close();\n } catch (err) {\n console.warn('unable to close vite server');\n }\n\n throw e;\n}\n\nexport const start: ViteBuilder['start'] = async ({ startTime, options, router, server: devServer }) => {\n server = await createViteServer(options as ExtendedOptions, devServer);\n\n // Just mock this endpoint (which is really Webpack-specific) so we don't get spammed with 404 in browser devtools\n // TODO: we should either show some sort of progress from Vite, or just try to disable the whole Loader in the Manager UI.\n router.get('/progress', (req: Request, res: Response) => {\n res.header('Cache-Control', 'no-cache');\n res.header('Content-Type', 'text/event-stream');\n });\n\n router.use(await iframeMiddleware(options as ExtendedOptions, server));\n router.use(server.middlewares);\n\n return {\n bail,\n stats: null,\n totalTime: process.hrtime(startTime),\n };\n};\n\nexport const build: ViteBuilder['build'] = async ({ options }) => {\n return viteBuild(options as ExtendedOptions);\n};\n\nexport const corePresets = [];\nexport const previewPresets = [];\n"]}
|
package/index.ts
CHANGED
|
@@ -44,8 +44,20 @@ function iframeMiddleware(options: ExtendedOptions, server: ViteDevServer): Requ
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
let server: ViteDevServer;
|
|
48
|
+
|
|
49
|
+
export async function bail(e?: Error): Promise<void> {
|
|
50
|
+
try {
|
|
51
|
+
return await server.close();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.warn('unable to close vite server');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
58
|
+
|
|
47
59
|
export const start: ViteBuilder['start'] = async ({ startTime, options, router, server: devServer }) => {
|
|
48
|
-
|
|
60
|
+
server = await createViteServer(options as ExtendedOptions, devServer);
|
|
49
61
|
|
|
50
62
|
// Just mock this endpoint (which is really Webpack-specific) so we don't get spammed with 404 in browser devtools
|
|
51
63
|
// TODO: we should either show some sort of progress from Vite, or just try to disable the whole Loader in the Manager UI.
|
|
@@ -57,16 +69,6 @@ export const start: ViteBuilder['start'] = async ({ startTime, options, router,
|
|
|
57
69
|
router.use(await iframeMiddleware(options as ExtendedOptions, server));
|
|
58
70
|
router.use(server.middlewares);
|
|
59
71
|
|
|
60
|
-
async function bail(e?: Error): Promise<void> {
|
|
61
|
-
try {
|
|
62
|
-
return await server.close();
|
|
63
|
-
} catch (err) {
|
|
64
|
-
console.warn('unable to close vite server');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
throw e;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
72
|
return {
|
|
71
73
|
bail,
|
|
72
74
|
stats: null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/builder-vite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "A plugin to run and build Storybooks with Vite",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"glob": "^7.2.0",
|
|
37
37
|
"glob-promise": "^4.2.0",
|
|
38
38
|
"magic-string": "^0.26.1",
|
|
39
|
-
"react-docgen": "
|
|
39
|
+
"react-docgen": "6.0.0-alpha.3",
|
|
40
40
|
"slash": "^3.0.0",
|
|
41
41
|
"sveltedoc-parser": "^4.2.1"
|
|
42
42
|
},
|