vite-plugin-storybook-nextjs 3.1.8--canary.82.dd5dbde.0 → 3.1.8
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 +27 -24
- package/dist/index.js +27 -24
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4069,14 +4069,16 @@ async function getFontFaceDeclarations2(options) {
|
|
|
4069
4069
|
if ("fontReferenceId" in localFontSrc) {
|
|
4070
4070
|
return tsDedent.dedent`@font-face {
|
|
4071
4071
|
font-family: ${id};
|
|
4072
|
-
src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs
|
|
4072
|
+
src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs/${localFontSrc.fontPath}`});
|
|
4073
|
+
${weight ? `font-weight: ${weight};` : ""}
|
|
4074
|
+
${style ? `font-style: ${style};` : ""}
|
|
4073
4075
|
${fontDeclarations}
|
|
4074
4076
|
}`;
|
|
4075
4077
|
}
|
|
4076
4078
|
return localFontSrc.map((font) => {
|
|
4077
4079
|
return tsDedent.dedent`@font-face {
|
|
4078
4080
|
font-family: ${id};
|
|
4079
|
-
src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs
|
|
4081
|
+
src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs/${font.path.fontPath}`});
|
|
4080
4082
|
${font.weight ? `font-weight: ${font.weight};` : ""}
|
|
4081
4083
|
${font.style ? `font-style: ${font.style};` : ""}
|
|
4082
4084
|
${fontDeclarations}
|
|
@@ -4104,7 +4106,7 @@ function getCSSMeta(options) {
|
|
|
4104
4106
|
.${className} {
|
|
4105
4107
|
font-family: ${options.fontFamily};
|
|
4106
4108
|
${isNextCSSPropertyValid(options.styles) ? `font-style: ${options.styles[0]};` : ""}
|
|
4107
|
-
${isNextCSSPropertyValid(options.weights) ? `font-weight: ${options.weights[0]};` : ""}
|
|
4109
|
+
${isNextCSSPropertyValid(options.weights) && !options.weights[0]?.includes(" ") ? `font-weight: ${options.weights[0]};` : ""}
|
|
4108
4110
|
}
|
|
4109
4111
|
|
|
4110
4112
|
${options.variable ? `.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }` : ""}
|
|
@@ -4121,7 +4123,7 @@ function getCSSMeta(options) {
|
|
|
4121
4123
|
function getClassName({ styles, weights, fontFamily }) {
|
|
4122
4124
|
const font = fontFamily.replaceAll(" ", "-").toLowerCase();
|
|
4123
4125
|
const style = isNextCSSPropertyValid(styles) ? styles[0] : null;
|
|
4124
|
-
const weight = isNextCSSPropertyValid(weights) ? weights[0] : null;
|
|
4126
|
+
const weight = isNextCSSPropertyValid(weights) ? weights[0]?.replaceAll(" ", "-") : null;
|
|
4125
4127
|
return `${font}${style ? `-${style}` : ""}${weight ? `-${weight}` : ""}`;
|
|
4126
4128
|
}
|
|
4127
4129
|
function getStylesObj({ styles, weights, fontFamily }) {
|
|
@@ -4297,6 +4299,21 @@ function vitePluginNextFont() {
|
|
|
4297
4299
|
}
|
|
4298
4300
|
};
|
|
4299
4301
|
}
|
|
4302
|
+
var require2 = 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)));
|
|
4303
|
+
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
4304
|
+
var isVitestEnv = process.env.VITEST === "true";
|
|
4305
|
+
function getExecutionEnvironment(config) {
|
|
4306
|
+
return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
|
|
4307
|
+
}
|
|
4308
|
+
var getNextjsVersion = () => require2("next/package.json").version;
|
|
4309
|
+
var getNextjsMajorVersion = () => {
|
|
4310
|
+
try {
|
|
4311
|
+
const version = getNextjsVersion();
|
|
4312
|
+
return Number.parseInt(version.split(".")[0], 10);
|
|
4313
|
+
} catch (error) {
|
|
4314
|
+
return 16;
|
|
4315
|
+
}
|
|
4316
|
+
};
|
|
4300
4317
|
|
|
4301
4318
|
// src/utils/swc/styles.ts
|
|
4302
4319
|
function getStyledComponentsOptions(styledComponentsConfig, development) {
|
|
@@ -4339,8 +4356,8 @@ function getEmotionOptions(emotionConfig, development) {
|
|
|
4339
4356
|
}
|
|
4340
4357
|
|
|
4341
4358
|
// src/utils/swc/options.ts
|
|
4342
|
-
var
|
|
4343
|
-
var regeneratorRuntimePath =
|
|
4359
|
+
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)));
|
|
4360
|
+
var regeneratorRuntimePath = require3.resolve(
|
|
4344
4361
|
"next/dist/compiled/regenerator-runtime"
|
|
4345
4362
|
);
|
|
4346
4363
|
function getBaseSWCOptions({
|
|
@@ -4367,7 +4384,7 @@ function getBaseSWCOptions({
|
|
|
4367
4384
|
const useDefineForClassFields = Boolean(
|
|
4368
4385
|
jsConfig?.compilerOptions?.useDefineForClassFields
|
|
4369
4386
|
);
|
|
4370
|
-
const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [
|
|
4387
|
+
const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [require3.resolve(name), options]);
|
|
4371
4388
|
return {
|
|
4372
4389
|
jsc: {
|
|
4373
4390
|
...resolvedBaseUrl && paths ? {
|
|
@@ -4556,8 +4573,9 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
|
4556
4573
|
await loadSWCBindingsEagerly(nextConfig);
|
|
4557
4574
|
const serverWatchIgnored = config.server?.watch?.ignored;
|
|
4558
4575
|
const isServerWatchIgnoredArray = Array.isArray(serverWatchIgnored);
|
|
4559
|
-
|
|
4560
|
-
|
|
4576
|
+
isServerEnvironment = false;
|
|
4577
|
+
if (isVitestEnv) {
|
|
4578
|
+
isServerEnvironment = config.test?.environment === "node" || config.test?.environment === "edge-runtime" || config.test?.browser?.enabled !== true;
|
|
4561
4579
|
}
|
|
4562
4580
|
return {
|
|
4563
4581
|
// esbuild: {
|
|
@@ -4696,21 +4714,6 @@ var reservedWords = "break case class catch const continue debugger default dele
|
|
|
4696
4714
|
var builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
|
|
4697
4715
|
var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
|
|
4698
4716
|
forbiddenIdentifiers.add("");
|
|
4699
|
-
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)));
|
|
4700
|
-
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
4701
|
-
var isVitestEnv = process.env.VITEST === "true";
|
|
4702
|
-
function getExecutionEnvironment(config) {
|
|
4703
|
-
return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
|
|
4704
|
-
}
|
|
4705
|
-
var getNextjsVersion = () => require3("next/package.json").version;
|
|
4706
|
-
var getNextjsMajorVersion = () => {
|
|
4707
|
-
try {
|
|
4708
|
-
const version = getNextjsVersion();
|
|
4709
|
-
return Number.parseInt(version.split(".")[0], 10);
|
|
4710
|
-
} catch (error) {
|
|
4711
|
-
return 16;
|
|
4712
|
-
}
|
|
4713
|
-
};
|
|
4714
4717
|
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)));
|
|
4715
4718
|
var getEntryPoint = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
4716
4719
|
var getAlias = (env) => ({
|
package/dist/index.js
CHANGED
|
@@ -4036,14 +4036,16 @@ async function getFontFaceDeclarations2(options) {
|
|
|
4036
4036
|
if ("fontReferenceId" in localFontSrc) {
|
|
4037
4037
|
return dedent`@font-face {
|
|
4038
4038
|
font-family: ${id};
|
|
4039
|
-
src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs
|
|
4039
|
+
src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs/${localFontSrc.fontPath}`});
|
|
4040
|
+
${weight ? `font-weight: ${weight};` : ""}
|
|
4041
|
+
${style ? `font-style: ${style};` : ""}
|
|
4040
4042
|
${fontDeclarations}
|
|
4041
4043
|
}`;
|
|
4042
4044
|
}
|
|
4043
4045
|
return localFontSrc.map((font) => {
|
|
4044
4046
|
return dedent`@font-face {
|
|
4045
4047
|
font-family: ${id};
|
|
4046
|
-
src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs
|
|
4048
|
+
src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs/${font.path.fontPath}`});
|
|
4047
4049
|
${font.weight ? `font-weight: ${font.weight};` : ""}
|
|
4048
4050
|
${font.style ? `font-style: ${font.style};` : ""}
|
|
4049
4051
|
${fontDeclarations}
|
|
@@ -4071,7 +4073,7 @@ function getCSSMeta(options) {
|
|
|
4071
4073
|
.${className} {
|
|
4072
4074
|
font-family: ${options.fontFamily};
|
|
4073
4075
|
${isNextCSSPropertyValid(options.styles) ? `font-style: ${options.styles[0]};` : ""}
|
|
4074
|
-
${isNextCSSPropertyValid(options.weights) ? `font-weight: ${options.weights[0]};` : ""}
|
|
4076
|
+
${isNextCSSPropertyValid(options.weights) && !options.weights[0]?.includes(" ") ? `font-weight: ${options.weights[0]};` : ""}
|
|
4075
4077
|
}
|
|
4076
4078
|
|
|
4077
4079
|
${options.variable ? `.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }` : ""}
|
|
@@ -4088,7 +4090,7 @@ function getCSSMeta(options) {
|
|
|
4088
4090
|
function getClassName({ styles, weights, fontFamily }) {
|
|
4089
4091
|
const font = fontFamily.replaceAll(" ", "-").toLowerCase();
|
|
4090
4092
|
const style = isNextCSSPropertyValid(styles) ? styles[0] : null;
|
|
4091
|
-
const weight = isNextCSSPropertyValid(weights) ? weights[0] : null;
|
|
4093
|
+
const weight = isNextCSSPropertyValid(weights) ? weights[0]?.replaceAll(" ", "-") : null;
|
|
4092
4094
|
return `${font}${style ? `-${style}` : ""}${weight ? `-${weight}` : ""}`;
|
|
4093
4095
|
}
|
|
4094
4096
|
function getStylesObj({ styles, weights, fontFamily }) {
|
|
@@ -4264,6 +4266,21 @@ function vitePluginNextFont() {
|
|
|
4264
4266
|
}
|
|
4265
4267
|
};
|
|
4266
4268
|
}
|
|
4269
|
+
var require2 = createRequire(import.meta.url);
|
|
4270
|
+
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
4271
|
+
var isVitestEnv = process.env.VITEST === "true";
|
|
4272
|
+
function getExecutionEnvironment(config) {
|
|
4273
|
+
return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
|
|
4274
|
+
}
|
|
4275
|
+
var getNextjsVersion = () => require2("next/package.json").version;
|
|
4276
|
+
var getNextjsMajorVersion = () => {
|
|
4277
|
+
try {
|
|
4278
|
+
const version = getNextjsVersion();
|
|
4279
|
+
return Number.parseInt(version.split(".")[0], 10);
|
|
4280
|
+
} catch (error) {
|
|
4281
|
+
return 16;
|
|
4282
|
+
}
|
|
4283
|
+
};
|
|
4267
4284
|
|
|
4268
4285
|
// src/utils/swc/styles.ts
|
|
4269
4286
|
function getStyledComponentsOptions(styledComponentsConfig, development) {
|
|
@@ -4306,8 +4323,8 @@ function getEmotionOptions(emotionConfig, development) {
|
|
|
4306
4323
|
}
|
|
4307
4324
|
|
|
4308
4325
|
// src/utils/swc/options.ts
|
|
4309
|
-
var
|
|
4310
|
-
var regeneratorRuntimePath =
|
|
4326
|
+
var require3 = createRequire(import.meta.url);
|
|
4327
|
+
var regeneratorRuntimePath = require3.resolve(
|
|
4311
4328
|
"next/dist/compiled/regenerator-runtime"
|
|
4312
4329
|
);
|
|
4313
4330
|
function getBaseSWCOptions({
|
|
@@ -4334,7 +4351,7 @@ function getBaseSWCOptions({
|
|
|
4334
4351
|
const useDefineForClassFields = Boolean(
|
|
4335
4352
|
jsConfig?.compilerOptions?.useDefineForClassFields
|
|
4336
4353
|
);
|
|
4337
|
-
const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [
|
|
4354
|
+
const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [require3.resolve(name), options]);
|
|
4338
4355
|
return {
|
|
4339
4356
|
jsc: {
|
|
4340
4357
|
...resolvedBaseUrl && paths ? {
|
|
@@ -4523,8 +4540,9 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
|
|
|
4523
4540
|
await loadSWCBindingsEagerly(nextConfig);
|
|
4524
4541
|
const serverWatchIgnored = config.server?.watch?.ignored;
|
|
4525
4542
|
const isServerWatchIgnoredArray = Array.isArray(serverWatchIgnored);
|
|
4526
|
-
|
|
4527
|
-
|
|
4543
|
+
isServerEnvironment = false;
|
|
4544
|
+
if (isVitestEnv) {
|
|
4545
|
+
isServerEnvironment = config.test?.environment === "node" || config.test?.environment === "edge-runtime" || config.test?.browser?.enabled !== true;
|
|
4528
4546
|
}
|
|
4529
4547
|
return {
|
|
4530
4548
|
// esbuild: {
|
|
@@ -4663,21 +4681,6 @@ var reservedWords = "break case class catch const continue debugger default dele
|
|
|
4663
4681
|
var builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
|
|
4664
4682
|
var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
|
|
4665
4683
|
forbiddenIdentifiers.add("");
|
|
4666
|
-
var require3 = createRequire(import.meta.url);
|
|
4667
|
-
var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
|
|
4668
|
-
var isVitestEnv = process.env.VITEST === "true";
|
|
4669
|
-
function getExecutionEnvironment(config) {
|
|
4670
|
-
return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
|
|
4671
|
-
}
|
|
4672
|
-
var getNextjsVersion = () => require3("next/package.json").version;
|
|
4673
|
-
var getNextjsMajorVersion = () => {
|
|
4674
|
-
try {
|
|
4675
|
-
const version = getNextjsVersion();
|
|
4676
|
-
return Number.parseInt(version.split(".")[0], 10);
|
|
4677
|
-
} catch (error) {
|
|
4678
|
-
return 16;
|
|
4679
|
-
}
|
|
4680
|
-
};
|
|
4681
4684
|
var require4 = createRequire(import.meta.url);
|
|
4682
4685
|
var getEntryPoint = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
|
|
4683
4686
|
var getAlias = (env) => ({
|