vite-plugin-storybook-nextjs 3.0.0 → 4.0.0--canary.66.79fff46.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/dist/index.cjs CHANGED
@@ -2910,6 +2910,15 @@ var loadConfig = (
2910
2910
  // biome-ignore lint/suspicious/noExplicitAny: CJS support
2911
2911
  nextServerConfig__default.default.default || nextServerConfig__default.default
2912
2912
  );
2913
+ var getNextjsMajorVersion = () => {
2914
+ try {
2915
+ const content = fs3.readFileSync(require8.resolve("next/package.json"), "utf8");
2916
+ const { version } = JSON.parse(content);
2917
+ return Number.parseInt(version.split(".")[0], 10);
2918
+ } catch (error) {
2919
+ return 16;
2920
+ }
2921
+ };
2913
2922
  function VitePlugin({
2914
2923
  dir = process.cwd()
2915
2924
  } = {}) {
@@ -2922,6 +2931,7 @@ function VitePlugin({
2922
2931
  enforce: "pre",
2923
2932
  async config(config, env) {
2924
2933
  const phase = env.mode === "development" ? constants_js.PHASE_DEVELOPMENT_SERVER : env.mode === "test" ? constants_js.PHASE_TEST : constants_js.PHASE_PRODUCTION_BUILD;
2934
+ const isNext16orNewer = getNextjsMajorVersion() >= 16;
2925
2935
  nextConfigResolver.resolve(await loadConfig(phase, resolvedDir));
2926
2936
  const executionEnvironment = getExecutionEnvironment(config);
2927
2937
  return {
@@ -2984,7 +2994,6 @@ function VitePlugin({
2984
2994
  "next/dist/client/components/redirect-boundary",
2985
2995
  "next/dist/client/head-manager",
2986
2996
  "next/dist/client/components/is-next-router-error",
2987
- "next/config",
2988
2997
  "next/dist/shared/lib/segment",
2989
2998
  "styled-jsx",
2990
2999
  "styled-jsx/style",
@@ -2998,7 +3007,7 @@ function VitePlugin({
2998
3007
  // Refer to this pnpm issue for more details:
2999
3008
  // https://github.com/vitejs/vite/issues/16293
3000
3009
  "next > styled-jsx/style"
3001
- ]
3010
+ ].concat(!isNext16orNewer ? ["next/config"] : [])
3002
3011
  },
3003
3012
  test: {
3004
3013
  alias: {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import path2, { resolve, join, sep } from 'path';
2
2
  import { createRequire } from 'module';
3
3
  import tsconfigPaths from 'vite-tsconfig-paths';
4
- import fs3 from 'fs';
4
+ import fs3, { readFileSync } from 'fs';
5
5
  import * as nextEnv from '@next/env';
6
6
  import Log from 'next/dist/build/output/log.js';
7
7
  import { transform, loadBindings, lockfilePatchPromise } from 'next/dist/build/swc/index.js';
@@ -2876,6 +2876,15 @@ var loadConfig = (
2876
2876
  // biome-ignore lint/suspicious/noExplicitAny: CJS support
2877
2877
  nextServerConfig.default || nextServerConfig
2878
2878
  );
2879
+ var getNextjsMajorVersion = () => {
2880
+ try {
2881
+ const content = readFileSync(require8.resolve("next/package.json"), "utf8");
2882
+ const { version } = JSON.parse(content);
2883
+ return Number.parseInt(version.split(".")[0], 10);
2884
+ } catch (error) {
2885
+ return 16;
2886
+ }
2887
+ };
2879
2888
  function VitePlugin({
2880
2889
  dir = process.cwd()
2881
2890
  } = {}) {
@@ -2888,6 +2897,7 @@ function VitePlugin({
2888
2897
  enforce: "pre",
2889
2898
  async config(config, env) {
2890
2899
  const phase = env.mode === "development" ? PHASE_DEVELOPMENT_SERVER : env.mode === "test" ? PHASE_TEST : PHASE_PRODUCTION_BUILD;
2900
+ const isNext16orNewer = getNextjsMajorVersion() >= 16;
2891
2901
  nextConfigResolver.resolve(await loadConfig(phase, resolvedDir));
2892
2902
  const executionEnvironment = getExecutionEnvironment(config);
2893
2903
  return {
@@ -2950,7 +2960,6 @@ function VitePlugin({
2950
2960
  "next/dist/client/components/redirect-boundary",
2951
2961
  "next/dist/client/head-manager",
2952
2962
  "next/dist/client/components/is-next-router-error",
2953
- "next/config",
2954
2963
  "next/dist/shared/lib/segment",
2955
2964
  "styled-jsx",
2956
2965
  "styled-jsx/style",
@@ -2964,7 +2973,7 @@ function VitePlugin({
2964
2973
  // Refer to this pnpm issue for more details:
2965
2974
  // https://github.com/vitejs/vite/issues/16293
2966
2975
  "next > styled-jsx/style"
2967
- ]
2976
+ ].concat(!isNext16orNewer ? ["next/config"] : [])
2968
2977
  },
2969
2978
  test: {
2970
2979
  alias: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-storybook-nextjs",
3
- "version": "3.0.0",
3
+ "version": "4.0.0--canary.66.79fff46.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vite-plugin",