Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prebundle the preview #19718

Merged
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9a07e87
prebundle the preview
ndelangen Nov 2, 2022
f98bc37
improvements
ndelangen Nov 2, 2022
36d0659
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 4, 2022
fb08bfc
wip
ndelangen Nov 7, 2022
dbe046c
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 8, 2022
17b876f
wip
ndelangen Nov 8, 2022
1fe77d4
fix lockfile
ndelangen Nov 8, 2022
1db803d
fixes for angular
ndelangen Nov 8, 2022
ab687a1
fix the other renderers types
ndelangen Nov 8, 2022
c523042
make blocks more self-contained
ndelangen Nov 8, 2022
34ab45a
making docs work maybe
ndelangen Nov 9, 2022
d15e5a0
fix lockfile
ndelangen Nov 9, 2022
b3caece
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 9, 2022
247c527
fixes
ndelangen Nov 9, 2022
655c89c
linting
ndelangen Nov 9, 2022
9bcf735
fixes
ndelangen Nov 9, 2022
9bfd817
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 11, 2022
e3a46f5
fixes
ndelangen Nov 11, 2022
b1a038e
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 14, 2022
8cf492d
fixes
ndelangen Nov 14, 2022
4b77ab1
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 14, 2022
e0b7084
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 15, 2022
39fd00c
add explanation
ndelangen Nov 15, 2022
b105b21
regen lockfile, sync csf package version
ndelangen Nov 15, 2022
1059a82
perf improvements
ndelangen Nov 15, 2022
da1a067
enable fast open again, re-use serverChannel
ndelangen Nov 15, 2022
8bb0ed3
fixes
ndelangen Nov 15, 2022
6351b1a
cleanup
ndelangen Nov 15, 2022
91b2e55
cleanup
ndelangen Nov 15, 2022
a4ac8b9
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 15, 2022
a38734c
fixes
ndelangen Nov 15, 2022
6d88303
fix static build
ndelangen Nov 16, 2022
a634cf9
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 16, 2022
d37d1a5
fixes
ndelangen Nov 16, 2022
efb6b91
fix esbuild-register registering twice in tests
ndelangen Nov 16, 2022
70182dd
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 16, 2022
6b92157
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 16, 2022
7743017
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 17, 2022
7dc6abf
use an inline esm instead
ndelangen Nov 17, 2022
5af191f
add caching
ndelangen Nov 17, 2022
f6e59a1
cleanup
ndelangen Nov 17, 2022
7d20b7c
preloading no longer needed, since request is not plainly visible to …
ndelangen Nov 17, 2022
b4cd568
use same trick for manager: using an inline esm to combine request an…
ndelangen Nov 17, 2022
341d549
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 18, 2022
d2a127e
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 18, 2022
db13564
cleanup
ndelangen Nov 18, 2022
c431700
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 18, 2022
aca780b
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 18, 2022
c4fc196
make progress on making the changes for vite builder with Ian
ndelangen Nov 21, 2022
52c3f5f
use externals feature of webpack over global modules aliases
ndelangen Nov 21, 2022
e715e7c
refactor for perf, more presets apply in parallel
ndelangen Nov 21, 2022
6dec23f
Merge remote-tracking branch 'origin/next' into norbert/sb-798-figure…
IanVS Nov 21, 2022
dc96afa
Generate exports.ts for @storybook/preview
IanVS Nov 22, 2022
dd1f555
Use esbuild plugin to externalize preview imports
IanVS Nov 22, 2022
dfe2039
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 22, 2022
3dff5ea
Merge branch 'norbert/sb-798-figure-out-plan-for-package-structure-re…
ndelangen Nov 22, 2022
a181638
refactor the exports generation so it's the same as for manager
ndelangen Nov 22, 2022
656edaa
cleanup
ndelangen Nov 22, 2022
9656826
fix types types/node
ndelangen Nov 22, 2022
bc0a83f
fix
ndelangen Nov 22, 2022
de8be83
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 22, 2022
ec73fa0
Merge branch 'next' into norbert/sb-798-figure-out-plan-for-package-s…
ndelangen Nov 22, 2022
6d692e5
fixes
ndelangen Nov 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"devDependencies": {
"@storybook/jest": "^0.0.10",
"@storybook/testing-library": "0.0.14-next.0",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
"formik": "^2.2.9",
"typescript": "^4.9.3"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@storybook/node-logger": "7.0.0-alpha.52",
"@storybook/store": "7.0.0-alpha.52",
"@storybook/types": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"@types/react": "^16.14.34",
"@types/react-dom": "^16.9.14",
"@types/semver": "^7.3.4",
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/html-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@storybook/core-common": "7.0.0-alpha.52",
"@storybook/html": "7.0.0-alpha.52",
"@storybook/preset-html-webpack": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"global": "^4.4.0",
"react": "16.14.0",
"react-dom": "16.14.0"
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@storybook/node-logger": "7.0.0-alpha.52",
"@storybook/preset-react-webpack": "7.0.0-alpha.52",
"@storybook/react": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"find-up": "^5.0.0",
"fs-extra": "^9.0.1",
"image-size": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/preact-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@storybook/core-common": "7.0.0-alpha.52",
"@storybook/preact": "7.0.0-alpha.52",
"@storybook/preset-preact-webpack": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"vite": "^3.1.3"
},
"devDependencies": {
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"typescript": "^4.9.3",
"vite": "^3.1.3"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@storybook/builder-webpack5": "7.0.0-alpha.52",
"@storybook/preset-react-webpack": "7.0.0-alpha.52",
"@storybook/react": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0"
"@types/node": "^16.0.0"
},
"devDependencies": {
"jest-specific-snapshot": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/server-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@storybook/core-common": "7.0.0-alpha.52",
"@storybook/preset-server-webpack": "7.0.0-alpha.52",
"@storybook/server": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/svelte-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"vite": "^3.1.3"
},
"devDependencies": {
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"typescript": "^4.9.3",
"vite": "^3.1.3"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/vue-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@storybook/core-common": "7.0.0-alpha.52",
"@storybook/preset-vue-webpack": "7.0.0-alpha.52",
"@storybook/vue": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/vue3-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"vue-docgen-api": "^4.40.0"
},
"devDependencies": {
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"typescript": "^4.9.3",
"vite": "^3.1.3"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/vue3-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@storybook/core-common": "7.0.0-alpha.52",
"@storybook/preset-vue3-webpack": "7.0.0-alpha.52",
"@storybook/vue3": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/web-components-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"vite": "3"
},
"devDependencies": {
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"typescript": "^4.9.3",
"vite": "^3.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/web-components-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@storybook/core-common": "7.0.0-alpha.52",
"@storybook/preset-web-components-webpack": "7.0.0-alpha.52",
"@storybook/web-components": "7.0.0-alpha.52",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
Expand Down
8 changes: 1 addition & 7 deletions code/lib/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./shortcut": {
"require": "./dist/shortcut.js",
"import": "./dist/shortcut.mjs",
"types": "./dist/shortcut.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
Expand Down Expand Up @@ -79,8 +74,7 @@
},
"bundler": {
"entries": [
"./src/index.tsx",
"./src/shortcut.ts"
"./src/index.tsx"
]
},
"gitHead": "d2494e3f51ce0f55bcb1ef693a6477c669fbe666"
Expand Down
8 changes: 0 additions & 8 deletions code/lib/api/shortcut.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion code/lib/api/shortcut.js

This file was deleted.

3 changes: 3 additions & 0 deletions code/lib/api/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import * as url from './modules/url';
import * as version from './modules/versions';
// eslint-disable-next-line import/no-cycle
import * as globals from './modules/globals';
import { eventToShortcut, shortcutMatchesShortcut, shortcutToHumanString } from './lib/shortcut';

const { ActiveTabs } = layout;

Expand Down Expand Up @@ -480,3 +481,5 @@ export function useArgTypes(): API_ArgTypes {
const current = useCurrentStory();
return (current?.type === 'story' && current.argTypes) || {};
}

export { eventToShortcut, shortcutToHumanString, shortcutMatchesShortcut };
4 changes: 2 additions & 2 deletions code/lib/builder-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ const starter: StarterFunction = async function* starterGeneratorFn({

const coreDirOrigin = join(dirname(require.resolve('@storybook/manager/package.json')), 'dist');

router.use(`/sb-addons`, express.static(addonsDir));
router.use(`/sb-manager`, express.static(coreDirOrigin));
router.use(`/sb-addons`, express.static(addonsDir, { immutable: true, maxAge: '5m' }));
router.use(`/sb-manager`, express.static(coreDirOrigin, { immutable: true, maxAge: '5m' }));

const { cssFiles, jsFiles } = await readOrderedFiles(addonsDir, compilation?.outputFiles);

Expand Down
3 changes: 2 additions & 1 deletion code/lib/builder-manager/src/utils/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const renderHTML = async (
refs: Promise<Record<string, Ref>>,
logLevel: Promise<string>,
docsOptions: Promise<DocsOptions>,
{ versionCheck, releaseNotesData, docsMode, previewUrl, serverChannelUrl }: Options
{ versionCheck, releaseNotesData, previewUrl, serverChannelUrl, configType }: Options
) => {
const customHeadRef = await customHead;
const titleRef = await title;
Expand All @@ -71,6 +71,7 @@ export const renderHTML = async (
REFS: JSON.stringify(await refs, null, 2),
LOGLEVEL: JSON.stringify(await logLevel, null, 2),
DOCS_OPTIONS: JSON.stringify(await docsOptions, null, 2),
CONFIG_TYPE: JSON.stringify(await configType, null, 2),
// These two need to be double stringified because the UI expects a string
VERSIONCHECK: JSON.stringify(JSON.stringify(versionCheck), null, 2),
RELEASE_NOTES_DATA: JSON.stringify(JSON.stringify(releaseNotesData), null, 2),
Expand Down
12 changes: 8 additions & 4 deletions code/lib/builder-manager/templates/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<link rel="shortcut icon" href="./favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link href="./sb-preview/runtime.mjs" rel="preload" as="script">

<% if (typeof head !== 'undefined') { %> <%- head %> <% } %>

<style>
Expand All @@ -33,10 +35,12 @@
</script>
<% } %>

<script src="./sb-manager/runtime.mjs" type="module"></script>
<script type="module">
import './sb-manager/runtime.mjs';

<% files.js.forEach(file => { %>
<script src="<%= file %>" type="module"></script>
<% }); %>
<% files.js.forEach(file => { %>
import './<%= file %>';
<% }); %>
</script>
</body>
</html>
11 changes: 8 additions & 3 deletions code/lib/builder-vite/input/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,22 @@
window.STORIES = '[STORIES HERE]';
window.DOCS_OPTIONS = '[DOCS_OPTIONS HERE]';
window.SERVER_CHANNEL_URL = '[SERVER_CHANNEL_URL HERE]';

// We do this so that "module && module.hot" etc. in Storybook source code
// doesn't fail (it will simply be disabled)
window.module = undefined;
</script>
</script>
<!-- [HEAD HTML SNIPPET HERE] -->
</head>
<body>
<!-- [BODY HTML SNIPPET HERE] -->
<div id="storybook-root"></div>
<div id="storybook-docs"></div>
<script type="module" src="/virtual:/@storybook/builder-vite/vite-app.js"></script>
<script type="module">
/* eslint-disable import/no-absolute-path, import/extensions, import/no-unresolved */

import '/sb-preview/runtime.mjs';
Copy link
Member Author

@ndelangen ndelangen Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IanVS I think this should really be:

import './sb-preview/runtime.mjs';

WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I think the two urls are equivalent since iframe.html is at the root of the site, right? The relative path looks a little odd to me, personally, but I don't feel strongly so long as both work correctly, including when the site is served at a subpath (e.g. github pages).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not always the root of the site

import '/virtual:/@storybook/builder-vite/vite-app.js';
</script>
</body>
</html>
6 changes: 5 additions & 1 deletion code/lib/builder-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,22 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
"@joshwooding/vite-plugin-react-docgen-typescript": "0.0.5",
"@storybook/client-api": "7.0.0-alpha.52",
"@storybook/client-logger": "7.0.0-alpha.52",
"@storybook/core-common": "7.0.0-alpha.52",
"@storybook/mdx2-csf": "next",
"@storybook/node-logger": "7.0.0-alpha.52",
"@storybook/preview": "7.0.0-alpha.52",
"@storybook/preview-web": "7.0.0-alpha.52",
"@storybook/source-loader": "7.0.0-alpha.52",
"@storybook/types": "7.0.0-alpha.52",
"@vitejs/plugin-react": "^2.0.0",
"browser-assert": "^1.2.1",
"es-module-lexer": "^0.9.3",
"express": "^4.17.1",
"fs-extra": "^9.0.1",
"glob": "^7.2.0",
"glob-promise": "^4.2.0",
"magic-string": "^0.26.1",
Expand All @@ -61,7 +65,7 @@
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^16.0.0 || ^18.0.0",
"@types/node": "^16.0.0",
"typescript": "^4.9.3",
"vite": "^3.1.3"
},
Expand Down
38 changes: 28 additions & 10 deletions code/lib/builder-vite/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// noinspection JSUnusedGlobalSymbols

import * as fs from 'fs';
import * as fs from 'fs-extra';
import type { Builder, StorybookConfig as StorybookBaseConfig, Options } from '@storybook/types';
import type { RequestHandler, Request, Response } from 'express';
import type { RequestHandler } from 'express';
import type { InlineConfig, UserConfig, ViteDevServer } from 'vite';
import express from 'express';
import { dirname, join, parse } from 'path';
import { transformIframeHtml } from './transform-iframe-html';
import { createViteServer } from './vite-server';
import { build as viteBuild } from './build';
Expand Down Expand Up @@ -44,7 +46,7 @@ function iframeMiddleware(options: ExtendedOptions, server: ViteDevServer): Requ
return;
}

const indexHtml = fs.readFileSync(
const indexHtml = await fs.readFile(
require.resolve('@storybook/builder-vite/input/iframe.html'),
'utf-8'
);
Expand Down Expand Up @@ -75,12 +77,10 @@ export const start: ViteBuilder['start'] = async ({
}) => {
server = await createViteServer(options as ExtendedOptions, devServer);

// Just mock this endpoint (which is really Webpack-specific) so we don't get spammed with 404 in browser devtools
// TODO: we should either show some sort of progress from Vite, or just try to disable the whole Loader in the Manager UI.
router.get('/progress', (req: Request, res: Response) => {
res.header('Cache-Control', 'no-cache');
res.header('Content-Type', 'text/event-stream');
});
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
const previewResolvedDir = dirname(require.resolve('@storybook/preview/package.json'));
const previewDirOrigin = join(previewResolvedDir, 'dist');

router.use(`/sb-preview`, express.static(previewDirOrigin, { immutable: true, maxAge: '5m' }));

router.use(iframeMiddleware(options as ExtendedOptions, server));
router.use(server.middlewares);
Expand All @@ -93,5 +93,23 @@ export const start: ViteBuilder['start'] = async ({
};

export const build: ViteBuilder['build'] = async ({ options }) => {
return viteBuild(options as ExtendedOptions);
const viteCompilation = viteBuild(options as ExtendedOptions);

const previewResolvedDir = dirname(require.resolve('@storybook/preview/package.json'));
const previewDirOrigin = join(previewResolvedDir, 'dist');
const previewDirTarget = join(options.outputDir || '', `sb-preview`);

const previewFiles = fs.copy(previewDirOrigin, previewDirTarget, {
filter: (src) => {
const { ext } = parse(src);
if (ext) {
return ext === '.mjs';
}
return true;
},
});

const [out] = await Promise.all([viteCompilation, previewFiles]);

return out;
};
11 changes: 9 additions & 2 deletions code/lib/builder-vite/src/optimizeDeps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as path from 'path';
import { normalizePath, resolveConfig } from 'vite';
import type { InlineConfig as ViteInlineConfig } from 'vite';
import type { InlineConfig as ViteInlineConfig, UserConfig } from 'vite';
import { globalExternals } from '@fal-works/esbuild-plugin-global-externals';
import { definitions } from '@storybook/preview/globals';
import { listStories } from './list-stories';

import type { ExtendedOptions } from './types';
Expand Down Expand Up @@ -113,11 +115,16 @@ export async function getOptimizeDeps(config: ViteInlineConfig, options: Extende
const resolve = resolvedConfig.createResolver({ asSrc: false });
const include = await asyncFilter(INCLUDE_CANDIDATES, async (id) => Boolean(await resolve(id)));

return {
const optimizeDeps: UserConfig['optimizeDeps'] = {
// We don't need to resolve the glob since vite supports globs for entries.
entries: stories,
// We need Vite to precompile these dependencies, because they contain non-ESM code that would break
// if we served it directly to the browser.
include,
esbuildOptions: {
plugins: [globalExternals(definitions)],
},
};

return optimizeDeps;
}
Loading