@forsakringskassan/vite-lib-config 5.15.2 → 6.0.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/README.md CHANGED
@@ -47,7 +47,7 @@ module.exports = {
47
47
  ```ts
48
48
  import { defineConfig } from "@forsakringskassan/vite-lib-config/vite";
49
49
 
50
- export default defineConfig();
50
+ export default defineConfig(import.meta.dirname);
51
51
  ```
52
52
 
53
53
  In addition to the regular Vite configuration you can also pass the optional `fk` property:
@@ -179,7 +179,7 @@ import {
179
179
  defaultPlugins,
180
180
  } from "@forsakringskassan/vite-lib-config/vite";
181
181
 
182
- export default defineConfig({
182
+ export default defineConfig(import.meta.dirname, {
183
183
  plugins: [...defaultPlugins, myFancyPlugin],
184
184
  });
185
185
  ```
@@ -111,6 +111,11 @@ var require_vendors = __commonJS({
111
111
  ne: "false"
112
112
  }
113
113
  },
114
+ {
115
+ name: "Capawesome Cloud",
116
+ constant: "CAPAWESOME_CLOUD",
117
+ env: "CAPAWESOME_CLOUD"
118
+ },
114
119
  {
115
120
  name: "CircleCI",
116
121
  constant: "CIRCLE",
@@ -293,6 +298,11 @@ var require_vendors = __commonJS({
293
298
  IS_PULL_REQUEST: "true"
294
299
  }
295
300
  },
301
+ {
302
+ name: "RWX",
303
+ constant: "RWX",
304
+ env: "RWX"
305
+ },
296
306
  {
297
307
  name: "Sail CI",
298
308
  constant: "SAIL",
@@ -429,10 +439,10 @@ var require_ci_info = __commonJS({
429
439
  exports.isCI = !!(env.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
430
440
  (env.BUILD_ID || // Jenkins, Cloudbees
431
441
  env.BUILD_NUMBER || // Jenkins, TeamCity
432
- env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages/Workers
433
- env.CI_APP_ID || // Appflow
434
- env.CI_BUILD_ID || // Appflow
435
- env.CI_BUILD_NUMBER || // Appflow
442
+ env.CI || // Appveyor, Capawesome Cloud, CircleCI, Cirrus CI, Cloudflare Pages/Workers, CodeShip, dsari, Gitlab CI, RWX, Travis CI
443
+ env.CI_APP_ID || // Appflow, Capawesome Cloud
444
+ env.CI_BUILD_ID || // Appflow, Capawesome Cloud
445
+ env.CI_BUILD_NUMBER || // Appflow, Capawesome Cloud
436
446
  env.CI_NAME || // Codeship and others
437
447
  env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
438
448
  env.RUN_ID || // TaskCluster, dsari
@@ -4938,7 +4938,7 @@ var import_node_fs = __toESM(require("node:fs"), 1);
4938
4938
  var import_vite = require("vite");
4939
4939
  var import_vue = require("vue");
4940
4940
 
4941
- // node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs
4941
+ // node_modules/@rolldown/pluginutils/dist/filter-p20yeu4b.mjs
4942
4942
  function exactRegex(str, flags) {
4943
4943
  return new RegExp(`^${escapeRegex(str)}$`, flags);
4944
4944
  }
@@ -4963,7 +4963,7 @@ var import_node_path = __toESM(require("node:path"), 1);
4963
4963
  var import_node_crypto = __toESM(require("node:crypto"), 1);
4964
4964
  var import_node_tty = require("node:tty");
4965
4965
  var import_node_util = require("node:util");
4966
- var version = "6.0.10";
4966
+ var version = "6.0.11";
4967
4967
  function resolveCompiler(root) {
4968
4968
  const compiler = tryResolveCompiler(root) || tryResolveCompiler();
4969
4969
  if (!compiler) throw new Error("Failed to resolve vue/compiler-sfc.\n@vitejs/plugin-vue requires vue (>=3.2.25) to be present in the dependency tree.");
@@ -5095,8 +5095,6 @@ function canForceVaporMode(descriptor) {
5095
5095
  async function transformTemplateAsModule(code2, filename, descriptor, options, pluginContext, ssr, customElement) {
5096
5096
  const result = compile(code2, filename, descriptor, options, pluginContext, ssr, customElement);
5097
5097
  let returnCode = result.code;
5098
- returnCode += `
5099
- export const multiRoot = ${JSON.stringify(result.multiRoot)}`;
5100
5098
  if (options.devServer && options.devServer.config.server.hmr !== false && !ssr && !options.isProduction) returnCode += `
5101
5099
  import.meta.hot.accept(({ render }) => {
5102
5100
  __VUE_HMR_RUNTIME__.rerender(${JSON.stringify(descriptor.id)}, render)
@@ -6119,6 +6117,7 @@ async function handleHotUpdate({ file, modules, read }, options, customElement,
6119
6117
  }
6120
6118
  }
6121
6119
  const updateType = [];
6120
+ if (scriptChanged) updateType.push(`script`);
6122
6121
  if (needRerender) {
6123
6122
  updateType.push(`template`);
6124
6123
  if (!templateModule) affectedModules.add(mainModule);
@@ -6230,14 +6229,11 @@ async function transformMain(code2, filename, options, pluginContext, ssr, custo
6230
6229
  }
6231
6230
  const attachedProps = [];
6232
6231
  const hasScoped = descriptor.styles.some((s) => s.scoped);
6233
- const isTemplateOnlyVapor = !descriptor.script && !descriptor.scriptSetup && isVaporMode(descriptor, options);
6234
6232
  const { code: scriptCode, map: scriptMap } = await genScriptCode(descriptor, options, pluginContext, ssr, customElement);
6235
6233
  const hasTemplateImport = descriptor.template && !isUseInlineTemplate(descriptor, options);
6236
- const isTemplateInlined = !!descriptor.template && (!descriptor.template.lang || descriptor.template.lang === "html") && !descriptor.template.src;
6237
6234
  let templateCode = "";
6238
6235
  let templateMap = void 0;
6239
- let templateMultiRoot;
6240
- if (hasTemplateImport) ({ code: templateCode, map: templateMap, multiRoot: templateMultiRoot } = await genTemplateCode(descriptor, options, pluginContext, ssr, customElement));
6236
+ if (hasTemplateImport) ({ code: templateCode, map: templateMap } = await genTemplateCode(descriptor, options, pluginContext, ssr, customElement));
6241
6237
  if (hasTemplateImport) attachedProps.push(ssr ? ["ssrRender", "_sfc_ssrRender"] : ["render", "_sfc_render"]);
6242
6238
  else if (prevDescriptor && !isEqualBlock(descriptor.template, prevDescriptor.template)) attachedProps.push([ssr ? "ssrRender" : "render", "() => {}"]);
6243
6239
  const stylesCode = await genStyleCode(descriptor, pluginContext, customElement, attachedProps);
@@ -6245,7 +6241,6 @@ async function transformMain(code2, filename, options, pluginContext, ssr, custo
6245
6241
  const output = [
6246
6242
  scriptCode,
6247
6243
  templateCode,
6248
- isTemplateOnlyVapor ? `${scriptIdentifier}.__multiRoot = ${isTemplateInlined ? templateMultiRoot : "_sfc_multiRoot"}` : "",
6249
6244
  stylesCode,
6250
6245
  customBlocksCode
6251
6246
  ];
@@ -6327,21 +6322,15 @@ async function transformMain(code2, filename, options, pluginContext, ssr, custo
6327
6322
  async function genTemplateCode(descriptor, options, pluginContext, ssr, customElement) {
6328
6323
  const template = descriptor.template;
6329
6324
  const hasScoped = descriptor.styles.some((style) => style.scoped);
6330
- const needsMultiRoot = !descriptor.script && !descriptor.scriptSetup && isVaporMode(descriptor, options);
6331
- if ((!template.lang || template.lang === "html") && !template.src) {
6332
- const result = transformTemplateInMain(template.content, descriptor, options, pluginContext, ssr, customElement);
6333
- return {
6334
- ...result,
6335
- multiRoot: needsMultiRoot ? result.multiRoot : void 0
6336
- };
6337
- } else {
6325
+ if ((!template.lang || template.lang === "html") && !template.src) return transformTemplateInMain(template.content, descriptor, options, pluginContext, ssr, customElement);
6326
+ else {
6338
6327
  if (template.src) await linkSrcToDescriptor(template.src, descriptor, pluginContext, hasScoped);
6339
6328
  const src = template.src || descriptor.filename;
6340
6329
  const query2 = `?vue&type=template${template.src ? hasScoped ? `&src=${descriptor.id}` : "&src=true" : ""}${hasScoped ? `&scoped=${descriptor.id}` : ``}${attrsToQuery(template.attrs, "js", true)}`;
6341
6330
  const request = JSON.stringify(src + query2);
6342
6331
  const renderFnName = ssr ? "ssrRender" : "render";
6343
6332
  return {
6344
- code: `import { ${renderFnName} as _sfc_${renderFnName}${needsMultiRoot ? ", multiRoot as _sfc_multiRoot" : ""} } from ${request}`,
6333
+ code: `import { ${renderFnName} as _sfc_${renderFnName} } from ${request}`,
6345
6334
  map: void 0
6346
6335
  };
6347
6336
  }
@@ -7136,7 +7125,7 @@ function getLocator(source) {
7136
7125
  return { line, column };
7137
7126
  };
7138
7127
  }
7139
- var wordRegex = /\w/;
7128
+ var wordRegex2 = /\w/;
7140
7129
  var Mappings = class {
7141
7130
  constructor(hires) {
7142
7131
  this.hires = hires;
@@ -7192,7 +7181,7 @@ var Mappings = class {
7192
7181
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
7193
7182
  const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
7194
7183
  if (this.hires === "boundary") {
7195
- if (wordRegex.test(original[originalCharIndex])) {
7184
+ if (wordRegex2.test(original[originalCharIndex])) {
7196
7185
  if (!charInHiresBoundary) {
7197
7186
  this.rawSegments.push(segment);
7198
7187
  charInHiresBoundary = true;
@@ -8646,9 +8635,9 @@ var defaultConfig = {
8646
8635
  function overwriteMerge(_a, b) {
8647
8636
  return b;
8648
8637
  }
8649
- function defineConfig(config = {}) {
8638
+ function defineConfig(rootDir2, config = {}) {
8650
8639
  return (0, import_vite2.defineConfig)(({ mode }) => {
8651
- return fkDefineConfig(mode, config);
8640
+ return fkDefineConfig(rootDir2, mode, config);
8652
8641
  });
8653
8642
  }
8654
8643
  function shouldUseCustomEntrypoint(options) {
@@ -8664,7 +8653,7 @@ function shouldUseCustomEntrypoint(options) {
8664
8653
  }
8665
8654
  return !config.fk?.entrypoint;
8666
8655
  }
8667
- async function fkDefineConfig(mode, config = {}) {
8656
+ async function fkDefineConfig(_rootDir, mode, config = {}) {
8668
8657
  const argv = process.argv.slice(2);
8669
8658
  const positional = argv.filter((it) => !it.startsWith("-"));
8670
8659
  config.fk ??= {};
@@ -16,7 +16,7 @@ export declare const defaultPlugins: (Plugin_2<any> | Plugin_3<any>)[];
16
16
  /**
17
17
  * @public
18
18
  */
19
- export declare function defineConfig(config?: UserConfig): UserConfigFn;
19
+ export declare function defineConfig(rootDir: string, config?: UserConfig): UserConfigFn;
20
20
 
21
21
  /**
22
22
  * @public
@@ -4930,7 +4930,7 @@ import fs from "node:fs";
4930
4930
  import { createFilter, formatPostcssSourceMap, isCSSRequest, normalizePath, transformWithEsbuild } from "vite";
4931
4931
  import { computed, shallowRef } from "vue";
4932
4932
 
4933
- // node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs
4933
+ // node_modules/@rolldown/pluginutils/dist/filter-p20yeu4b.mjs
4934
4934
  function exactRegex(str, flags) {
4935
4935
  return new RegExp(`^${escapeRegex(str)}$`, flags);
4936
4936
  }
@@ -4955,7 +4955,7 @@ import path from "node:path";
4955
4955
  import crypto from "node:crypto";
4956
4956
  import { isatty } from "node:tty";
4957
4957
  import { formatWithOptions, inspect } from "node:util";
4958
- var version = "6.0.10";
4958
+ var version = "6.0.11";
4959
4959
  function resolveCompiler(root) {
4960
4960
  const compiler = tryResolveCompiler(root) || tryResolveCompiler();
4961
4961
  if (!compiler) throw new Error("Failed to resolve vue/compiler-sfc.\n@vitejs/plugin-vue requires vue (>=3.2.25) to be present in the dependency tree.");
@@ -5087,8 +5087,6 @@ function canForceVaporMode(descriptor) {
5087
5087
  async function transformTemplateAsModule(code2, filename, descriptor, options, pluginContext, ssr, customElement) {
5088
5088
  const result = compile(code2, filename, descriptor, options, pluginContext, ssr, customElement);
5089
5089
  let returnCode = result.code;
5090
- returnCode += `
5091
- export const multiRoot = ${JSON.stringify(result.multiRoot)}`;
5092
5090
  if (options.devServer && options.devServer.config.server.hmr !== false && !ssr && !options.isProduction) returnCode += `
5093
5091
  import.meta.hot.accept(({ render }) => {
5094
5092
  __VUE_HMR_RUNTIME__.rerender(${JSON.stringify(descriptor.id)}, render)
@@ -6111,6 +6109,7 @@ async function handleHotUpdate({ file, modules, read }, options, customElement,
6111
6109
  }
6112
6110
  }
6113
6111
  const updateType = [];
6112
+ if (scriptChanged) updateType.push(`script`);
6114
6113
  if (needRerender) {
6115
6114
  updateType.push(`template`);
6116
6115
  if (!templateModule) affectedModules.add(mainModule);
@@ -6222,14 +6221,11 @@ async function transformMain(code2, filename, options, pluginContext, ssr, custo
6222
6221
  }
6223
6222
  const attachedProps = [];
6224
6223
  const hasScoped = descriptor.styles.some((s) => s.scoped);
6225
- const isTemplateOnlyVapor = !descriptor.script && !descriptor.scriptSetup && isVaporMode(descriptor, options);
6226
6224
  const { code: scriptCode, map: scriptMap } = await genScriptCode(descriptor, options, pluginContext, ssr, customElement);
6227
6225
  const hasTemplateImport = descriptor.template && !isUseInlineTemplate(descriptor, options);
6228
- const isTemplateInlined = !!descriptor.template && (!descriptor.template.lang || descriptor.template.lang === "html") && !descriptor.template.src;
6229
6226
  let templateCode = "";
6230
6227
  let templateMap = void 0;
6231
- let templateMultiRoot;
6232
- if (hasTemplateImport) ({ code: templateCode, map: templateMap, multiRoot: templateMultiRoot } = await genTemplateCode(descriptor, options, pluginContext, ssr, customElement));
6228
+ if (hasTemplateImport) ({ code: templateCode, map: templateMap } = await genTemplateCode(descriptor, options, pluginContext, ssr, customElement));
6233
6229
  if (hasTemplateImport) attachedProps.push(ssr ? ["ssrRender", "_sfc_ssrRender"] : ["render", "_sfc_render"]);
6234
6230
  else if (prevDescriptor && !isEqualBlock(descriptor.template, prevDescriptor.template)) attachedProps.push([ssr ? "ssrRender" : "render", "() => {}"]);
6235
6231
  const stylesCode = await genStyleCode(descriptor, pluginContext, customElement, attachedProps);
@@ -6237,7 +6233,6 @@ async function transformMain(code2, filename, options, pluginContext, ssr, custo
6237
6233
  const output = [
6238
6234
  scriptCode,
6239
6235
  templateCode,
6240
- isTemplateOnlyVapor ? `${scriptIdentifier}.__multiRoot = ${isTemplateInlined ? templateMultiRoot : "_sfc_multiRoot"}` : "",
6241
6236
  stylesCode,
6242
6237
  customBlocksCode
6243
6238
  ];
@@ -6319,21 +6314,15 @@ async function transformMain(code2, filename, options, pluginContext, ssr, custo
6319
6314
  async function genTemplateCode(descriptor, options, pluginContext, ssr, customElement) {
6320
6315
  const template = descriptor.template;
6321
6316
  const hasScoped = descriptor.styles.some((style) => style.scoped);
6322
- const needsMultiRoot = !descriptor.script && !descriptor.scriptSetup && isVaporMode(descriptor, options);
6323
- if ((!template.lang || template.lang === "html") && !template.src) {
6324
- const result = transformTemplateInMain(template.content, descriptor, options, pluginContext, ssr, customElement);
6325
- return {
6326
- ...result,
6327
- multiRoot: needsMultiRoot ? result.multiRoot : void 0
6328
- };
6329
- } else {
6317
+ if ((!template.lang || template.lang === "html") && !template.src) return transformTemplateInMain(template.content, descriptor, options, pluginContext, ssr, customElement);
6318
+ else {
6330
6319
  if (template.src) await linkSrcToDescriptor(template.src, descriptor, pluginContext, hasScoped);
6331
6320
  const src = template.src || descriptor.filename;
6332
6321
  const query2 = `?vue&type=template${template.src ? hasScoped ? `&src=${descriptor.id}` : "&src=true" : ""}${hasScoped ? `&scoped=${descriptor.id}` : ``}${attrsToQuery(template.attrs, "js", true)}`;
6333
6322
  const request = JSON.stringify(src + query2);
6334
6323
  const renderFnName = ssr ? "ssrRender" : "render";
6335
6324
  return {
6336
- code: `import { ${renderFnName} as _sfc_${renderFnName}${needsMultiRoot ? ", multiRoot as _sfc_multiRoot" : ""} } from ${request}`,
6325
+ code: `import { ${renderFnName} as _sfc_${renderFnName} } from ${request}`,
6337
6326
  map: void 0
6338
6327
  };
6339
6328
  }
@@ -7128,7 +7117,7 @@ function getLocator(source) {
7128
7117
  return { line, column };
7129
7118
  };
7130
7119
  }
7131
- var wordRegex = /\w/;
7120
+ var wordRegex2 = /\w/;
7132
7121
  var Mappings = class {
7133
7122
  constructor(hires) {
7134
7123
  this.hires = hires;
@@ -7184,7 +7173,7 @@ var Mappings = class {
7184
7173
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
7185
7174
  const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
7186
7175
  if (this.hires === "boundary") {
7187
- if (wordRegex.test(original[originalCharIndex])) {
7176
+ if (wordRegex2.test(original[originalCharIndex])) {
7188
7177
  if (!charInHiresBoundary) {
7189
7178
  this.rawSegments.push(segment);
7190
7179
  charInHiresBoundary = true;
@@ -8640,9 +8629,9 @@ var defaultConfig = {
8640
8629
  function overwriteMerge(_a, b) {
8641
8630
  return b;
8642
8631
  }
8643
- function defineConfig(config = {}) {
8632
+ function defineConfig(rootDir2, config = {}) {
8644
8633
  return viteDefineConfig(({ mode }) => {
8645
- return fkDefineConfig(mode, config);
8634
+ return fkDefineConfig(rootDir2, mode, config);
8646
8635
  });
8647
8636
  }
8648
8637
  function shouldUseCustomEntrypoint(options) {
@@ -8658,7 +8647,7 @@ function shouldUseCustomEntrypoint(options) {
8658
8647
  }
8659
8648
  return !config.fk?.entrypoint;
8660
8649
  }
8661
- async function fkDefineConfig(mode, config = {}) {
8650
+ async function fkDefineConfig(_rootDir, mode, config = {}) {
8662
8651
  const argv = process.argv.slice(2);
8663
8652
  const positional = argv.filter((it) => !it.startsWith("-"));
8664
8653
  config.fk ??= {};
@@ -769,7 +769,7 @@ function generateViteConfig() {
769
769
  `import { defineConfig } from "@forsakringskassan/vite-lib-config/vite";`,
770
770
  `import { defineTestConfig } from "@forsakringskassan/vitest-config-jsdom";`,
771
771
  ``,
772
- `export default defineConfig({`,
772
+ `export default defineConfig(import.meta.dirname, {`,
773
773
  ` test: defineTestConfig(),`,
774
774
  `});`
775
775
  ].map((it) => `${it}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vite-lib-config",
3
- "version": "5.15.2",
3
+ "version": "6.0.0",
4
4
  "description": "Försäkringskassan toolchain to build libraries with Vite",
5
5
  "keywords": [
6
6
  "vite"