@forsakringskassan/vite-lib-config 5.12.5 → 5.13.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.
@@ -0,0 +1,67 @@
1
+ (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`header[data-v-96545601]{color:#fff;background-color:#116a3e;padding:1rem}h1[data-v-96545601]{margin:0;font-size:1.5rem}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
2
+ import { Fragment as e, createBlock as t, createElementBlock as n, createElementVNode as r, createTextVNode as i, createVNode as a, defineComponent as o, getCurrentInstance as s, openBlock as c, renderList as l, toDisplayString as u, unref as d, withCtx as f } from "vue";
3
+ import { RouterLink as p, RouterView as m, createRouter as h, createWebHashHistory as g } from "vue-router";
4
+ //#region src/fallback/FallbackHome.vue?vue&type=script&setup=true&lang.ts
5
+ var _ = { key: 0 }, v = { key: 1 }, y = /*#__PURE__*/ ((e, t) => {
6
+ let n = e.__vccOpts || e;
7
+ for (let [e, r] of t) n[e] = r;
8
+ return n;
9
+ })(/* @__PURE__ */ o({
10
+ __name: "FallbackHome",
11
+ props: { examples: {} },
12
+ setup(t) {
13
+ return (o, s) => (c(), n("div", null, [s[3] ||= r("header", null, [r("h1", null, "@forsakringskassan/vite-lib-config")], -1), t.examples.length === 0 ? (c(), n("p", _, [...s[0] ||= [
14
+ i("Create a new vue example at ", -1),
15
+ r("b", null, "./src/examples/**", -1),
16
+ i(" to get started.", -1)
17
+ ]])) : (c(), n("div", v, [
18
+ s[1] ||= r("p", null, "Start one of the following examples directly:", -1),
19
+ r("ul", null, [(c(!0), n(e, null, l(t.examples, (e) => (c(), n("li", { key: e }, [a(d(p), { to: `/${e}` }, {
20
+ default: f(() => [i(u(e), 1)]),
21
+ _: 2
22
+ }, 1032, ["to"])]))), 128))]),
23
+ s[2] ||= r("p", null, "Or from your terminal, type:", -1),
24
+ r("pre", null, "$ npm start -- " + u(t.examples[0]), 1)
25
+ ]))]));
26
+ }
27
+ }), [["__scopeId", "data-v-96545601"]]), b = /* @__PURE__ */ o({
28
+ __name: "NotFound",
29
+ setup(e) {
30
+ return (e, t) => (c(), n("div", null, [
31
+ t[1] ||= r("h1", null, "404", -1),
32
+ t[2] ||= r("p", null, "Example not found.", -1),
33
+ a(d(p), { to: "/" }, {
34
+ default: f(() => [...t[0] ||= [i("Back to start page", -1)]]),
35
+ _: 1
36
+ })
37
+ ]));
38
+ }
39
+ }), x = /* @__PURE__ */ o({
40
+ __name: "App",
41
+ setup(e) {
42
+ let n = __AVAILABLE_EXAMPLES__, r = n.map((e) => ({
43
+ path: `/${e}`,
44
+ component: () => import(
45
+ /* @vite-ignore */
46
+ `/${e}`
47
+ )
48
+ })), i = h({
49
+ history: g(),
50
+ routes: [
51
+ {
52
+ path: "/",
53
+ component: y,
54
+ props: { examples: n }
55
+ },
56
+ ...r,
57
+ {
58
+ path: "/:pathMatch(.*)*",
59
+ component: b
60
+ }
61
+ ]
62
+ });
63
+ return s().appContext.app.use(i), (e, n) => (c(), t(d(m)));
64
+ }
65
+ });
66
+ //#endregion
67
+ export { x as default };
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.2"
8
+ "packageVersion": "7.59.3"
9
9
  }
10
10
  ]
11
11
  }
@@ -4706,6 +4706,7 @@ __export(vite_config_exports, {
4706
4706
  vuePlugin: () => vuePlugin2
4707
4707
  });
4708
4708
  module.exports = __toCommonJS(vite_config_exports);
4709
+ var import_node_fs4 = require("node:fs");
4709
4710
  var import_node_path4 = __toESM(require("node:path"));
4710
4711
  var import_vite2 = require("vite");
4711
4712
  var import_apimock_express = require("@forsakringskassan/apimock-express");
@@ -11168,7 +11169,8 @@ function middleware(server) {
11168
11169
  }
11169
11170
  function indexHtmlPlugin() {
11170
11171
  const templateData = {
11171
- entrypoint: "/src/vite-dev/app.vue",
11172
+ entrypoint: "",
11173
+ // Defined by config
11172
11174
  entrypointLocal: `/${lookupFile("src/local")}`
11173
11175
  };
11174
11176
  return {
@@ -11203,9 +11205,10 @@ function indexHtmlPlugin() {
11203
11205
  }
11204
11206
  },
11205
11207
  config(config) {
11206
- if (config.fk?.entrypoint) {
11207
- templateData.entrypoint = config.fk.entrypoint;
11208
+ if (!config.fk?.entrypoint) {
11209
+ return;
11208
11210
  }
11211
+ templateData.entrypoint = config.fk.entrypoint;
11209
11212
  },
11210
11213
  configureServer(server) {
11211
11214
  server.middlewares.use(middleware(server));
@@ -11240,6 +11243,7 @@ function packageJsonPlugin() {
11240
11243
 
11241
11244
  // src/vite.config.ts
11242
11245
  var import_apimock_express2 = require("@forsakringskassan/apimock-express");
11246
+ var defaultEntrypoint = "src/vite-dev/app.vue";
11243
11247
  function isExternal(externals, name) {
11244
11248
  for (const external2 of externals) {
11245
11249
  const matchRegexp = external2 instanceof RegExp && external2.test(name);
@@ -11284,16 +11288,20 @@ function vuePlugin2(config) {
11284
11288
  return vuePlugin(resolvedConfig);
11285
11289
  }
11286
11290
  }
11287
- async function findEntrypoint(pattern) {
11288
- if (!pattern) {
11289
- const defaultEntrypoint = "/src/vite-dev/app.vue";
11290
- return defaultEntrypoint;
11291
- }
11292
- const uf = new import_ufuzzy.default({ intraIns: Infinity });
11291
+ async function getExamples() {
11293
11292
  const files = await Ze("**/{examples,docs,tests}/**/*.vue", {
11294
11293
  posix: true,
11295
11294
  nodir: true
11296
11295
  });
11296
+ return files;
11297
+ }
11298
+ async function findEntrypoint(pattern) {
11299
+ if (!pattern) {
11300
+ const defaultEntrypoint2 = "/src/vite-dev/app.vue";
11301
+ return defaultEntrypoint2;
11302
+ }
11303
+ const uf = new import_ufuzzy.default({ intraIns: Infinity });
11304
+ const files = await getExamples();
11297
11305
  const idxs = uf.filter(files, pattern);
11298
11306
  if (!idxs || idxs.length === 0) {
11299
11307
  throw new Error(`No files matching "${pattern}"`);
@@ -11350,6 +11358,7 @@ if (process.env.CYPRESS) {
11350
11358
  var defaultConfig = {
11351
11359
  fk: {},
11352
11360
  plugins: defaultPlugins,
11361
+ define: {},
11353
11362
  build: {
11354
11363
  emptyOutDir: false,
11355
11364
  minify: false,
@@ -11426,9 +11435,12 @@ async function fkDefineConfig(mode, config = {}) {
11426
11435
  positional,
11427
11436
  mode
11428
11437
  });
11438
+ config.fk.entrypoint = `/${defaultEntrypoint}`;
11439
+ if (!(0, import_node_fs4.existsSync)(defaultEntrypoint)) {
11440
+ config.fk.entrypoint = "@forsakringskassan/vite-lib-config/vue-fallback";
11441
+ }
11429
11442
  if (useCustomEntrypoint) {
11430
- const entrypoint = await findEntrypoint(positional[0]);
11431
- config.fk.entrypoint = `/${entrypoint}`;
11443
+ config.fk.entrypoint = `/${await findEntrypoint(positional[0])}`;
11432
11444
  }
11433
11445
  let result;
11434
11446
  if (config) {
@@ -11440,6 +11452,10 @@ async function fkDefineConfig(mode, config = {}) {
11440
11452
  } else {
11441
11453
  result = defaultConfig;
11442
11454
  }
11455
+ result.define = {
11456
+ ...result.define,
11457
+ __AVAILABLE_EXAMPLES__: JSON.stringify(await getExamples())
11458
+ };
11443
11459
  const { build } = result;
11444
11460
  const external2 = build?.rolldownOptions?.external ?? /* eslint-disable-next-line @typescript-eslint/no-deprecated -- for backwards compatibility */
11445
11461
  build?.rollupOptions?.external ?? [];
@@ -4697,6 +4697,7 @@ var require_semver2 = __commonJS({
4697
4697
 
4698
4698
  // src/vite.config.ts
4699
4699
  var import_ufuzzy = __toESM(require_uFuzzy());
4700
+ import { existsSync } from "node:fs";
4700
4701
  import path3 from "node:path";
4701
4702
  import {
4702
4703
  defineConfig as viteDefineConfig
@@ -11160,7 +11161,8 @@ function middleware(server) {
11160
11161
  }
11161
11162
  function indexHtmlPlugin() {
11162
11163
  const templateData = {
11163
- entrypoint: "/src/vite-dev/app.vue",
11164
+ entrypoint: "",
11165
+ // Defined by config
11164
11166
  entrypointLocal: `/${lookupFile("src/local")}`
11165
11167
  };
11166
11168
  return {
@@ -11195,9 +11197,10 @@ function indexHtmlPlugin() {
11195
11197
  }
11196
11198
  },
11197
11199
  config(config) {
11198
- if (config.fk?.entrypoint) {
11199
- templateData.entrypoint = config.fk.entrypoint;
11200
+ if (!config.fk?.entrypoint) {
11201
+ return;
11200
11202
  }
11203
+ templateData.entrypoint = config.fk.entrypoint;
11201
11204
  },
11202
11205
  configureServer(server) {
11203
11206
  server.middlewares.use(middleware(server));
@@ -11234,6 +11237,7 @@ function packageJsonPlugin() {
11234
11237
  import {
11235
11238
  vitePlugin
11236
11239
  } from "@forsakringskassan/apimock-express";
11240
+ var defaultEntrypoint = "src/vite-dev/app.vue";
11237
11241
  function isExternal(externals, name) {
11238
11242
  for (const external2 of externals) {
11239
11243
  const matchRegexp = external2 instanceof RegExp && external2.test(name);
@@ -11278,16 +11282,20 @@ function vuePlugin2(config) {
11278
11282
  return vuePlugin(resolvedConfig);
11279
11283
  }
11280
11284
  }
11281
- async function findEntrypoint(pattern) {
11282
- if (!pattern) {
11283
- const defaultEntrypoint = "/src/vite-dev/app.vue";
11284
- return defaultEntrypoint;
11285
- }
11286
- const uf = new import_ufuzzy.default({ intraIns: Infinity });
11285
+ async function getExamples() {
11287
11286
  const files = await Ze("**/{examples,docs,tests}/**/*.vue", {
11288
11287
  posix: true,
11289
11288
  nodir: true
11290
11289
  });
11290
+ return files;
11291
+ }
11292
+ async function findEntrypoint(pattern) {
11293
+ if (!pattern) {
11294
+ const defaultEntrypoint2 = "/src/vite-dev/app.vue";
11295
+ return defaultEntrypoint2;
11296
+ }
11297
+ const uf = new import_ufuzzy.default({ intraIns: Infinity });
11298
+ const files = await getExamples();
11291
11299
  const idxs = uf.filter(files, pattern);
11292
11300
  if (!idxs || idxs.length === 0) {
11293
11301
  throw new Error(`No files matching "${pattern}"`);
@@ -11344,6 +11352,7 @@ if (process.env.CYPRESS) {
11344
11352
  var defaultConfig = {
11345
11353
  fk: {},
11346
11354
  plugins: defaultPlugins,
11355
+ define: {},
11347
11356
  build: {
11348
11357
  emptyOutDir: false,
11349
11358
  minify: false,
@@ -11420,9 +11429,12 @@ async function fkDefineConfig(mode, config = {}) {
11420
11429
  positional,
11421
11430
  mode
11422
11431
  });
11432
+ config.fk.entrypoint = `/${defaultEntrypoint}`;
11433
+ if (!existsSync(defaultEntrypoint)) {
11434
+ config.fk.entrypoint = "@forsakringskassan/vite-lib-config/vue-fallback";
11435
+ }
11423
11436
  if (useCustomEntrypoint) {
11424
- const entrypoint = await findEntrypoint(positional[0]);
11425
- config.fk.entrypoint = `/${entrypoint}`;
11437
+ config.fk.entrypoint = `/${await findEntrypoint(positional[0])}`;
11426
11438
  }
11427
11439
  let result;
11428
11440
  if (config) {
@@ -11434,6 +11446,10 @@ async function fkDefineConfig(mode, config = {}) {
11434
11446
  } else {
11435
11447
  result = defaultConfig;
11436
11448
  }
11449
+ result.define = {
11450
+ ...result.define,
11451
+ __AVAILABLE_EXAMPLES__: JSON.stringify(await getExamples())
11452
+ };
11437
11453
  const { build } = result;
11438
11454
  const external2 = build?.rolldownOptions?.external ?? /* eslint-disable-next-line @typescript-eslint/no-deprecated -- for backwards compatibility */
11439
11455
  build?.rollupOptions?.external ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vite-lib-config",
3
- "version": "5.12.5",
3
+ "version": "5.13.0",
4
4
  "description": "Försäkringskassan toolchain to build libraries with Vite",
5
5
  "keywords": [
6
6
  "vite"
@@ -33,6 +33,9 @@
33
33
  "types": "./dist/vite.config.d.ts",
34
34
  "import": "./dist/vite.config.mjs",
35
35
  "require": "./dist/vite.config.cjs"
36
+ },
37
+ "./vue-fallback": {
38
+ "default": "./dist/fallback.mjs"
36
39
  }
37
40
  },
38
41
  "main": "./dist/index.js",
@@ -52,7 +55,7 @@
52
55
  "tsconfig"
53
56
  ],
54
57
  "dependencies": {
55
- "@microsoft/api-extractor": "7.59.2",
58
+ "@microsoft/api-extractor": "7.59.3",
56
59
  "@vue/babel-preset-app": "5.0.9",
57
60
  "esbuild": "^0.28.0"
58
61
  },
@@ -64,7 +67,8 @@
64
67
  "prettier": "^3.0.0",
65
68
  "typescript": "^5.0.2 || ^6.0.2 || ^7.0.0",
66
69
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
67
- "vue": "^3.0.0"
70
+ "vue": "^3.0.0",
71
+ "vue-router": "^5.0.0"
68
72
  },
69
73
  "engines": {
70
74
  "node": "^22.12.0 || >= 24",