Skip to content

Commit 0c945e5

Browse files
committed
Fix .storybook/main PnP workaround for ESM env
1 parent cff3d27 commit 0c945e5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/_snippets/storybook-main-pnpm-with-module-resolution.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import path from 'path';
33

44
const getAbsolutePath = (packageName) =>
5-
path.dirname(require.resolve(path.join(packageName, 'package.json')));
5+
path
6+
.dirname(import.meta.resolve(path.join(packageName, 'package.json')))
7+
.replace(/^file:\/\//, '');
68

79
export default {
810
framework: {
@@ -25,7 +27,9 @@ import type { StorybookConfig } from '@storybook/your-framework';
2527
import path from 'path';
2628

2729
const getAbsolutePath = (packageName: string): any =>
28-
path.dirname(require.resolve(path.join(packageName, 'package.json')));
30+
path
31+
.dirname(import.meta.resolve(path.join(packageName, 'package.json')))
32+
.replace(/^file:\/\//, '');
2933

3034
const config: StorybookConfig = {
3135
framework: {

0 commit comments

Comments
 (0)