vite-plugin-storybook-nextjs 1.0.5 → 1.0.7

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
@@ -4,7 +4,7 @@ var path = require('path');
4
4
  var module$1 = require('module');
5
5
  var defineEnvPlugin_js = require('next/dist/build/webpack/plugins/define-env-plugin.js');
6
6
  var fs3 = require('fs');
7
- var env = require('@next/env');
7
+ var nextEnv = require('@next/env');
8
8
  var Log = require('next/dist/build/output/log.js');
9
9
  var index_js = require('next/dist/build/swc/index.js');
10
10
  var fs2 = require('fs/promises');
@@ -15,12 +15,12 @@ var validateGoogleFontFunctionCall_js = require('next/dist/compiled/@next/font/d
15
15
  var loaderUtils = require('next/dist/compiled/loader-utils3/index.js');
16
16
  var validateLocalFontFunctionCall_js = require('next/dist/compiled/@next/font/dist/local/validate-local-font-function-call.js');
17
17
  var tsDedent = require('ts-dedent');
18
- var loadJsConfig = require('next/dist/build/load-jsconfig.js');
18
+ var nextLoadJsConfig = require('next/dist/build/load-jsconfig.js');
19
19
  var findPagesDir_js = require('next/dist/lib/find-pages-dir.js');
20
20
  var vite = require('vite');
21
21
  var utils_js = require('next/dist/build/utils.js');
22
22
  var options_js = require('next/dist/build/swc/options.js');
23
- var loadConfig = require('next/dist/server/config.js');
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
26
  var os = require('os');
@@ -30,20 +30,40 @@ var imageSizeOf = require('image-size');
30
30
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
31
31
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
32
32
 
33
+ function _interopNamespace(e) {
34
+ if (e && e.__esModule) return e;
35
+ var n = Object.create(null);
36
+ if (e) {
37
+ Object.keys(e).forEach(function (k) {
38
+ if (k !== 'default') {
39
+ var d = Object.getOwnPropertyDescriptor(e, k);
40
+ Object.defineProperty(n, k, d.get ? d : {
41
+ enumerable: true,
42
+ get: function () { return e[k]; }
43
+ });
44
+ }
45
+ });
46
+ }
47
+ n.default = e;
48
+ return Object.freeze(n);
49
+ }
50
+
33
51
  var path__default = /*#__PURE__*/_interopDefault(path);
34
52
  var fs3__default = /*#__PURE__*/_interopDefault(fs3);
53
+ var nextEnv__namespace = /*#__PURE__*/_interopNamespace(nextEnv);
35
54
  var Log__default = /*#__PURE__*/_interopDefault(Log);
36
55
  var fs2__default = /*#__PURE__*/_interopDefault(fs2);
37
56
  var loaderUtils__default = /*#__PURE__*/_interopDefault(loaderUtils);
38
- var loadJsConfig__default = /*#__PURE__*/_interopDefault(loadJsConfig);
39
- var loadConfig__default = /*#__PURE__*/_interopDefault(loadConfig);
57
+ var nextLoadJsConfig__default = /*#__PURE__*/_interopDefault(nextLoadJsConfig);
58
+ var nextServerConfig__default = /*#__PURE__*/_interopDefault(nextServerConfig);
40
59
  var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
41
60
  var imageSizeOf__default = /*#__PURE__*/_interopDefault(imageSizeOf);
42
61
 
43
62
  // src/index.ts
44
63
  var nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
64
+ var { loadEnvConfig } = nextEnv__namespace.default || nextEnv__namespace;
45
65
  async function loadEnvironmentConfig(dir, dev) {
46
- return env.loadEnvConfig(dir, dev, Log__default.default);
66
+ return loadEnvConfig(dir, dev, Log__default.default);
47
67
  }
48
68
  async function loadSWCBindingsEagerly(nextConfig) {
49
69
  await index_js.loadBindings(nextConfig?.experimental?.useWasmBinary);
@@ -472,7 +492,7 @@ function getBaseSWCOptions({
472
492
  esm,
473
493
  modularizeImports,
474
494
  swcPlugins,
475
- compilerOptions,
495
+ compiler,
476
496
  resolvedBaseUrl,
477
497
  jsConfig,
478
498
  swcCacheDir
@@ -508,7 +528,7 @@ function getBaseSWCOptions({
508
528
  decoratorMetadata: emitDecoratorMetadata,
509
529
  useDefineForClassFields,
510
530
  react: {
511
- importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (compilerOptions?.emotion ? "@emotion/react" : "react"),
531
+ importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (compiler?.emotion ? "@emotion/react" : "react"),
512
532
  runtime: "automatic",
513
533
  pragmaFrag: "React.Fragment",
514
534
  throwIfNamespace: true,
@@ -534,7 +554,7 @@ function getBaseSWCOptions({
534
554
  }
535
555
  },
536
556
  sourceMaps: true,
537
- removeConsole: compilerOptions?.removeConsole,
557
+ removeConsole: compiler?.removeConsole,
538
558
  reactRemoveProperties: false,
539
559
  // Map the k-v map to an array of pairs.
540
560
  modularizeImports: modularizeImports ? Object.fromEntries(
@@ -549,14 +569,14 @@ function getBaseSWCOptions({
549
569
  }
550
570
  ])
551
571
  ) : void 0,
552
- relay: compilerOptions?.relay,
572
+ relay: compiler?.relay,
553
573
  // Always transform styled-jsx and error when `client-only` condition is triggered
554
574
  styledJsx: {},
555
575
  // Disable css-in-js libs (without client-only integration) transform on server layer for server components
556
- emotion: getEmotionOptions(compilerOptions?.emotion, development),
576
+ emotion: getEmotionOptions(compiler?.emotion, development),
557
577
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
558
578
  styledComponents: getStyledComponentsOptions(
559
- compilerOptions?.styledComponents,
579
+ compiler?.styledComponents,
560
580
  development
561
581
  ),
562
582
  serverComponents: void 0,
@@ -588,7 +608,7 @@ var getVitestSWCTransformConfig = ({
588
608
  jsConfig: loadedJSConfig.jsConfig,
589
609
  resolvedBaseUrl: loadedJSConfig.resolvedBaseUrl,
590
610
  swcPlugins: nextConfig.experimental.swcPlugins,
591
- compilerOptions: nextConfig?.compilerOptions,
611
+ compiler: nextConfig?.compiler,
592
612
  esm: isEsmProject,
593
613
  swcCacheDir: path__default.default.join(
594
614
  rootDir,
@@ -652,6 +672,10 @@ var isDefined = (value) => value !== void 0;
652
672
  // src/plugins/next-swc/plugin.ts
653
673
  var excluded = /[\\/]((cache[\\/][^\\/]+\.zip[\\/])|virtual:)[\\/]/;
654
674
  var included = /\.((c|m)?(j|t)sx?)$/;
675
+ var loadJsConfig = (
676
+ // biome-ignore lint/suspicious/noExplicitAny: CJS support
677
+ nextLoadJsConfig__default.default.default || nextLoadJsConfig__default.default
678
+ );
655
679
  function vitePluginNextSwc(rootDir, nextConfigResolver) {
656
680
  let loadedJSConfig;
657
681
  let nextDirectories;
@@ -666,7 +690,7 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
666
690
  async config(config, env) {
667
691
  const nextConfig = await nextConfigResolver.promise;
668
692
  nextDirectories = findPagesDir_js.findPagesDir(resolvedDir);
669
- loadedJSConfig = await loadJsConfig__default.default(resolvedDir, nextConfig);
693
+ loadedJSConfig = await loadJsConfig(resolvedDir, nextConfig);
670
694
  isDev = env.mode !== "production";
671
695
  await loadClosestPackageJson(resolvedDir);
672
696
  isEsmProject = true;
@@ -920,6 +944,10 @@ var vitePluginNextMocks = () => ({
920
944
 
921
945
  // src/index.ts
922
946
  var require6 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
947
+ var loadConfig = (
948
+ // biome-ignore lint/suspicious/noExplicitAny: CJS support
949
+ nextServerConfig__default.default.default || nextServerConfig__default.default
950
+ );
923
951
  function VitePlugin({ dir = process.cwd() } = {}) {
924
952
  const resolvedDir = path.resolve(dir);
925
953
  const nextConfigResolver = Promise.withResolvers();
@@ -929,7 +957,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
929
957
  enforce: "pre",
930
958
  async config(config, env) {
931
959
  const phase = env.mode === "development" ? constants_js.PHASE_DEVELOPMENT_SERVER : env.mode === "test" ? constants_js.PHASE_TEST : constants_js.PHASE_PRODUCTION_BUILD;
932
- nextConfigResolver.resolve(await loadConfig__default.default(phase, resolvedDir));
960
+ nextConfigResolver.resolve(await loadConfig(phase, resolvedDir));
933
961
  const executionEnvironment = getExecutionEnvironment(config);
934
962
  return {
935
963
  ...!isVitestEnv && {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import path, { resolve, join } from 'node:path';
2
2
  import { createRequire } from 'node:module';
3
3
  import { getDefineEnv } from 'next/dist/build/webpack/plugins/define-env-plugin.js';
4
4
  import fs3 from 'node:fs';
5
- import { loadEnvConfig } from '@next/env';
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';
8
8
  import fs2 from 'node:fs/promises';
@@ -13,12 +13,12 @@ import { validateGoogleFontFunctionCall } from 'next/dist/compiled/@next/font/di
13
13
  import loaderUtils from 'next/dist/compiled/loader-utils3/index.js';
14
14
  import { validateLocalFontFunctionCall } from 'next/dist/compiled/@next/font/dist/local/validate-local-font-function-call.js';
15
15
  import { dedent } from 'ts-dedent';
16
- import loadJsConfig from 'next/dist/build/load-jsconfig.js';
16
+ import nextLoadJsConfig from 'next/dist/build/load-jsconfig.js';
17
17
  import { findPagesDir } from 'next/dist/lib/find-pages-dir.js';
18
18
  import { createFilter } from 'vite';
19
19
  import { getSupportedBrowsers } from 'next/dist/build/utils.js';
20
20
  import { getParserOptions } from 'next/dist/build/swc/options.js';
21
- import loadConfig from 'next/dist/server/config.js';
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
24
  import { cpus } from 'node:os';
@@ -27,6 +27,7 @@ import imageSizeOf from 'image-size';
27
27
 
28
28
  // src/index.ts
29
29
  var nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
30
+ var { loadEnvConfig } = nextEnv.default || nextEnv;
30
31
  async function loadEnvironmentConfig(dir, dev) {
31
32
  return loadEnvConfig(dir, dev, Log);
32
33
  }
@@ -457,7 +458,7 @@ function getBaseSWCOptions({
457
458
  esm,
458
459
  modularizeImports,
459
460
  swcPlugins,
460
- compilerOptions,
461
+ compiler,
461
462
  resolvedBaseUrl,
462
463
  jsConfig,
463
464
  swcCacheDir
@@ -493,7 +494,7 @@ function getBaseSWCOptions({
493
494
  decoratorMetadata: emitDecoratorMetadata,
494
495
  useDefineForClassFields,
495
496
  react: {
496
- importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (compilerOptions?.emotion ? "@emotion/react" : "react"),
497
+ importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (compiler?.emotion ? "@emotion/react" : "react"),
497
498
  runtime: "automatic",
498
499
  pragmaFrag: "React.Fragment",
499
500
  throwIfNamespace: true,
@@ -519,7 +520,7 @@ function getBaseSWCOptions({
519
520
  }
520
521
  },
521
522
  sourceMaps: true,
522
- removeConsole: compilerOptions?.removeConsole,
523
+ removeConsole: compiler?.removeConsole,
523
524
  reactRemoveProperties: false,
524
525
  // Map the k-v map to an array of pairs.
525
526
  modularizeImports: modularizeImports ? Object.fromEntries(
@@ -534,14 +535,14 @@ function getBaseSWCOptions({
534
535
  }
535
536
  ])
536
537
  ) : void 0,
537
- relay: compilerOptions?.relay,
538
+ relay: compiler?.relay,
538
539
  // Always transform styled-jsx and error when `client-only` condition is triggered
539
540
  styledJsx: {},
540
541
  // Disable css-in-js libs (without client-only integration) transform on server layer for server components
541
- emotion: getEmotionOptions(compilerOptions?.emotion, development),
542
+ emotion: getEmotionOptions(compiler?.emotion, development),
542
543
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
543
544
  styledComponents: getStyledComponentsOptions(
544
- compilerOptions?.styledComponents,
545
+ compiler?.styledComponents,
545
546
  development
546
547
  ),
547
548
  serverComponents: void 0,
@@ -573,7 +574,7 @@ var getVitestSWCTransformConfig = ({
573
574
  jsConfig: loadedJSConfig.jsConfig,
574
575
  resolvedBaseUrl: loadedJSConfig.resolvedBaseUrl,
575
576
  swcPlugins: nextConfig.experimental.swcPlugins,
576
- compilerOptions: nextConfig?.compilerOptions,
577
+ compiler: nextConfig?.compiler,
577
578
  esm: isEsmProject,
578
579
  swcCacheDir: path.join(
579
580
  rootDir,
@@ -637,6 +638,10 @@ var isDefined = (value) => value !== void 0;
637
638
  // src/plugins/next-swc/plugin.ts
638
639
  var excluded = /[\\/]((cache[\\/][^\\/]+\.zip[\\/])|virtual:)[\\/]/;
639
640
  var included = /\.((c|m)?(j|t)sx?)$/;
641
+ var loadJsConfig = (
642
+ // biome-ignore lint/suspicious/noExplicitAny: CJS support
643
+ nextLoadJsConfig.default || nextLoadJsConfig
644
+ );
640
645
  function vitePluginNextSwc(rootDir, nextConfigResolver) {
641
646
  let loadedJSConfig;
642
647
  let nextDirectories;
@@ -905,6 +910,10 @@ var vitePluginNextMocks = () => ({
905
910
 
906
911
  // src/index.ts
907
912
  var require6 = createRequire(import.meta.url);
913
+ var loadConfig = (
914
+ // biome-ignore lint/suspicious/noExplicitAny: CJS support
915
+ nextServerConfig.default || nextServerConfig
916
+ );
908
917
  function VitePlugin({ dir = process.cwd() } = {}) {
909
918
  const resolvedDir = resolve(dir);
910
919
  const nextConfigResolver = Promise.withResolvers();
@@ -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.5",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vite-plugin",
@@ -20,8 +20,8 @@
20
20
  "exports": {
21
21
  ".": {
22
22
  "types": "./dist/index.d.ts",
23
- "browser": "./dist/index.js",
24
- "node": "./dist/index.cjs"
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
25
  },
26
26
  "./browser/mocks/cache": "./dist/plugins/next-mocks/alias/cache/index.js",
27
27
  "./browser/mocks/navigation": "./dist/plugins/next-mocks/alias/navigation/index.js",