vite-plugin-storybook-nextjs 1.0.2--canary.10.bf6ac6c.0 → 1.0.2--canary.12.6dea25b.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 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/nextjs-vite`, enabling you to use Storybook with Next.js in a Vite environment.
8
+ - **Storybook Compatibility**: Acts as the foundation for `@storybook/experimental-nextjs-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
- To install the plugin, use your package manager of choice:
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
- ### Setup Vitest
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 vitest configuration
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
 
@@ -46,7 +46,7 @@ export default defineConfig({
46
46
 
47
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
48
 
49
- #### Experimental @storybook/experimental-vitest-plugin
49
+ ### Experimental @storybook/experimental-vitest-plugin
50
50
 
51
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
52
 
@@ -66,37 +66,51 @@ type VitePluginOptions = {
66
66
 
67
67
  ## Limitations and differences to the Webpack5-based integration of Next.js in Storybook
68
68
 
69
- ### next/font staticDir mapping obsolete
69
+ ### `next/font` `staticDir` mapping obsolete
70
70
 
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 build.
71
+ 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
72
 
73
73
  ### CSS/SASS
74
74
 
75
- The `sassOptions` in `next.config.js` is not supported. Please use Vite's configuration options to configure the Sass compiler:
75
+ The `sassOptions` property in `next.config.js` is not supported. Please use Vite's configuration options to configure the Sass compiler:
76
76
 
77
77
  ```js
78
78
  css: {
79
- preprocessorOptions: {
80
- scss: {
81
- quietDeps: true
82
- },
83
- }
79
+ preprocessorOptions: {
80
+ scss: {
81
+ quietDeps: true
82
+ },
83
+ }
84
84
  },
85
85
  ```
86
86
 
87
87
  ### Next.js: Server Actions
88
88
 
89
- When using components that rely on Next.js Server Actions, there are some limitations to be aware of. Specifically, you need to ensure that your story files are set up to use the jsdom environment in Vitest for the case that your default Virtual DOM environment is set to happy-dom. This can be done by adding a special comment at the top of your story files:
89
+ 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
90
 
91
- ```js
92
- // @vitest-environment jsdom
93
- ```
91
+ 1. To apply it to individual story files, add a special comment at the top of each file:
92
+
93
+ ```js
94
+ // @vitest-environment jsdom
95
+ ```
96
+ 2. To apply it to all tests, adjust your Vitest configuration:
97
+
98
+ ```ts
99
+ // vitest.config.ts
100
+ import { defineConfig } from "vite";
101
+ import nextjs from "vite-plugin-storybook-nextjs";
94
102
 
95
- This comment ensures that the components using Next.js Server Actions are properly handled in a jsdom environment, which is necessary for them to function correctly in Vitest.
103
+ export default defineConfig({
104
+ plugins: [nextjs()],
105
+ vitest: {
106
+ environment: "jsdom", // 👈 Add this
107
+ },
108
+ });
109
+ ```
96
110
 
97
111
  ## SWC Mode
98
112
 
99
- Only Next.js in SWC mode is supported. If you were 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 lacking behind).
113
+ 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 lacking behind).
100
114
 
101
115
  ## License
102
116
 
@@ -4,7 +4,7 @@ import { RequestCookies } from 'next/dist/compiled/@edge-runtime/cookies/index.j
4
4
 
5
5
  declare class RequestCookiesMock extends RequestCookies {
6
6
  get: vitest.Mock<[name: string] | [next_dist_compiled__edge_runtime_cookies.RequestCookie], next_dist_compiled__edge_runtime_cookies.RequestCookie | undefined>;
7
- getAll: vitest.Mock<[] | [next_dist_compiled__edge_runtime_cookies.RequestCookie] | [name: string], next_dist_compiled__edge_runtime_cookies.RequestCookie[]>;
7
+ getAll: vitest.Mock<[next_dist_compiled__edge_runtime_cookies.RequestCookie] | [name: string] | [], next_dist_compiled__edge_runtime_cookies.RequestCookie[]>;
8
8
  has: vitest.Mock<[name: string], boolean>;
9
9
  set: vitest.Mock<[key: string, value: string] | [options: next_dist_compiled__edge_runtime_cookies.RequestCookie], this>;
10
10
  delete: vitest.Mock<[names: string | string[]], boolean | boolean[]>;
@@ -4,7 +4,7 @@ import { RequestCookies } from 'next/dist/compiled/@edge-runtime/cookies/index.j
4
4
 
5
5
  declare class RequestCookiesMock extends RequestCookies {
6
6
  get: vitest.Mock<[name: string] | [next_dist_compiled__edge_runtime_cookies.RequestCookie], next_dist_compiled__edge_runtime_cookies.RequestCookie | undefined>;
7
- getAll: vitest.Mock<[] | [next_dist_compiled__edge_runtime_cookies.RequestCookie] | [name: string], next_dist_compiled__edge_runtime_cookies.RequestCookie[]>;
7
+ getAll: vitest.Mock<[next_dist_compiled__edge_runtime_cookies.RequestCookie] | [name: string] | [], next_dist_compiled__edge_runtime_cookies.RequestCookie[]>;
8
8
  has: vitest.Mock<[name: string], boolean>;
9
9
  set: vitest.Mock<[key: string, value: string] | [options: next_dist_compiled__edge_runtime_cookies.RequestCookie], this>;
10
10
  delete: vitest.Mock<[names: string | string[]], boolean | boolean[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-storybook-nextjs",
3
- "version": "1.0.2--canary.10.bf6ac6c.0",
3
+ "version": "1.0.2--canary.12.6dea25b.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vite-plugin",