vite-plugin-storybook-nextjs 2.0.0--canary.33.7b6eedb.0 → 2.0.0--canary.33.4ab8644.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
@@ -23,9 +23,8 @@ var options_js = require('next/dist/build/swc/options.js');
23
23
  var nextServerConfig = require('next/dist/server/config.js');
24
24
  var constants_js = require('next/dist/shared/lib/constants.js');
25
25
  var MagicString = require('magic-string');
26
- var os = require('os');
27
26
  var querystring = require('querystring');
28
- var imageSizeOf = require('image-size');
27
+ var imageSize = require('image-size');
29
28
 
30
29
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
31
30
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -57,7 +56,6 @@ var loaderUtils__default = /*#__PURE__*/_interopDefault(loaderUtils);
57
56
  var nextLoadJsConfig__default = /*#__PURE__*/_interopDefault(nextLoadJsConfig);
58
57
  var nextServerConfig__default = /*#__PURE__*/_interopDefault(nextServerConfig);
59
58
  var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
60
- var imageSizeOf__default = /*#__PURE__*/_interopDefault(imageSizeOf);
61
59
 
62
60
  var __create = Object.create;
63
61
  var __defProp = Object.defineProperty;
@@ -2691,19 +2689,7 @@ var excludeImporterPattern = /\.(css|scss|sass)$/;
2691
2689
  var virtualImage = "virtual:next-image";
2692
2690
  var virtualNextImage = "virtual:next/image";
2693
2691
  var virtualNextLegacyImage = "virtual:next/legacy/image";
2694
- var sharp;
2695
2692
  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)));
2696
- try {
2697
- sharp = require4("sharp");
2698
- if (sharp && sharp.concurrency() > 1) {
2699
- const divisor = process.env.NODE_ENV === "development" ? 4 : 2;
2700
- sharp.concurrency(Math.floor(Math.max(os.cpus().length / divisor, 1)));
2701
- }
2702
- } catch (e) {
2703
- console.warn(
2704
- "You have to install sharp in order to use image optimization features in Next.js. AVIF support is also disabled."
2705
- );
2706
- }
2707
2693
  function vitePluginNextImage(nextConfigResolver) {
2708
2694
  let isBrowser = !isVitestEnv;
2709
2695
  return {
@@ -2755,7 +2741,6 @@ function vitePluginNextImage(nextConfigResolver) {
2755
2741
  if (virtualImage === source) {
2756
2742
  const imagePath = querystring.decode(query).imagePath;
2757
2743
  const nextConfig = await nextConfigResolver.promise;
2758
- const extension = path2__default.default.extname(imagePath);
2759
2744
  try {
2760
2745
  if (nextConfig.images?.disableStaticImages) {
2761
2746
  return tsDedent.dedent`
@@ -2764,18 +2749,7 @@ function vitePluginNextImage(nextConfigResolver) {
2764
2749
  `;
2765
2750
  }
2766
2751
  const imageData = await fs3__default.default.promises.readFile(imagePath);
2767
- let width;
2768
- let height;
2769
- if (extension === ".avif" && sharp) {
2770
- const transformer = sharp(Buffer.from(imageData));
2771
- const result = await transformer.metadata();
2772
- width = result.width;
2773
- height = result.height;
2774
- } else {
2775
- const result = imageSizeOf__default.default(imageData);
2776
- width = result.width;
2777
- height = result.height;
2778
- }
2752
+ const { width, height } = imageSize.imageSize(imageData);
2779
2753
  return tsDedent.dedent`
2780
2754
  import src from "${imagePath}?ignore";
2781
2755
  export default {
@@ -2897,6 +2871,13 @@ var loadConfig = (
2897
2871
  function VitePlugin({ dir = process.cwd() } = {}) {
2898
2872
  const resolvedDir = path2.resolve(dir);
2899
2873
  const nextConfigResolver = Promise.withResolvers();
2874
+ let styledJsxIsInstalled;
2875
+ try {
2876
+ require8.resolve("styled-jsx");
2877
+ styledJsxIsInstalled = true;
2878
+ } catch (e) {
2879
+ styledJsxIsInstalled = false;
2880
+ }
2900
2881
  return [
2901
2882
  {
2902
2883
  name: "vite-plugin-storybook-nextjs",
@@ -2913,6 +2894,24 @@ function VitePlugin({ dir = process.cwd() } = {}) {
2913
2894
  find: /^react$/,
2914
2895
  replacement: require8.resolve("next/dist/compiled/react")
2915
2896
  },
2897
+ {
2898
+ find: /^react\/jsx-runtime$/,
2899
+ replacement: require8.resolve(
2900
+ "next/dist/compiled/react/jsx-runtime"
2901
+ )
2902
+ },
2903
+ {
2904
+ find: /^react\/jsx-dev-runtime$/,
2905
+ replacement: require8.resolve(
2906
+ "next/dist/compiled/react/jsx-dev-runtime"
2907
+ )
2908
+ },
2909
+ {
2910
+ find: /^react\/compiler-runtime$/,
2911
+ replacement: require8.resolve(
2912
+ "next/dist/compiled/react/compiler-runtime"
2913
+ )
2914
+ },
2916
2915
  {
2917
2916
  find: /^react-dom$/,
2918
2917
  replacement: require8.resolve("next/dist/compiled/react-dom")
@@ -2952,7 +2951,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
2952
2951
  "next/image",
2953
2952
  "next/legacy/image",
2954
2953
  "react/jsx-dev-runtime",
2955
- "styled-jsx/style"
2954
+ ...styledJsxIsInstalled ? ["styled-jsx/style"] : []
2956
2955
  ]
2957
2956
  },
2958
2957
  test: {
package/dist/index.js CHANGED
@@ -21,9 +21,8 @@ import { getParserOptions } from 'next/dist/build/swc/options.js';
21
21
  import nextServerConfig from 'next/dist/server/config.js';
22
22
  import { PHASE_DEVELOPMENT_SERVER, PHASE_TEST, PHASE_PRODUCTION_BUILD } from 'next/dist/shared/lib/constants.js';
23
23
  import MagicString from 'magic-string';
24
- import { cpus } from 'node:os';
25
24
  import { decode } from 'node:querystring';
26
- import imageSizeOf from 'image-size';
25
+ import { imageSize } from 'image-size';
27
26
 
28
27
  var __create = Object.create;
29
28
  var __defProp = Object.defineProperty;
@@ -2657,19 +2656,7 @@ var excludeImporterPattern = /\.(css|scss|sass)$/;
2657
2656
  var virtualImage = "virtual:next-image";
2658
2657
  var virtualNextImage = "virtual:next/image";
2659
2658
  var virtualNextLegacyImage = "virtual:next/legacy/image";
2660
- var sharp;
2661
2659
  var require4 = createRequire(import.meta.url);
2662
- try {
2663
- sharp = require4("sharp");
2664
- if (sharp && sharp.concurrency() > 1) {
2665
- const divisor = process.env.NODE_ENV === "development" ? 4 : 2;
2666
- sharp.concurrency(Math.floor(Math.max(cpus().length / divisor, 1)));
2667
- }
2668
- } catch (e) {
2669
- console.warn(
2670
- "You have to install sharp in order to use image optimization features in Next.js. AVIF support is also disabled."
2671
- );
2672
- }
2673
2660
  function vitePluginNextImage(nextConfigResolver) {
2674
2661
  let isBrowser = !isVitestEnv;
2675
2662
  return {
@@ -2721,7 +2708,6 @@ function vitePluginNextImage(nextConfigResolver) {
2721
2708
  if (virtualImage === source) {
2722
2709
  const imagePath = decode(query).imagePath;
2723
2710
  const nextConfig = await nextConfigResolver.promise;
2724
- const extension = path2.extname(imagePath);
2725
2711
  try {
2726
2712
  if (nextConfig.images?.disableStaticImages) {
2727
2713
  return dedent`
@@ -2730,18 +2716,7 @@ function vitePluginNextImage(nextConfigResolver) {
2730
2716
  `;
2731
2717
  }
2732
2718
  const imageData = await fs3.promises.readFile(imagePath);
2733
- let width;
2734
- let height;
2735
- if (extension === ".avif" && sharp) {
2736
- const transformer = sharp(Buffer.from(imageData));
2737
- const result = await transformer.metadata();
2738
- width = result.width;
2739
- height = result.height;
2740
- } else {
2741
- const result = imageSizeOf(imageData);
2742
- width = result.width;
2743
- height = result.height;
2744
- }
2719
+ const { width, height } = imageSize(imageData);
2745
2720
  return dedent`
2746
2721
  import src from "${imagePath}?ignore";
2747
2722
  export default {
@@ -2863,6 +2838,13 @@ var loadConfig = (
2863
2838
  function VitePlugin({ dir = process.cwd() } = {}) {
2864
2839
  const resolvedDir = resolve(dir);
2865
2840
  const nextConfigResolver = Promise.withResolvers();
2841
+ let styledJsxIsInstalled;
2842
+ try {
2843
+ require8.resolve("styled-jsx");
2844
+ styledJsxIsInstalled = true;
2845
+ } catch (e) {
2846
+ styledJsxIsInstalled = false;
2847
+ }
2866
2848
  return [
2867
2849
  {
2868
2850
  name: "vite-plugin-storybook-nextjs",
@@ -2879,6 +2861,24 @@ function VitePlugin({ dir = process.cwd() } = {}) {
2879
2861
  find: /^react$/,
2880
2862
  replacement: require8.resolve("next/dist/compiled/react")
2881
2863
  },
2864
+ {
2865
+ find: /^react\/jsx-runtime$/,
2866
+ replacement: require8.resolve(
2867
+ "next/dist/compiled/react/jsx-runtime"
2868
+ )
2869
+ },
2870
+ {
2871
+ find: /^react\/jsx-dev-runtime$/,
2872
+ replacement: require8.resolve(
2873
+ "next/dist/compiled/react/jsx-dev-runtime"
2874
+ )
2875
+ },
2876
+ {
2877
+ find: /^react\/compiler-runtime$/,
2878
+ replacement: require8.resolve(
2879
+ "next/dist/compiled/react/compiler-runtime"
2880
+ )
2881
+ },
2882
2882
  {
2883
2883
  find: /^react-dom$/,
2884
2884
  replacement: require8.resolve("next/dist/compiled/react-dom")
@@ -2918,7 +2918,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
2918
2918
  "next/image",
2919
2919
  "next/legacy/image",
2920
2920
  "react/jsx-dev-runtime",
2921
- "styled-jsx/style"
2921
+ ...styledJsxIsInstalled ? ["styled-jsx/style"] : []
2922
2922
  ]
2923
2923
  },
2924
2924
  test: {
@@ -2,7 +2,7 @@ import * as next_dist_shared_lib_get_img_props from 'next/dist/shared/lib/get-im
2
2
  import * as _NextImage from 'next/image';
3
3
  import React__default from 'next/dist/compiled/react';
4
4
 
5
- declare const MockedNextImage: React__default.ForwardRefExoticComponent<Omit<React__default.DetailedHTMLProps<React__default.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "srcSet" | "ref" | "alt" | "width" | "height" | "loading"> & {
5
+ declare const MockedNextImage: React__default.ForwardRefExoticComponent<Omit<React__default.DetailedHTMLProps<React__default.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "width" | "srcSet" | "ref" | "alt" | "height" | "loading"> & {
6
6
  src: string | next_dist_shared_lib_get_img_props.StaticImport;
7
7
  alt: string;
8
8
  width?: number | `${number}`;
@@ -2,7 +2,7 @@ import * as next_dist_shared_lib_get_img_props from 'next/dist/shared/lib/get-im
2
2
  import * as _NextImage from 'next/image';
3
3
  import React__default from 'next/dist/compiled/react';
4
4
 
5
- declare const MockedNextImage: React__default.ForwardRefExoticComponent<Omit<React__default.DetailedHTMLProps<React__default.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "srcSet" | "ref" | "alt" | "width" | "height" | "loading"> & {
5
+ declare const MockedNextImage: React__default.ForwardRefExoticComponent<Omit<React__default.DetailedHTMLProps<React__default.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "width" | "srcSet" | "ref" | "alt" | "height" | "loading"> & {
6
6
  src: string | next_dist_shared_lib_get_img_props.StaticImport;
7
7
  alt: string;
8
8
  width?: number | `${number}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-storybook-nextjs",
3
- "version": "2.0.0--canary.33.7b6eedb.0",
3
+ "version": "2.0.0--canary.33.4ab8644.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vite-plugin",
@@ -76,7 +76,6 @@
76
76
  "react": "19.0.0-rc-66855b96-20241106",
77
77
  "rollup": "^4.18.0",
78
78
  "semver": "^7.6.3",
79
- "sharp": "^0.33.4",
80
79
  "storybook": "0.0.0-pr-30742-sha-cd7cb3d8",
81
80
  "tsup": "^8.1.0",
82
81
  "typescript": "^5.0.0",
@@ -86,14 +85,11 @@
86
85
  "packageManager": "pnpm@9.4.0",
87
86
  "dependencies": {
88
87
  "@next/env": "^15.0.3",
89
- "image-size": "^1.1.1",
88
+ "image-size": "^2.0.0",
90
89
  "magic-string": "^0.30.11",
91
90
  "module-alias": "^2.2.3",
92
91
  "ts-dedent": "^2.2.0"
93
92
  },
94
- "optionalDependencies": {
95
- "sharp": "^0.33.4"
96
- },
97
93
  "publishConfig": {
98
94
  "access": "public"
99
95
  },