vite-plugin-storybook-nextjs 1.0.4 → 1.0.5--canary.12.68c5675.0
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/README.md +46 -30
- package/dist/index.cjs +25 -19
- package/dist/index.js +25 -19
- package/dist/mocks/storybook.global.cjs +12 -8
- package/dist/mocks/storybook.global.js +12 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ This is a Vite plugin that allows you to use Next.js features in Vite. It is the
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Next.js Integration**: Seamlessly integrate Next.js features into your Vite project.
|
|
8
|
-
- **Storybook Compatibility**: Acts as the foundation for `@storybook/experimental-nextjs-vite
|
|
8
|
+
- **Storybook Compatibility**: Acts as the foundation for [the `@storybook/experimental-nextjs-vite` framework](https://storybook.js.org/docs/get-started/frameworks/nextjs#with-vite), enabling you to use Storybook with Next.js in a Vite environment.
|
|
9
9
|
- **Portable Stories**: Ideal for running portable stories in Vitest, ensuring your components are tested in an environment that closely mirrors production.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Install the plugin using your preferred package manager:
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
npm install vite-plugin-storybook-nextjs
|
|
@@ -22,11 +22,11 @@ pnpm add vite-plugin-storybook-nextjs
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### Set up Vitest
|
|
26
26
|
|
|
27
|
-
To use the plugin, you need to set up Vitest in your project. You can do this by following the instructions in the [Vitest documentation](https://vitest.dev/guide/)
|
|
27
|
+
To use the plugin, you need to set up Vitest in your project. You can do this by following the instructions in the [Vitest documentation](https://vitest.dev/guide/).
|
|
28
28
|
|
|
29
|
-
### Add the plugin to your
|
|
29
|
+
### Add the plugin to your Vitest configuration
|
|
30
30
|
|
|
31
31
|
Add the plugin to your Vitest configuration file. This ensures that Vitest is aware of the Next.js features provided by the plugin.
|
|
32
32
|
|
|
@@ -40,16 +40,6 @@ export default defineConfig({
|
|
|
40
40
|
});
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
### Usage with portable stories
|
|
44
|
-
|
|
45
|
-
[Portable stories](https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest) are Storybook stories which can be used in external environments, such as Vitest.
|
|
46
|
-
|
|
47
|
-
This plugin is necessary to run portable stories in Vitest, as it provides the necessary Next.js features to ensure that your components are tested in an environment that closely mirrors production.
|
|
48
|
-
|
|
49
|
-
#### Experimental @storybook/experimental-vitest-plugin
|
|
50
|
-
|
|
51
|
-
The experimental `@storybook/experimental-vitest-plugin` can be used to automatically transform your stories at Vitest runtime to in-memory test files. This allows you to run your stories in a Vitest environment without needing to manually transform your stories. Please visit https://github.com/storybookjs/vitest-plugin for more information.
|
|
52
|
-
|
|
53
43
|
## Configuration Options
|
|
54
44
|
|
|
55
45
|
You can configure the plugin using the following options:
|
|
@@ -64,39 +54,65 @@ type VitePluginOptions = {
|
|
|
64
54
|
};
|
|
65
55
|
```
|
|
66
56
|
|
|
57
|
+
## Usage with portable stories
|
|
58
|
+
|
|
59
|
+
[Portable stories](https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest) are Storybook stories which can be used in external environments, such as Vitest.
|
|
60
|
+
|
|
61
|
+
This plugin is necessary to run portable stories in Vitest, as it provides the necessary Next.js features to ensure that your components are tested in an environment that closely mirrors production.
|
|
62
|
+
|
|
63
|
+
## Automatic story transformation
|
|
64
|
+
|
|
65
|
+
(⚠️ **Experimental**)
|
|
66
|
+
|
|
67
|
+
The experimental `@storybook/experimental-vitest-plugin` can be used to automatically transform your stories at Vitest runtime to in-memory test files. This allows you to run your stories in a Vitest environment without needing to manually transform your stories. Please visit https://github.com/storybookjs/vitest-plugin for more information.
|
|
68
|
+
|
|
67
69
|
## Limitations and differences to the Webpack5-based integration of Next.js in Storybook
|
|
68
70
|
|
|
69
|
-
### next/font staticDir mapping obsolete
|
|
71
|
+
### `next/font` `staticDir` mapping obsolete
|
|
70
72
|
|
|
71
|
-
You don't need to map your custom font directory in Storybook's staticDir configuration. Vite will automatically serve the files in the public directory and provide assets during production
|
|
73
|
+
You don't need to map your custom font directory in Storybook's `staticDir` configuration. Instead, Vite will automatically serve the files in the `public` directory and provide assets during production builds.
|
|
72
74
|
|
|
73
75
|
### CSS/SASS
|
|
74
76
|
|
|
75
|
-
The `sassOptions` in `next.config.js` is not supported. Please use Vite's configuration options to configure the Sass compiler:
|
|
77
|
+
The `sassOptions` property in `next.config.js` is not supported. Please use Vite's configuration options to configure the Sass compiler:
|
|
76
78
|
|
|
77
79
|
```js
|
|
78
80
|
css: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
preprocessorOptions: {
|
|
82
|
+
scss: {
|
|
83
|
+
quietDeps: true
|
|
84
|
+
},
|
|
85
|
+
}
|
|
84
86
|
},
|
|
85
87
|
```
|
|
86
88
|
|
|
87
89
|
### Next.js: Server Actions
|
|
88
90
|
|
|
89
|
-
When
|
|
91
|
+
When testing components that rely on Next.js Server Actions, you need to ensure that your story files are [set up to use the `jsdom` environment in Vitest](https://vitest.dev/config/#environment). This can be done in two ways:
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
```
|
|
93
|
+
1. To apply it to individual story files, add a special comment at the top of each file:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
// @vitest-environment jsdom
|
|
97
|
+
```
|
|
98
|
+
2. To apply it to all tests, adjust your Vitest configuration:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// vitest.config.ts
|
|
102
|
+
import { defineConfig } from "vite";
|
|
103
|
+
import nextjs from "vite-plugin-storybook-nextjs";
|
|
94
104
|
|
|
95
|
-
|
|
105
|
+
export default defineConfig({
|
|
106
|
+
plugins: [nextjs()],
|
|
107
|
+
vitest: {
|
|
108
|
+
environment: "jsdom", // 👈 Add this
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
```
|
|
96
112
|
|
|
97
|
-
|
|
113
|
+
### SWC Mode
|
|
98
114
|
|
|
99
|
-
Only Next.js in SWC mode is supported. If
|
|
115
|
+
Only [Next.js in SWC mode](https://nextjs.org/docs/architecture/nextjs-compiler) is supported. If your project was forced to opt out of Babel for some reason, you will very likely encounter issues with this plugin (e.g., Emotion support in SWC is still lagging behind).
|
|
100
116
|
|
|
101
117
|
## License
|
|
102
118
|
|
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,12 @@ var loadConfig__default = /*#__PURE__*/_interopDefault(loadConfig);
|
|
|
40
40
|
var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
|
|
41
41
|
var imageSizeOf__default = /*#__PURE__*/_interopDefault(imageSizeOf);
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
44
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
45
|
+
}) : x)(function(x) {
|
|
46
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
47
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
48
|
+
});
|
|
44
49
|
var nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
|
|
45
50
|
async function loadEnvironmentConfig(dir, dev) {
|
|
46
51
|
return env.loadEnvConfig(dir, dev, Log__default.default);
|
|
@@ -753,8 +758,9 @@ var vitePluginNextDynamic = () => ({
|
|
|
753
758
|
// src/utils.ts
|
|
754
759
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
755
760
|
var isVitestEnv = process.env.VITEST === "true";
|
|
756
|
-
|
|
757
|
-
|
|
761
|
+
|
|
762
|
+
// src/plugins/next-image/alias/index.tsx
|
|
763
|
+
var getEntryPoint = (subPath, env) => __require.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
758
764
|
var getAlias = (env) => ({
|
|
759
765
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
760
766
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
@@ -767,9 +773,9 @@ var virtualImage = "virtual:next-image";
|
|
|
767
773
|
var virtualNextImage = "virtual:next/image";
|
|
768
774
|
var virtualNextLegacyImage = "virtual:next/legacy/image";
|
|
769
775
|
var sharp;
|
|
770
|
-
var
|
|
776
|
+
var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
771
777
|
try {
|
|
772
|
-
sharp =
|
|
778
|
+
sharp = require3("sharp");
|
|
773
779
|
if (sharp && sharp.concurrency() > 1) {
|
|
774
780
|
const divisor = process.env.NODE_ENV === "development" ? 4 : 2;
|
|
775
781
|
sharp.concurrency(Math.floor(Math.max(os.cpus().length / divisor, 1)));
|
|
@@ -816,12 +822,12 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
816
822
|
const aliasEnv = isBrowser ? "browser" : "node";
|
|
817
823
|
if (virtualNextImage === id) {
|
|
818
824
|
return (await fs3__default.default.promises.readFile(
|
|
819
|
-
|
|
825
|
+
require3.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
|
|
820
826
|
)).toString("utf-8");
|
|
821
827
|
}
|
|
822
828
|
if (virtualNextLegacyImage === id) {
|
|
823
829
|
return (await fs3__default.default.promises.readFile(
|
|
824
|
-
|
|
830
|
+
require3.resolve(
|
|
825
831
|
`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/legacy-image`
|
|
826
832
|
)
|
|
827
833
|
)).toString("utf-8");
|
|
@@ -869,8 +875,8 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
869
875
|
}
|
|
870
876
|
};
|
|
871
877
|
}
|
|
872
|
-
var
|
|
873
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
878
|
+
var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
879
|
+
var getEntryPoint2 = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
874
880
|
var getAlias2 = (env) => ({
|
|
875
881
|
"next/headers": getEntryPoint2("headers", env),
|
|
876
882
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -898,7 +904,7 @@ var getAlias2 = (env) => ({
|
|
|
898
904
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
899
905
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
900
906
|
"server-only": getEntryPoint2("server-only", env),
|
|
901
|
-
"@opentelemetry/api":
|
|
907
|
+
"@opentelemetry/api": require4.resolve(
|
|
902
908
|
"next/dist/compiled/@opentelemetry/api"
|
|
903
909
|
),
|
|
904
910
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
@@ -916,7 +922,7 @@ var vitePluginNextMocks = () => ({
|
|
|
916
922
|
});
|
|
917
923
|
|
|
918
924
|
// src/index.ts
|
|
919
|
-
var
|
|
925
|
+
var require5 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
920
926
|
function VitePlugin({ dir = process.cwd() } = {}) {
|
|
921
927
|
const resolvedDir = path.resolve(dir);
|
|
922
928
|
const nextConfigResolver = Promise.withResolvers();
|
|
@@ -938,23 +944,23 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
938
944
|
},
|
|
939
945
|
test: {
|
|
940
946
|
alias: {
|
|
941
|
-
"react/jsx-dev-runtime":
|
|
947
|
+
"react/jsx-dev-runtime": require5.resolve(
|
|
942
948
|
"next/dist/compiled/react/jsx-dev-runtime.js"
|
|
943
949
|
),
|
|
944
|
-
"react/jsx-runtime":
|
|
950
|
+
"react/jsx-runtime": require5.resolve(
|
|
945
951
|
"next/dist/compiled/react/jsx-runtime.js"
|
|
946
952
|
),
|
|
947
|
-
react:
|
|
948
|
-
"react-dom/test-utils":
|
|
953
|
+
react: require5.resolve("next/dist/compiled/react"),
|
|
954
|
+
"react-dom/test-utils": require5.resolve(
|
|
949
955
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
950
956
|
),
|
|
951
|
-
"react-dom/cjs/react-dom.development.js":
|
|
957
|
+
"react-dom/cjs/react-dom.development.js": require5.resolve(
|
|
952
958
|
"next/dist/compiled/react-dom/cjs/react-dom.development.js"
|
|
953
959
|
),
|
|
954
|
-
"react-dom/client":
|
|
960
|
+
"react-dom/client": require5.resolve(
|
|
955
961
|
"next/dist/compiled/react-dom/client.js"
|
|
956
962
|
),
|
|
957
|
-
"react-dom":
|
|
963
|
+
"react-dom": require5.resolve("next/dist/compiled/react-dom")
|
|
958
964
|
}
|
|
959
965
|
}
|
|
960
966
|
};
|
|
@@ -962,7 +968,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
962
968
|
configResolved(config) {
|
|
963
969
|
if (!config.test?.browser?.enabled) {
|
|
964
970
|
config.test.setupFiles = [
|
|
965
|
-
|
|
971
|
+
require5.resolve("./mocks/storybook.global.js"),
|
|
966
972
|
...config.test?.setupFiles ?? []
|
|
967
973
|
];
|
|
968
974
|
}
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,12 @@ import { cpus } from 'node:os';
|
|
|
25
25
|
import { decode } from 'node:querystring';
|
|
26
26
|
import imageSizeOf from 'image-size';
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
29
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
30
|
+
}) : x)(function(x) {
|
|
31
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
32
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
33
|
+
});
|
|
29
34
|
var nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
|
|
30
35
|
async function loadEnvironmentConfig(dir, dev) {
|
|
31
36
|
return loadEnvConfig(dir, dev, Log);
|
|
@@ -738,8 +743,9 @@ var vitePluginNextDynamic = () => ({
|
|
|
738
743
|
// src/utils.ts
|
|
739
744
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
740
745
|
var isVitestEnv = process.env.VITEST === "true";
|
|
741
|
-
|
|
742
|
-
|
|
746
|
+
|
|
747
|
+
// src/plugins/next-image/alias/index.tsx
|
|
748
|
+
var getEntryPoint = (subPath, env) => __require.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
743
749
|
var getAlias = (env) => ({
|
|
744
750
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
745
751
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
@@ -752,9 +758,9 @@ var virtualImage = "virtual:next-image";
|
|
|
752
758
|
var virtualNextImage = "virtual:next/image";
|
|
753
759
|
var virtualNextLegacyImage = "virtual:next/legacy/image";
|
|
754
760
|
var sharp;
|
|
755
|
-
var
|
|
761
|
+
var require3 = createRequire(import.meta.url);
|
|
756
762
|
try {
|
|
757
|
-
sharp =
|
|
763
|
+
sharp = require3("sharp");
|
|
758
764
|
if (sharp && sharp.concurrency() > 1) {
|
|
759
765
|
const divisor = process.env.NODE_ENV === "development" ? 4 : 2;
|
|
760
766
|
sharp.concurrency(Math.floor(Math.max(cpus().length / divisor, 1)));
|
|
@@ -801,12 +807,12 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
801
807
|
const aliasEnv = isBrowser ? "browser" : "node";
|
|
802
808
|
if (virtualNextImage === id) {
|
|
803
809
|
return (await fs3.promises.readFile(
|
|
804
|
-
|
|
810
|
+
require3.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
|
|
805
811
|
)).toString("utf-8");
|
|
806
812
|
}
|
|
807
813
|
if (virtualNextLegacyImage === id) {
|
|
808
814
|
return (await fs3.promises.readFile(
|
|
809
|
-
|
|
815
|
+
require3.resolve(
|
|
810
816
|
`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/legacy-image`
|
|
811
817
|
)
|
|
812
818
|
)).toString("utf-8");
|
|
@@ -854,8 +860,8 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
854
860
|
}
|
|
855
861
|
};
|
|
856
862
|
}
|
|
857
|
-
var
|
|
858
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
863
|
+
var require4 = createRequire(import.meta.url);
|
|
864
|
+
var getEntryPoint2 = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
859
865
|
var getAlias2 = (env) => ({
|
|
860
866
|
"next/headers": getEntryPoint2("headers", env),
|
|
861
867
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -883,7 +889,7 @@ var getAlias2 = (env) => ({
|
|
|
883
889
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
884
890
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
885
891
|
"server-only": getEntryPoint2("server-only", env),
|
|
886
|
-
"@opentelemetry/api":
|
|
892
|
+
"@opentelemetry/api": require4.resolve(
|
|
887
893
|
"next/dist/compiled/@opentelemetry/api"
|
|
888
894
|
),
|
|
889
895
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
@@ -901,7 +907,7 @@ var vitePluginNextMocks = () => ({
|
|
|
901
907
|
});
|
|
902
908
|
|
|
903
909
|
// src/index.ts
|
|
904
|
-
var
|
|
910
|
+
var require5 = createRequire(import.meta.url);
|
|
905
911
|
function VitePlugin({ dir = process.cwd() } = {}) {
|
|
906
912
|
const resolvedDir = resolve(dir);
|
|
907
913
|
const nextConfigResolver = Promise.withResolvers();
|
|
@@ -923,23 +929,23 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
923
929
|
},
|
|
924
930
|
test: {
|
|
925
931
|
alias: {
|
|
926
|
-
"react/jsx-dev-runtime":
|
|
932
|
+
"react/jsx-dev-runtime": require5.resolve(
|
|
927
933
|
"next/dist/compiled/react/jsx-dev-runtime.js"
|
|
928
934
|
),
|
|
929
|
-
"react/jsx-runtime":
|
|
935
|
+
"react/jsx-runtime": require5.resolve(
|
|
930
936
|
"next/dist/compiled/react/jsx-runtime.js"
|
|
931
937
|
),
|
|
932
|
-
react:
|
|
933
|
-
"react-dom/test-utils":
|
|
938
|
+
react: require5.resolve("next/dist/compiled/react"),
|
|
939
|
+
"react-dom/test-utils": require5.resolve(
|
|
934
940
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
935
941
|
),
|
|
936
|
-
"react-dom/cjs/react-dom.development.js":
|
|
942
|
+
"react-dom/cjs/react-dom.development.js": require5.resolve(
|
|
937
943
|
"next/dist/compiled/react-dom/cjs/react-dom.development.js"
|
|
938
944
|
),
|
|
939
|
-
"react-dom/client":
|
|
945
|
+
"react-dom/client": require5.resolve(
|
|
940
946
|
"next/dist/compiled/react-dom/client.js"
|
|
941
947
|
),
|
|
942
|
-
"react-dom":
|
|
948
|
+
"react-dom": require5.resolve("next/dist/compiled/react-dom")
|
|
943
949
|
}
|
|
944
950
|
}
|
|
945
951
|
};
|
|
@@ -947,7 +953,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
947
953
|
configResolved(config) {
|
|
948
954
|
if (!config.test?.browser?.enabled) {
|
|
949
955
|
config.test.setupFiles = [
|
|
950
|
-
|
|
956
|
+
require5.resolve("./mocks/storybook.global.js"),
|
|
951
957
|
...config.test?.setupFiles ?? []
|
|
952
958
|
];
|
|
953
959
|
}
|
|
@@ -8,21 +8,25 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
8
8
|
|
|
9
9
|
var moduleAlias__default = /*#__PURE__*/_interopDefault(moduleAlias);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
12
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
|
+
}) : x)(function(x) {
|
|
14
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
+
});
|
|
12
17
|
|
|
13
18
|
// src/utils.ts
|
|
14
19
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
15
20
|
process.env.VITEST === "true";
|
|
16
21
|
|
|
17
22
|
// src/plugins/next-image/alias/index.tsx
|
|
18
|
-
var
|
|
19
|
-
var getEntryPoint = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
23
|
+
var getEntryPoint = (subPath, env) => __require.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
20
24
|
var getAlias = (env) => ({
|
|
21
25
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
22
26
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
23
27
|
});
|
|
24
|
-
var
|
|
25
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
28
|
+
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
29
|
+
var getEntryPoint2 = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
26
30
|
var getAlias2 = (env) => ({
|
|
27
31
|
"next/headers": getEntryPoint2("headers", env),
|
|
28
32
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -50,17 +54,17 @@ var getAlias2 = (env) => ({
|
|
|
50
54
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
51
55
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
52
56
|
"server-only": getEntryPoint2("server-only", env),
|
|
53
|
-
"@opentelemetry/api":
|
|
57
|
+
"@opentelemetry/api": require2.resolve(
|
|
54
58
|
"next/dist/compiled/@opentelemetry/api"
|
|
55
59
|
),
|
|
56
60
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
57
61
|
});
|
|
58
62
|
|
|
59
63
|
// src/mocks/storybook.global.ts
|
|
60
|
-
var
|
|
64
|
+
var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
61
65
|
moduleAlias__default.default.addAliases({
|
|
62
66
|
react: "next/dist/compiled/react",
|
|
63
|
-
"react-dom/test-utils":
|
|
67
|
+
"react-dom/test-utils": require3.resolve(
|
|
64
68
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
65
69
|
),
|
|
66
70
|
"react-dom": "next/dist/compiled/react-dom",
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import moduleAlias from 'module-alias';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
+
});
|
|
5
10
|
|
|
6
11
|
// src/utils.ts
|
|
7
12
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
8
13
|
process.env.VITEST === "true";
|
|
9
14
|
|
|
10
15
|
// src/plugins/next-image/alias/index.tsx
|
|
11
|
-
var
|
|
12
|
-
var getEntryPoint = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
16
|
+
var getEntryPoint = (subPath, env) => __require.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
13
17
|
var getAlias = (env) => ({
|
|
14
18
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
15
19
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
16
20
|
});
|
|
17
|
-
var
|
|
18
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
21
|
+
var require2 = createRequire(import.meta.url);
|
|
22
|
+
var getEntryPoint2 = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
19
23
|
var getAlias2 = (env) => ({
|
|
20
24
|
"next/headers": getEntryPoint2("headers", env),
|
|
21
25
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -43,17 +47,17 @@ var getAlias2 = (env) => ({
|
|
|
43
47
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
44
48
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
45
49
|
"server-only": getEntryPoint2("server-only", env),
|
|
46
|
-
"@opentelemetry/api":
|
|
50
|
+
"@opentelemetry/api": require2.resolve(
|
|
47
51
|
"next/dist/compiled/@opentelemetry/api"
|
|
48
52
|
),
|
|
49
53
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
50
54
|
});
|
|
51
55
|
|
|
52
56
|
// src/mocks/storybook.global.ts
|
|
53
|
-
var
|
|
57
|
+
var require3 = createRequire(import.meta.url);
|
|
54
58
|
moduleAlias.addAliases({
|
|
55
59
|
react: "next/dist/compiled/react",
|
|
56
|
-
"react-dom/test-utils":
|
|
60
|
+
"react-dom/test-utils": require3.resolve(
|
|
57
61
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
58
62
|
),
|
|
59
63
|
"react-dom": "next/dist/compiled/react-dom",
|