Skip to content

Commit

Permalink
Ensure esm module loader is used to import vite
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed May 2, 2024
1 parent c1a2a84 commit 2153609
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-queens-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chialab/storybook-dna-vite": patch
---

Ensure esm module loader is used to import vite.
8 changes: 5 additions & 3 deletions packages/storybook-dna-vite/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { dnaPlugins } from '@chialab/manifest-analyzer-dna-plugin';
import { hmrPlugin } from '@chialab/vite-plugin-hmr-dna';
import type { PresetProperty } from '@storybook/types';
import remarkGfm from 'remark-gfm';
import { mergeConfig } from 'vite';
import customElementsManifestPlugin from './plugins/CustomElementsManifest';
import type { StorybookConfig } from './types';

Expand All @@ -17,8 +16,10 @@ export const mdxLoaderOptions = {
},
};

export const viteFinal: StorybookConfig['viteFinal'] = async (config) =>
mergeConfig(config, {
export const viteFinal: StorybookConfig['viteFinal'] = async (config) => {
const { mergeConfig } = await import('vite');

return mergeConfig(config, {
optimizeDeps: {
exclude: ['@chialab/storybook-dna'],
include: ['@storybook/docs-tools', '@storybook/preview-api', 'ts-dedent'],
Expand All @@ -31,3 +32,4 @@ export const viteFinal: StorybookConfig['viteFinal'] = async (config) =>
}),
],
});
};

0 comments on commit 2153609

Please sign in to comment.