vite-plugin-storybook-nextjs 1.0.2--canary.8683acb.1 → 1.0.3
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
|
@@ -17,6 +17,7 @@ var validateLocalFontFunctionCall_js = require('next/dist/compiled/@next/font/di
|
|
|
17
17
|
var tsDedent = require('ts-dedent');
|
|
18
18
|
var loadJsConfig = require('next/dist/build/load-jsconfig.js');
|
|
19
19
|
var findPagesDir_js = require('next/dist/lib/find-pages-dir.js');
|
|
20
|
+
var vite = require('vite');
|
|
20
21
|
var utils_js = require('next/dist/build/utils.js');
|
|
21
22
|
var options_js = require('next/dist/build/swc/options.js');
|
|
22
23
|
var loadConfig = require('next/dist/server/config.js');
|
|
@@ -654,7 +655,7 @@ var getVitestSWCTransformConfig = ({
|
|
|
654
655
|
var isDefined = (value) => value !== void 0;
|
|
655
656
|
|
|
656
657
|
// src/plugins/next-swc/plugin.ts
|
|
657
|
-
var excluded = /[\\/](cache[\\/][^\\/]+\.zip[\\/]
|
|
658
|
+
var excluded = /[\\/]((cache[\\/][^\\/]+\.zip[\\/])|virtual:)[\\/]/;
|
|
658
659
|
var included = /\.((c|m)?(j|t)sx?)$/;
|
|
659
660
|
function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
660
661
|
let loadedJSConfig;
|
|
@@ -662,6 +663,7 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
|
662
663
|
let isServerEnvironment;
|
|
663
664
|
let isDev;
|
|
664
665
|
let isEsmProject;
|
|
666
|
+
const filter = vite.createFilter(included, excluded);
|
|
665
667
|
const resolvedDir = path.resolve(rootDir);
|
|
666
668
|
return {
|
|
667
669
|
name: "vite-plugin-storybook-nextjs-swc",
|
|
@@ -695,24 +697,25 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
|
695
697
|
};
|
|
696
698
|
},
|
|
697
699
|
async transform(code, id) {
|
|
698
|
-
if (
|
|
699
|
-
|
|
700
|
-
const output = await index_js.transform(
|
|
701
|
-
code,
|
|
702
|
-
getVitestSWCTransformConfig({
|
|
703
|
-
filename: id,
|
|
704
|
-
inputSourceMap,
|
|
705
|
-
isServerEnvironment,
|
|
706
|
-
loadedJSConfig,
|
|
707
|
-
nextConfig: await nextConfigResolver.promise,
|
|
708
|
-
nextDirectories,
|
|
709
|
-
rootDir,
|
|
710
|
-
isDev,
|
|
711
|
-
isEsmProject
|
|
712
|
-
})
|
|
713
|
-
);
|
|
714
|
-
return output;
|
|
700
|
+
if (id.includes("/node_modules/") || !filter(id)) {
|
|
701
|
+
return;
|
|
715
702
|
}
|
|
703
|
+
const inputSourceMap = this.getCombinedSourcemap();
|
|
704
|
+
const output = await index_js.transform(
|
|
705
|
+
code,
|
|
706
|
+
getVitestSWCTransformConfig({
|
|
707
|
+
filename: id,
|
|
708
|
+
inputSourceMap,
|
|
709
|
+
isServerEnvironment,
|
|
710
|
+
loadedJSConfig,
|
|
711
|
+
nextConfig: await nextConfigResolver.promise,
|
|
712
|
+
nextDirectories,
|
|
713
|
+
rootDir,
|
|
714
|
+
isDev,
|
|
715
|
+
isEsmProject
|
|
716
|
+
})
|
|
717
|
+
);
|
|
718
|
+
return output;
|
|
716
719
|
}
|
|
717
720
|
};
|
|
718
721
|
}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { validateLocalFontFunctionCall } from 'next/dist/compiled/@next/font/dis
|
|
|
15
15
|
import { dedent } from 'ts-dedent';
|
|
16
16
|
import loadJsConfig from 'next/dist/build/load-jsconfig.js';
|
|
17
17
|
import { findPagesDir } from 'next/dist/lib/find-pages-dir.js';
|
|
18
|
+
import { createFilter } from 'vite';
|
|
18
19
|
import { getSupportedBrowsers } from 'next/dist/build/utils.js';
|
|
19
20
|
import { getParserOptions } from 'next/dist/build/swc/options.js';
|
|
20
21
|
import loadConfig from 'next/dist/server/config.js';
|
|
@@ -639,7 +640,7 @@ var getVitestSWCTransformConfig = ({
|
|
|
639
640
|
var isDefined = (value) => value !== void 0;
|
|
640
641
|
|
|
641
642
|
// src/plugins/next-swc/plugin.ts
|
|
642
|
-
var excluded = /[\\/](cache[\\/][^\\/]+\.zip[\\/]
|
|
643
|
+
var excluded = /[\\/]((cache[\\/][^\\/]+\.zip[\\/])|virtual:)[\\/]/;
|
|
643
644
|
var included = /\.((c|m)?(j|t)sx?)$/;
|
|
644
645
|
function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
645
646
|
let loadedJSConfig;
|
|
@@ -647,6 +648,7 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
|
647
648
|
let isServerEnvironment;
|
|
648
649
|
let isDev;
|
|
649
650
|
let isEsmProject;
|
|
651
|
+
const filter = createFilter(included, excluded);
|
|
650
652
|
const resolvedDir = resolve(rootDir);
|
|
651
653
|
return {
|
|
652
654
|
name: "vite-plugin-storybook-nextjs-swc",
|
|
@@ -680,24 +682,25 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
|
680
682
|
};
|
|
681
683
|
},
|
|
682
684
|
async transform(code, id) {
|
|
683
|
-
if (
|
|
684
|
-
|
|
685
|
-
const output = await transform(
|
|
686
|
-
code,
|
|
687
|
-
getVitestSWCTransformConfig({
|
|
688
|
-
filename: id,
|
|
689
|
-
inputSourceMap,
|
|
690
|
-
isServerEnvironment,
|
|
691
|
-
loadedJSConfig,
|
|
692
|
-
nextConfig: await nextConfigResolver.promise,
|
|
693
|
-
nextDirectories,
|
|
694
|
-
rootDir,
|
|
695
|
-
isDev,
|
|
696
|
-
isEsmProject
|
|
697
|
-
})
|
|
698
|
-
);
|
|
699
|
-
return output;
|
|
685
|
+
if (id.includes("/node_modules/") || !filter(id)) {
|
|
686
|
+
return;
|
|
700
687
|
}
|
|
688
|
+
const inputSourceMap = this.getCombinedSourcemap();
|
|
689
|
+
const output = await transform(
|
|
690
|
+
code,
|
|
691
|
+
getVitestSWCTransformConfig({
|
|
692
|
+
filename: id,
|
|
693
|
+
inputSourceMap,
|
|
694
|
+
isServerEnvironment,
|
|
695
|
+
loadedJSConfig,
|
|
696
|
+
nextConfig: await nextConfigResolver.promise,
|
|
697
|
+
nextDirectories,
|
|
698
|
+
rootDir,
|
|
699
|
+
isDev,
|
|
700
|
+
isEsmProject
|
|
701
|
+
})
|
|
702
|
+
);
|
|
703
|
+
return output;
|
|
701
704
|
}
|
|
702
705
|
};
|
|
703
706
|
}
|
|
@@ -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;
|