vite-plugin-storybook-nextjs 4.0.0--canary.66.79fff46.0 → 4.0.0--canary.66.c37ebb8.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
@@ -25,6 +25,7 @@ var constants_js = require('next/dist/shared/lib/constants.js');
25
25
  var MagicString = require('magic-string');
26
26
  var querystring = require('querystring');
27
27
  var imageSize = require('image-size');
28
+ var posix = require('path/posix');
28
29
 
29
30
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
30
31
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -2703,15 +2704,38 @@ var vitePluginNextDynamic = () => ({
2703
2704
  return null;
2704
2705
  }
2705
2706
  });
2706
-
2707
- // src/utils.ts
2707
+ var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
2708
2708
  var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
2709
2709
  var isVitestEnv = process.env.VITEST === "true";
2710
2710
  function getExecutionEnvironment(config) {
2711
2711
  return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
2712
2712
  }
2713
- var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
2714
- var getEntryPoint = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
2713
+ var getNextjsVersion = () => require3(scopedResolve("next/package.json")).version;
2714
+ var scopedResolve = (id) => {
2715
+ let scopedModulePath;
2716
+ try {
2717
+ scopedModulePath = require3.resolve(id, { paths: [posix.resolve()] });
2718
+ } catch (e) {
2719
+ scopedModulePath = require3.resolve(id);
2720
+ }
2721
+ const idWithNativePathSep = id.replace(/\//g, posix.sep);
2722
+ if (scopedModulePath.endsWith(idWithNativePathSep)) {
2723
+ return scopedModulePath;
2724
+ }
2725
+ const moduleFolderStrPosition = scopedModulePath.lastIndexOf(idWithNativePathSep);
2726
+ const beginningOfMainScriptPath = moduleFolderStrPosition + id.length;
2727
+ return scopedModulePath.substring(0, beginningOfMainScriptPath);
2728
+ };
2729
+ var getNextjsMajorVersion = () => {
2730
+ try {
2731
+ const version = getNextjsVersion();
2732
+ return Number.parseInt(version.split(".")[0], 10);
2733
+ } catch (error) {
2734
+ return 16;
2735
+ }
2736
+ };
2737
+ var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
2738
+ var getEntryPoint = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
2715
2739
  var getAlias = (env) => ({
2716
2740
  "sb-original/default-loader": getEntryPoint("image-default-loader", env),
2717
2741
  "sb-original/image-context": getEntryPoint("image-context", env)
@@ -2723,7 +2747,7 @@ var excludeImporterPattern = /\.(css|scss|sass)$/;
2723
2747
  var virtualImage = "virtual:next-image";
2724
2748
  var virtualNextImage = "virtual:next/image";
2725
2749
  var virtualNextLegacyImage = "virtual:next/legacy/image";
2726
- var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
2750
+ var require5 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
2727
2751
  function vitePluginNextImage(nextConfigResolver) {
2728
2752
  let isBrowser = !isVitestEnv;
2729
2753
  return {
@@ -2761,12 +2785,12 @@ function vitePluginNextImage(nextConfigResolver) {
2761
2785
  const aliasEnv = isBrowser ? "browser" : "node";
2762
2786
  if (virtualNextImage === id) {
2763
2787
  return (await fs3__default.default.promises.readFile(
2764
- require4.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
2788
+ require5.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
2765
2789
  )).toString("utf-8");
2766
2790
  }
2767
2791
  if (virtualNextLegacyImage === id) {
2768
2792
  return (await fs3__default.default.promises.readFile(
2769
- require4.resolve(
2793
+ require5.resolve(
2770
2794
  `${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/legacy-image`
2771
2795
  )
2772
2796
  )).toString("utf-8");
@@ -2805,25 +2829,6 @@ function vitePluginNextImage(nextConfigResolver) {
2805
2829
 
2806
2830
  // src/plugins/next-mocks/compatibility/compatibility-map.ts
2807
2831
  var import_semver = __toESM(require_semver2());
2808
- var require5 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
2809
- var getNextjsVersion = () => require5(scopedResolve("next/package.json")).version;
2810
- var scopedResolve = (id) => {
2811
- let scopedModulePath;
2812
- try {
2813
- scopedModulePath = require5.resolve(id, { paths: [path2.resolve()] });
2814
- } catch (e) {
2815
- scopedModulePath = require5.resolve(id);
2816
- }
2817
- const idWithNativePathSep = id.replace(/\//g, path2.sep);
2818
- if (scopedModulePath.endsWith(idWithNativePathSep)) {
2819
- return scopedModulePath;
2820
- }
2821
- const moduleFolderStrPosition = scopedModulePath.lastIndexOf(idWithNativePathSep);
2822
- const beginningOfMainScriptPath = moduleFolderStrPosition + id.length;
2823
- return scopedModulePath.substring(0, beginningOfMainScriptPath);
2824
- };
2825
-
2826
- // src/plugins/next-mocks/compatibility/compatibility-map.ts
2827
2832
  var require6 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
2828
2833
  var getEntryPoint2 = (subPath, env) => require6.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
2829
2834
  var mapping = (env) => ({
@@ -2910,15 +2915,6 @@ var loadConfig = (
2910
2915
  // biome-ignore lint/suspicious/noExplicitAny: CJS support
2911
2916
  nextServerConfig__default.default.default || nextServerConfig__default.default
2912
2917
  );
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
- };
2922
2918
  function VitePlugin({
2923
2919
  dir = process.cwd()
2924
2920
  } = {}) {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import path2, { resolve, join, sep } from 'path';
1
+ import path2, { resolve, join } from 'path';
2
2
  import { createRequire } from 'module';
3
3
  import tsconfigPaths from 'vite-tsconfig-paths';
4
- import fs3, { readFileSync } from 'fs';
4
+ import fs3 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';
@@ -23,6 +23,7 @@ import { PHASE_DEVELOPMENT_SERVER, PHASE_TEST, PHASE_PRODUCTION_BUILD } from 'ne
23
23
  import MagicString from 'magic-string';
24
24
  import { decode } from 'querystring';
25
25
  import { imageSize } from 'image-size';
26
+ import { resolve as resolve$1, sep } from 'path/posix';
26
27
 
27
28
  var __create = Object.create;
28
29
  var __defProp = Object.defineProperty;
@@ -2669,15 +2670,38 @@ var vitePluginNextDynamic = () => ({
2669
2670
  return null;
2670
2671
  }
2671
2672
  });
2672
-
2673
- // src/utils.ts
2673
+ var require3 = createRequire(import.meta.url);
2674
2674
  var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
2675
2675
  var isVitestEnv = process.env.VITEST === "true";
2676
2676
  function getExecutionEnvironment(config) {
2677
2677
  return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
2678
2678
  }
2679
- var require3 = createRequire(import.meta.url);
2680
- var getEntryPoint = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
2679
+ var getNextjsVersion = () => require3(scopedResolve("next/package.json")).version;
2680
+ var scopedResolve = (id) => {
2681
+ let scopedModulePath;
2682
+ try {
2683
+ scopedModulePath = require3.resolve(id, { paths: [resolve$1()] });
2684
+ } catch (e) {
2685
+ scopedModulePath = require3.resolve(id);
2686
+ }
2687
+ const idWithNativePathSep = id.replace(/\//g, sep);
2688
+ if (scopedModulePath.endsWith(idWithNativePathSep)) {
2689
+ return scopedModulePath;
2690
+ }
2691
+ const moduleFolderStrPosition = scopedModulePath.lastIndexOf(idWithNativePathSep);
2692
+ const beginningOfMainScriptPath = moduleFolderStrPosition + id.length;
2693
+ return scopedModulePath.substring(0, beginningOfMainScriptPath);
2694
+ };
2695
+ var getNextjsMajorVersion = () => {
2696
+ try {
2697
+ const version = getNextjsVersion();
2698
+ return Number.parseInt(version.split(".")[0], 10);
2699
+ } catch (error) {
2700
+ return 16;
2701
+ }
2702
+ };
2703
+ var require4 = createRequire(import.meta.url);
2704
+ var getEntryPoint = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
2681
2705
  var getAlias = (env) => ({
2682
2706
  "sb-original/default-loader": getEntryPoint("image-default-loader", env),
2683
2707
  "sb-original/image-context": getEntryPoint("image-context", env)
@@ -2689,7 +2713,7 @@ var excludeImporterPattern = /\.(css|scss|sass)$/;
2689
2713
  var virtualImage = "virtual:next-image";
2690
2714
  var virtualNextImage = "virtual:next/image";
2691
2715
  var virtualNextLegacyImage = "virtual:next/legacy/image";
2692
- var require4 = createRequire(import.meta.url);
2716
+ var require5 = createRequire(import.meta.url);
2693
2717
  function vitePluginNextImage(nextConfigResolver) {
2694
2718
  let isBrowser = !isVitestEnv;
2695
2719
  return {
@@ -2727,12 +2751,12 @@ function vitePluginNextImage(nextConfigResolver) {
2727
2751
  const aliasEnv = isBrowser ? "browser" : "node";
2728
2752
  if (virtualNextImage === id) {
2729
2753
  return (await fs3.promises.readFile(
2730
- require4.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
2754
+ require5.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
2731
2755
  )).toString("utf-8");
2732
2756
  }
2733
2757
  if (virtualNextLegacyImage === id) {
2734
2758
  return (await fs3.promises.readFile(
2735
- require4.resolve(
2759
+ require5.resolve(
2736
2760
  `${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/legacy-image`
2737
2761
  )
2738
2762
  )).toString("utf-8");
@@ -2771,25 +2795,6 @@ function vitePluginNextImage(nextConfigResolver) {
2771
2795
 
2772
2796
  // src/plugins/next-mocks/compatibility/compatibility-map.ts
2773
2797
  var import_semver = __toESM(require_semver2());
2774
- var require5 = createRequire(import.meta.url);
2775
- var getNextjsVersion = () => require5(scopedResolve("next/package.json")).version;
2776
- var scopedResolve = (id) => {
2777
- let scopedModulePath;
2778
- try {
2779
- scopedModulePath = require5.resolve(id, { paths: [resolve()] });
2780
- } catch (e) {
2781
- scopedModulePath = require5.resolve(id);
2782
- }
2783
- const idWithNativePathSep = id.replace(/\//g, sep);
2784
- if (scopedModulePath.endsWith(idWithNativePathSep)) {
2785
- return scopedModulePath;
2786
- }
2787
- const moduleFolderStrPosition = scopedModulePath.lastIndexOf(idWithNativePathSep);
2788
- const beginningOfMainScriptPath = moduleFolderStrPosition + id.length;
2789
- return scopedModulePath.substring(0, beginningOfMainScriptPath);
2790
- };
2791
-
2792
- // src/plugins/next-mocks/compatibility/compatibility-map.ts
2793
2798
  var require6 = createRequire(import.meta.url);
2794
2799
  var getEntryPoint2 = (subPath, env) => require6.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
2795
2800
  var mapping = (env) => ({
@@ -2876,15 +2881,6 @@ var loadConfig = (
2876
2881
  // biome-ignore lint/suspicious/noExplicitAny: CJS support
2877
2882
  nextServerConfig.default || nextServerConfig
2878
2883
  );
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
- };
2888
2884
  function VitePlugin({
2889
2885
  dir = process.cwd()
2890
2886
  } = {}) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  var module$1 = require('module');
4
4
  var moduleAlias = require('module-alias');
5
- var path = require('path');
5
+ var posix = require('path/posix');
6
6
 
7
7
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
8
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -1919,31 +1919,18 @@ var require_semver2 = __commonJS({
1919
1919
  };
1920
1920
  }
1921
1921
  });
1922
-
1923
- // src/utils.ts
1922
+ var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('storybook.global.cjs', document.baseURI).href)));
1924
1923
  var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
1925
1924
  process.env.VITEST === "true";
1926
-
1927
- // src/plugins/next-image/alias/index.tsx
1928
- var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('storybook.global.cjs', document.baseURI).href)));
1929
- var getEntryPoint = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
1930
- var getAlias = (env) => ({
1931
- "sb-original/default-loader": getEntryPoint("image-default-loader", env),
1932
- "sb-original/image-context": getEntryPoint("image-context", env)
1933
- });
1934
-
1935
- // src/plugins/next-mocks/compatibility/compatibility-map.ts
1936
- var import_semver = __toESM(require_semver2());
1937
- var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('storybook.global.cjs', document.baseURI).href)));
1938
- var getNextjsVersion = () => require3(scopedResolve("next/package.json")).version;
1925
+ var getNextjsVersion = () => require2(scopedResolve("next/package.json")).version;
1939
1926
  var scopedResolve = (id) => {
1940
1927
  let scopedModulePath;
1941
1928
  try {
1942
- scopedModulePath = require3.resolve(id, { paths: [path.resolve()] });
1929
+ scopedModulePath = require2.resolve(id, { paths: [posix.resolve()] });
1943
1930
  } catch (e) {
1944
- scopedModulePath = require3.resolve(id);
1931
+ scopedModulePath = require2.resolve(id);
1945
1932
  }
1946
- const idWithNativePathSep = id.replace(/\//g, path.sep);
1933
+ const idWithNativePathSep = id.replace(/\//g, posix.sep);
1947
1934
  if (scopedModulePath.endsWith(idWithNativePathSep)) {
1948
1935
  return scopedModulePath;
1949
1936
  }
@@ -1952,7 +1939,16 @@ var scopedResolve = (id) => {
1952
1939
  return scopedModulePath.substring(0, beginningOfMainScriptPath);
1953
1940
  };
1954
1941
 
1942
+ // src/plugins/next-image/alias/index.tsx
1943
+ var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('storybook.global.cjs', document.baseURI).href)));
1944
+ var getEntryPoint = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
1945
+ var getAlias = (env) => ({
1946
+ "sb-original/default-loader": getEntryPoint("image-default-loader", env),
1947
+ "sb-original/image-context": getEntryPoint("image-context", env)
1948
+ });
1949
+
1955
1950
  // src/plugins/next-mocks/compatibility/compatibility-map.ts
1951
+ var import_semver = __toESM(require_semver2());
1956
1952
  var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('storybook.global.cjs', document.baseURI).href)));
1957
1953
  var getEntryPoint2 = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
1958
1954
  var mapping = (env) => ({
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module';
2
2
  import moduleAlias from 'module-alias';
3
- import { resolve, sep } from 'path';
3
+ import { resolve, sep } from 'path/posix';
4
4
 
5
5
  var __create = Object.create;
6
6
  var __defProp = Object.defineProperty;
@@ -1912,29 +1912,16 @@ var require_semver2 = __commonJS({
1912
1912
  };
1913
1913
  }
1914
1914
  });
1915
-
1916
- // src/utils.ts
1915
+ var require2 = createRequire(import.meta.url);
1917
1916
  var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
1918
1917
  process.env.VITEST === "true";
1919
-
1920
- // src/plugins/next-image/alias/index.tsx
1921
- var require2 = createRequire(import.meta.url);
1922
- var getEntryPoint = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
1923
- var getAlias = (env) => ({
1924
- "sb-original/default-loader": getEntryPoint("image-default-loader", env),
1925
- "sb-original/image-context": getEntryPoint("image-context", env)
1926
- });
1927
-
1928
- // src/plugins/next-mocks/compatibility/compatibility-map.ts
1929
- var import_semver = __toESM(require_semver2());
1930
- var require3 = createRequire(import.meta.url);
1931
- var getNextjsVersion = () => require3(scopedResolve("next/package.json")).version;
1918
+ var getNextjsVersion = () => require2(scopedResolve("next/package.json")).version;
1932
1919
  var scopedResolve = (id) => {
1933
1920
  let scopedModulePath;
1934
1921
  try {
1935
- scopedModulePath = require3.resolve(id, { paths: [resolve()] });
1922
+ scopedModulePath = require2.resolve(id, { paths: [resolve()] });
1936
1923
  } catch (e) {
1937
- scopedModulePath = require3.resolve(id);
1924
+ scopedModulePath = require2.resolve(id);
1938
1925
  }
1939
1926
  const idWithNativePathSep = id.replace(/\//g, sep);
1940
1927
  if (scopedModulePath.endsWith(idWithNativePathSep)) {
@@ -1945,7 +1932,16 @@ var scopedResolve = (id) => {
1945
1932
  return scopedModulePath.substring(0, beginningOfMainScriptPath);
1946
1933
  };
1947
1934
 
1935
+ // src/plugins/next-image/alias/index.tsx
1936
+ var require3 = createRequire(import.meta.url);
1937
+ var getEntryPoint = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
1938
+ var getAlias = (env) => ({
1939
+ "sb-original/default-loader": getEntryPoint("image-default-loader", env),
1940
+ "sb-original/image-context": getEntryPoint("image-context", env)
1941
+ });
1942
+
1948
1943
  // src/plugins/next-mocks/compatibility/compatibility-map.ts
1944
+ var import_semver = __toESM(require_semver2());
1949
1945
  var require4 = createRequire(import.meta.url);
1950
1946
  var getEntryPoint2 = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
1951
1947
  var mapping = (env) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-storybook-nextjs",
3
- "version": "4.0.0--canary.66.79fff46.0",
3
+ "version": "4.0.0--canary.66.c37ebb8.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vite-plugin",