vite-plugin-storybook-nextjs 1.0.5--canary.12.68c5675.0 → 1.0.6
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 +35 -34
- package/dist/index.js +35 -34
- package/dist/mocks/storybook.global.cjs +9 -12
- package/dist/mocks/storybook.global.js +9 -12
- package/dist/plugins/next-image/alias/next-image.d.cts +1 -1
- package/dist/plugins/next-image/alias/next-image.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -40,12 +40,7 @@ var loadConfig__default = /*#__PURE__*/_interopDefault(loadConfig);
|
|
|
40
40
|
var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
|
|
41
41
|
var imageSizeOf__default = /*#__PURE__*/_interopDefault(imageSizeOf);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
45
|
-
}) : x)(function(x) {
|
|
46
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
47
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
48
|
-
});
|
|
43
|
+
// src/index.ts
|
|
49
44
|
var nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
|
|
50
45
|
async function loadEnvironmentConfig(dir, dev) {
|
|
51
46
|
return env.loadEnvConfig(dir, dev, Log__default.default);
|
|
@@ -477,7 +472,7 @@ function getBaseSWCOptions({
|
|
|
477
472
|
esm,
|
|
478
473
|
modularizeImports,
|
|
479
474
|
swcPlugins,
|
|
480
|
-
|
|
475
|
+
compiler,
|
|
481
476
|
resolvedBaseUrl,
|
|
482
477
|
jsConfig,
|
|
483
478
|
swcCacheDir
|
|
@@ -513,7 +508,7 @@ function getBaseSWCOptions({
|
|
|
513
508
|
decoratorMetadata: emitDecoratorMetadata,
|
|
514
509
|
useDefineForClassFields,
|
|
515
510
|
react: {
|
|
516
|
-
importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (
|
|
511
|
+
importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (compiler?.emotion ? "@emotion/react" : "react"),
|
|
517
512
|
runtime: "automatic",
|
|
518
513
|
pragmaFrag: "React.Fragment",
|
|
519
514
|
throwIfNamespace: true,
|
|
@@ -539,7 +534,7 @@ function getBaseSWCOptions({
|
|
|
539
534
|
}
|
|
540
535
|
},
|
|
541
536
|
sourceMaps: true,
|
|
542
|
-
removeConsole:
|
|
537
|
+
removeConsole: compiler?.removeConsole,
|
|
543
538
|
reactRemoveProperties: false,
|
|
544
539
|
// Map the k-v map to an array of pairs.
|
|
545
540
|
modularizeImports: modularizeImports ? Object.fromEntries(
|
|
@@ -554,14 +549,14 @@ function getBaseSWCOptions({
|
|
|
554
549
|
}
|
|
555
550
|
])
|
|
556
551
|
) : void 0,
|
|
557
|
-
relay:
|
|
552
|
+
relay: compiler?.relay,
|
|
558
553
|
// Always transform styled-jsx and error when `client-only` condition is triggered
|
|
559
554
|
styledJsx: {},
|
|
560
555
|
// Disable css-in-js libs (without client-only integration) transform on server layer for server components
|
|
561
|
-
emotion: getEmotionOptions(
|
|
556
|
+
emotion: getEmotionOptions(compiler?.emotion, development),
|
|
562
557
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
563
558
|
styledComponents: getStyledComponentsOptions(
|
|
564
|
-
|
|
559
|
+
compiler?.styledComponents,
|
|
565
560
|
development
|
|
566
561
|
),
|
|
567
562
|
serverComponents: void 0,
|
|
@@ -593,7 +588,7 @@ var getVitestSWCTransformConfig = ({
|
|
|
593
588
|
jsConfig: loadedJSConfig.jsConfig,
|
|
594
589
|
resolvedBaseUrl: loadedJSConfig.resolvedBaseUrl,
|
|
595
590
|
swcPlugins: nextConfig.experimental.swcPlugins,
|
|
596
|
-
|
|
591
|
+
compiler: nextConfig?.compiler,
|
|
597
592
|
esm: isEsmProject,
|
|
598
593
|
swcCacheDir: path__default.default.join(
|
|
599
594
|
rootDir,
|
|
@@ -758,9 +753,11 @@ var vitePluginNextDynamic = () => ({
|
|
|
758
753
|
// src/utils.ts
|
|
759
754
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
760
755
|
var isVitestEnv = process.env.VITEST === "true";
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
756
|
+
function getExecutionEnvironment(config) {
|
|
757
|
+
return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
|
|
758
|
+
}
|
|
759
|
+
var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
760
|
+
var getEntryPoint = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
764
761
|
var getAlias = (env) => ({
|
|
765
762
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
766
763
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
@@ -773,9 +770,9 @@ var virtualImage = "virtual:next-image";
|
|
|
773
770
|
var virtualNextImage = "virtual:next/image";
|
|
774
771
|
var virtualNextLegacyImage = "virtual:next/legacy/image";
|
|
775
772
|
var sharp;
|
|
776
|
-
var
|
|
773
|
+
var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
777
774
|
try {
|
|
778
|
-
sharp =
|
|
775
|
+
sharp = require4("sharp");
|
|
779
776
|
if (sharp && sharp.concurrency() > 1) {
|
|
780
777
|
const divisor = process.env.NODE_ENV === "development" ? 4 : 2;
|
|
781
778
|
sharp.concurrency(Math.floor(Math.max(os.cpus().length / divisor, 1)));
|
|
@@ -822,12 +819,12 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
822
819
|
const aliasEnv = isBrowser ? "browser" : "node";
|
|
823
820
|
if (virtualNextImage === id) {
|
|
824
821
|
return (await fs3__default.default.promises.readFile(
|
|
825
|
-
|
|
822
|
+
require4.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
|
|
826
823
|
)).toString("utf-8");
|
|
827
824
|
}
|
|
828
825
|
if (virtualNextLegacyImage === id) {
|
|
829
826
|
return (await fs3__default.default.promises.readFile(
|
|
830
|
-
|
|
827
|
+
require4.resolve(
|
|
831
828
|
`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/legacy-image`
|
|
832
829
|
)
|
|
833
830
|
)).toString("utf-8");
|
|
@@ -875,8 +872,8 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
875
872
|
}
|
|
876
873
|
};
|
|
877
874
|
}
|
|
878
|
-
var
|
|
879
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
875
|
+
var require5 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
876
|
+
var getEntryPoint2 = (subPath, env) => require5.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
880
877
|
var getAlias2 = (env) => ({
|
|
881
878
|
"next/headers": getEntryPoint2("headers", env),
|
|
882
879
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -904,15 +901,15 @@ var getAlias2 = (env) => ({
|
|
|
904
901
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
905
902
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
906
903
|
"server-only": getEntryPoint2("server-only", env),
|
|
907
|
-
"@opentelemetry/api":
|
|
904
|
+
"@opentelemetry/api": require5.resolve(
|
|
908
905
|
"next/dist/compiled/@opentelemetry/api"
|
|
909
906
|
),
|
|
910
907
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
911
908
|
});
|
|
912
909
|
var vitePluginNextMocks = () => ({
|
|
913
910
|
name: "vite-plugin-next-mocks",
|
|
914
|
-
config: (
|
|
915
|
-
const aliasEnv =
|
|
911
|
+
config: (config) => {
|
|
912
|
+
const aliasEnv = getExecutionEnvironment(config);
|
|
916
913
|
return {
|
|
917
914
|
resolve: {
|
|
918
915
|
alias: getAlias2(aliasEnv)
|
|
@@ -922,7 +919,7 @@ var vitePluginNextMocks = () => ({
|
|
|
922
919
|
});
|
|
923
920
|
|
|
924
921
|
// src/index.ts
|
|
925
|
-
var
|
|
922
|
+
var require6 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
926
923
|
function VitePlugin({ dir = process.cwd() } = {}) {
|
|
927
924
|
const resolvedDir = path.resolve(dir);
|
|
928
925
|
const nextConfigResolver = Promise.withResolvers();
|
|
@@ -933,6 +930,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
933
930
|
async config(config, env) {
|
|
934
931
|
const phase = env.mode === "development" ? constants_js.PHASE_DEVELOPMENT_SERVER : env.mode === "test" ? constants_js.PHASE_TEST : constants_js.PHASE_PRODUCTION_BUILD;
|
|
935
932
|
nextConfigResolver.resolve(await loadConfig__default.default(phase, resolvedDir));
|
|
933
|
+
const executionEnvironment = getExecutionEnvironment(config);
|
|
936
934
|
return {
|
|
937
935
|
...!isVitestEnv && {
|
|
938
936
|
resolve: {
|
|
@@ -944,23 +942,26 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
944
942
|
},
|
|
945
943
|
test: {
|
|
946
944
|
alias: {
|
|
947
|
-
"react/jsx-dev-runtime":
|
|
945
|
+
"react/jsx-dev-runtime": require6.resolve(
|
|
948
946
|
"next/dist/compiled/react/jsx-dev-runtime.js"
|
|
949
947
|
),
|
|
950
|
-
"react/jsx-runtime":
|
|
948
|
+
"react/jsx-runtime": require6.resolve(
|
|
951
949
|
"next/dist/compiled/react/jsx-runtime.js"
|
|
952
950
|
),
|
|
953
|
-
react:
|
|
954
|
-
"react-dom/
|
|
951
|
+
react: require6.resolve("next/dist/compiled/react"),
|
|
952
|
+
"react-dom/server": require6.resolve(
|
|
953
|
+
executionEnvironment === "node" ? "next/dist/compiled/react-dom/server.js" : "next/dist/compiled/react-dom/server.browser.js"
|
|
954
|
+
),
|
|
955
|
+
"react-dom/test-utils": require6.resolve(
|
|
955
956
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
956
957
|
),
|
|
957
|
-
"react-dom/cjs/react-dom.development.js":
|
|
958
|
+
"react-dom/cjs/react-dom.development.js": require6.resolve(
|
|
958
959
|
"next/dist/compiled/react-dom/cjs/react-dom.development.js"
|
|
959
960
|
),
|
|
960
|
-
"react-dom/client":
|
|
961
|
+
"react-dom/client": require6.resolve(
|
|
961
962
|
"next/dist/compiled/react-dom/client.js"
|
|
962
963
|
),
|
|
963
|
-
"react-dom":
|
|
964
|
+
"react-dom": require6.resolve("next/dist/compiled/react-dom")
|
|
964
965
|
}
|
|
965
966
|
}
|
|
966
967
|
};
|
|
@@ -968,7 +969,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
968
969
|
configResolved(config) {
|
|
969
970
|
if (!config.test?.browser?.enabled) {
|
|
970
971
|
config.test.setupFiles = [
|
|
971
|
-
|
|
972
|
+
require6.resolve("./mocks/storybook.global.js"),
|
|
972
973
|
...config.test?.setupFiles ?? []
|
|
973
974
|
];
|
|
974
975
|
}
|
package/dist/index.js
CHANGED
|
@@ -25,12 +25,7 @@ import { cpus } from 'node:os';
|
|
|
25
25
|
import { decode } from 'node:querystring';
|
|
26
26
|
import imageSizeOf from 'image-size';
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
30
|
-
}) : x)(function(x) {
|
|
31
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
32
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
33
|
-
});
|
|
28
|
+
// src/index.ts
|
|
34
29
|
var nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
|
|
35
30
|
async function loadEnvironmentConfig(dir, dev) {
|
|
36
31
|
return loadEnvConfig(dir, dev, Log);
|
|
@@ -462,7 +457,7 @@ function getBaseSWCOptions({
|
|
|
462
457
|
esm,
|
|
463
458
|
modularizeImports,
|
|
464
459
|
swcPlugins,
|
|
465
|
-
|
|
460
|
+
compiler,
|
|
466
461
|
resolvedBaseUrl,
|
|
467
462
|
jsConfig,
|
|
468
463
|
swcCacheDir
|
|
@@ -498,7 +493,7 @@ function getBaseSWCOptions({
|
|
|
498
493
|
decoratorMetadata: emitDecoratorMetadata,
|
|
499
494
|
useDefineForClassFields,
|
|
500
495
|
react: {
|
|
501
|
-
importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (
|
|
496
|
+
importSource: jsConfig?.compilerOptions?.jsxImportSource ?? (compiler?.emotion ? "@emotion/react" : "react"),
|
|
502
497
|
runtime: "automatic",
|
|
503
498
|
pragmaFrag: "React.Fragment",
|
|
504
499
|
throwIfNamespace: true,
|
|
@@ -524,7 +519,7 @@ function getBaseSWCOptions({
|
|
|
524
519
|
}
|
|
525
520
|
},
|
|
526
521
|
sourceMaps: true,
|
|
527
|
-
removeConsole:
|
|
522
|
+
removeConsole: compiler?.removeConsole,
|
|
528
523
|
reactRemoveProperties: false,
|
|
529
524
|
// Map the k-v map to an array of pairs.
|
|
530
525
|
modularizeImports: modularizeImports ? Object.fromEntries(
|
|
@@ -539,14 +534,14 @@ function getBaseSWCOptions({
|
|
|
539
534
|
}
|
|
540
535
|
])
|
|
541
536
|
) : void 0,
|
|
542
|
-
relay:
|
|
537
|
+
relay: compiler?.relay,
|
|
543
538
|
// Always transform styled-jsx and error when `client-only` condition is triggered
|
|
544
539
|
styledJsx: {},
|
|
545
540
|
// Disable css-in-js libs (without client-only integration) transform on server layer for server components
|
|
546
|
-
emotion: getEmotionOptions(
|
|
541
|
+
emotion: getEmotionOptions(compiler?.emotion, development),
|
|
547
542
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
548
543
|
styledComponents: getStyledComponentsOptions(
|
|
549
|
-
|
|
544
|
+
compiler?.styledComponents,
|
|
550
545
|
development
|
|
551
546
|
),
|
|
552
547
|
serverComponents: void 0,
|
|
@@ -578,7 +573,7 @@ var getVitestSWCTransformConfig = ({
|
|
|
578
573
|
jsConfig: loadedJSConfig.jsConfig,
|
|
579
574
|
resolvedBaseUrl: loadedJSConfig.resolvedBaseUrl,
|
|
580
575
|
swcPlugins: nextConfig.experimental.swcPlugins,
|
|
581
|
-
|
|
576
|
+
compiler: nextConfig?.compiler,
|
|
582
577
|
esm: isEsmProject,
|
|
583
578
|
swcCacheDir: path.join(
|
|
584
579
|
rootDir,
|
|
@@ -743,9 +738,11 @@ var vitePluginNextDynamic = () => ({
|
|
|
743
738
|
// src/utils.ts
|
|
744
739
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
745
740
|
var isVitestEnv = process.env.VITEST === "true";
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
741
|
+
function getExecutionEnvironment(config) {
|
|
742
|
+
return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
|
|
743
|
+
}
|
|
744
|
+
var require3 = createRequire(import.meta.url);
|
|
745
|
+
var getEntryPoint = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
749
746
|
var getAlias = (env) => ({
|
|
750
747
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
751
748
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
@@ -758,9 +755,9 @@ var virtualImage = "virtual:next-image";
|
|
|
758
755
|
var virtualNextImage = "virtual:next/image";
|
|
759
756
|
var virtualNextLegacyImage = "virtual:next/legacy/image";
|
|
760
757
|
var sharp;
|
|
761
|
-
var
|
|
758
|
+
var require4 = createRequire(import.meta.url);
|
|
762
759
|
try {
|
|
763
|
-
sharp =
|
|
760
|
+
sharp = require4("sharp");
|
|
764
761
|
if (sharp && sharp.concurrency() > 1) {
|
|
765
762
|
const divisor = process.env.NODE_ENV === "development" ? 4 : 2;
|
|
766
763
|
sharp.concurrency(Math.floor(Math.max(cpus().length / divisor, 1)));
|
|
@@ -807,12 +804,12 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
807
804
|
const aliasEnv = isBrowser ? "browser" : "node";
|
|
808
805
|
if (virtualNextImage === id) {
|
|
809
806
|
return (await fs3.promises.readFile(
|
|
810
|
-
|
|
807
|
+
require4.resolve(`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/image`)
|
|
811
808
|
)).toString("utf-8");
|
|
812
809
|
}
|
|
813
810
|
if (virtualNextLegacyImage === id) {
|
|
814
811
|
return (await fs3.promises.readFile(
|
|
815
|
-
|
|
812
|
+
require4.resolve(
|
|
816
813
|
`${VITEST_PLUGIN_NAME}/${aliasEnv}/mocks/legacy-image`
|
|
817
814
|
)
|
|
818
815
|
)).toString("utf-8");
|
|
@@ -860,8 +857,8 @@ function vitePluginNextImage(nextConfigResolver) {
|
|
|
860
857
|
}
|
|
861
858
|
};
|
|
862
859
|
}
|
|
863
|
-
var
|
|
864
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
860
|
+
var require5 = createRequire(import.meta.url);
|
|
861
|
+
var getEntryPoint2 = (subPath, env) => require5.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
865
862
|
var getAlias2 = (env) => ({
|
|
866
863
|
"next/headers": getEntryPoint2("headers", env),
|
|
867
864
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -889,15 +886,15 @@ var getAlias2 = (env) => ({
|
|
|
889
886
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
890
887
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
891
888
|
"server-only": getEntryPoint2("server-only", env),
|
|
892
|
-
"@opentelemetry/api":
|
|
889
|
+
"@opentelemetry/api": require5.resolve(
|
|
893
890
|
"next/dist/compiled/@opentelemetry/api"
|
|
894
891
|
),
|
|
895
892
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
896
893
|
});
|
|
897
894
|
var vitePluginNextMocks = () => ({
|
|
898
895
|
name: "vite-plugin-next-mocks",
|
|
899
|
-
config: (
|
|
900
|
-
const aliasEnv =
|
|
896
|
+
config: (config) => {
|
|
897
|
+
const aliasEnv = getExecutionEnvironment(config);
|
|
901
898
|
return {
|
|
902
899
|
resolve: {
|
|
903
900
|
alias: getAlias2(aliasEnv)
|
|
@@ -907,7 +904,7 @@ var vitePluginNextMocks = () => ({
|
|
|
907
904
|
});
|
|
908
905
|
|
|
909
906
|
// src/index.ts
|
|
910
|
-
var
|
|
907
|
+
var require6 = createRequire(import.meta.url);
|
|
911
908
|
function VitePlugin({ dir = process.cwd() } = {}) {
|
|
912
909
|
const resolvedDir = resolve(dir);
|
|
913
910
|
const nextConfigResolver = Promise.withResolvers();
|
|
@@ -918,6 +915,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
918
915
|
async config(config, env) {
|
|
919
916
|
const phase = env.mode === "development" ? PHASE_DEVELOPMENT_SERVER : env.mode === "test" ? PHASE_TEST : PHASE_PRODUCTION_BUILD;
|
|
920
917
|
nextConfigResolver.resolve(await loadConfig(phase, resolvedDir));
|
|
918
|
+
const executionEnvironment = getExecutionEnvironment(config);
|
|
921
919
|
return {
|
|
922
920
|
...!isVitestEnv && {
|
|
923
921
|
resolve: {
|
|
@@ -929,23 +927,26 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
929
927
|
},
|
|
930
928
|
test: {
|
|
931
929
|
alias: {
|
|
932
|
-
"react/jsx-dev-runtime":
|
|
930
|
+
"react/jsx-dev-runtime": require6.resolve(
|
|
933
931
|
"next/dist/compiled/react/jsx-dev-runtime.js"
|
|
934
932
|
),
|
|
935
|
-
"react/jsx-runtime":
|
|
933
|
+
"react/jsx-runtime": require6.resolve(
|
|
936
934
|
"next/dist/compiled/react/jsx-runtime.js"
|
|
937
935
|
),
|
|
938
|
-
react:
|
|
939
|
-
"react-dom/
|
|
936
|
+
react: require6.resolve("next/dist/compiled/react"),
|
|
937
|
+
"react-dom/server": require6.resolve(
|
|
938
|
+
executionEnvironment === "node" ? "next/dist/compiled/react-dom/server.js" : "next/dist/compiled/react-dom/server.browser.js"
|
|
939
|
+
),
|
|
940
|
+
"react-dom/test-utils": require6.resolve(
|
|
940
941
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
941
942
|
),
|
|
942
|
-
"react-dom/cjs/react-dom.development.js":
|
|
943
|
+
"react-dom/cjs/react-dom.development.js": require6.resolve(
|
|
943
944
|
"next/dist/compiled/react-dom/cjs/react-dom.development.js"
|
|
944
945
|
),
|
|
945
|
-
"react-dom/client":
|
|
946
|
+
"react-dom/client": require6.resolve(
|
|
946
947
|
"next/dist/compiled/react-dom/client.js"
|
|
947
948
|
),
|
|
948
|
-
"react-dom":
|
|
949
|
+
"react-dom": require6.resolve("next/dist/compiled/react-dom")
|
|
949
950
|
}
|
|
950
951
|
}
|
|
951
952
|
};
|
|
@@ -953,7 +954,7 @@ function VitePlugin({ dir = process.cwd() } = {}) {
|
|
|
953
954
|
configResolved(config) {
|
|
954
955
|
if (!config.test?.browser?.enabled) {
|
|
955
956
|
config.test.setupFiles = [
|
|
956
|
-
|
|
957
|
+
require6.resolve("./mocks/storybook.global.js"),
|
|
957
958
|
...config.test?.setupFiles ?? []
|
|
958
959
|
];
|
|
959
960
|
}
|
|
@@ -8,25 +8,21 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
8
8
|
|
|
9
9
|
var moduleAlias__default = /*#__PURE__*/_interopDefault(moduleAlias);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
|
-
}) : x)(function(x) {
|
|
14
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
-
});
|
|
11
|
+
// src/mocks/storybook.global.ts
|
|
17
12
|
|
|
18
13
|
// src/utils.ts
|
|
19
14
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
20
15
|
process.env.VITEST === "true";
|
|
21
16
|
|
|
22
17
|
// src/plugins/next-image/alias/index.tsx
|
|
23
|
-
var
|
|
18
|
+
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
19
|
+
var getEntryPoint = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
24
20
|
var getAlias = (env) => ({
|
|
25
21
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
26
22
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
27
23
|
});
|
|
28
|
-
var
|
|
29
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
24
|
+
var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
25
|
+
var getEntryPoint2 = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
30
26
|
var getAlias2 = (env) => ({
|
|
31
27
|
"next/headers": getEntryPoint2("headers", env),
|
|
32
28
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -54,17 +50,18 @@ var getAlias2 = (env) => ({
|
|
|
54
50
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
55
51
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
56
52
|
"server-only": getEntryPoint2("server-only", env),
|
|
57
|
-
"@opentelemetry/api":
|
|
53
|
+
"@opentelemetry/api": require3.resolve(
|
|
58
54
|
"next/dist/compiled/@opentelemetry/api"
|
|
59
55
|
),
|
|
60
56
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
61
57
|
});
|
|
62
58
|
|
|
63
59
|
// src/mocks/storybook.global.ts
|
|
64
|
-
var
|
|
60
|
+
var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
65
61
|
moduleAlias__default.default.addAliases({
|
|
66
62
|
react: "next/dist/compiled/react",
|
|
67
|
-
"react-dom/
|
|
63
|
+
"react-dom/server": "next/dist/compiled/react-dom/server.js",
|
|
64
|
+
"react-dom/test-utils": require4.resolve(
|
|
68
65
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
69
66
|
),
|
|
70
67
|
"react-dom": "next/dist/compiled/react-dom",
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import moduleAlias from 'module-alias';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
-
}) : x)(function(x) {
|
|
7
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
-
});
|
|
4
|
+
// src/mocks/storybook.global.ts
|
|
10
5
|
|
|
11
6
|
// src/utils.ts
|
|
12
7
|
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
13
8
|
process.env.VITEST === "true";
|
|
14
9
|
|
|
15
10
|
// src/plugins/next-image/alias/index.tsx
|
|
16
|
-
var
|
|
11
|
+
var require2 = createRequire(import.meta.url);
|
|
12
|
+
var getEntryPoint = (subPath, env) => require2.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
17
13
|
var getAlias = (env) => ({
|
|
18
14
|
"sb-original/default-loader": getEntryPoint("image-default-loader", env),
|
|
19
15
|
"sb-original/image-context": getEntryPoint("image-context", env)
|
|
20
16
|
});
|
|
21
|
-
var
|
|
22
|
-
var getEntryPoint2 = (subPath, env) =>
|
|
17
|
+
var require3 = createRequire(import.meta.url);
|
|
18
|
+
var getEntryPoint2 = (subPath, env) => require3.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
23
19
|
var getAlias2 = (env) => ({
|
|
24
20
|
"next/headers": getEntryPoint2("headers", env),
|
|
25
21
|
"@storybook/nextjs/headers.mock": getEntryPoint2("headers", env),
|
|
@@ -47,17 +43,18 @@ var getAlias2 = (env) => ({
|
|
|
47
43
|
"@storybook/nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
48
44
|
"@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint2("cache", env),
|
|
49
45
|
"server-only": getEntryPoint2("server-only", env),
|
|
50
|
-
"@opentelemetry/api":
|
|
46
|
+
"@opentelemetry/api": require3.resolve(
|
|
51
47
|
"next/dist/compiled/@opentelemetry/api"
|
|
52
48
|
),
|
|
53
49
|
"next/dynamic": getEntryPoint2("dynamic", env)
|
|
54
50
|
});
|
|
55
51
|
|
|
56
52
|
// src/mocks/storybook.global.ts
|
|
57
|
-
var
|
|
53
|
+
var require4 = createRequire(import.meta.url);
|
|
58
54
|
moduleAlias.addAliases({
|
|
59
55
|
react: "next/dist/compiled/react",
|
|
60
|
-
"react-dom/
|
|
56
|
+
"react-dom/server": "next/dist/compiled/react-dom/server.js",
|
|
57
|
+
"react-dom/test-utils": require4.resolve(
|
|
61
58
|
"next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
|
|
62
59
|
),
|
|
63
60
|
"react-dom": "next/dist/compiled/react-dom",
|
|
@@ -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>, "
|
|
5
|
+
declare const MockedNextImage: React__default.ForwardRefExoticComponent<Omit<React__default.DetailedHTMLProps<React__default.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "srcSet" | "ref" | "width" | "height" | "loading" | "alt"> & {
|
|
6
6
|
src: string | next_dist_shared_lib_get_img_props.StaticImport;
|
|
7
7
|
alt: string;
|
|
8
8
|
width?: number | `${number}` | undefined;
|
|
@@ -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>, "
|
|
5
|
+
declare const MockedNextImage: React__default.ForwardRefExoticComponent<Omit<React__default.DetailedHTMLProps<React__default.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "src" | "srcSet" | "ref" | "width" | "height" | "loading" | "alt"> & {
|
|
6
6
|
src: string | next_dist_shared_lib_get_img_props.StaticImport;
|
|
7
7
|
alt: string;
|
|
8
8
|
width?: number | `${number}` | undefined;
|