@forsakringskassan/vite-lib-config 3.2.0 → 3.3.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
@@ -84,7 +84,15 @@ Use `--help` to see full description.
84
84
 
85
85
  ### Dev-server
86
86
 
87
- Create `src/local.ts` exporting a single function `setup`:
87
+ ```json
88
+ {
89
+ "scripts": {
90
+ "start": "vite"
91
+ }
92
+ }
93
+ ```
94
+
95
+ Create `src/local.{ts,mts,mjs,js}` exporting a single function `setup`:
88
96
 
89
97
  ```
90
98
  import { createApp } from "vue";
package/assets/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <div id="app"></div>
11
11
 
12
12
  <script type="module">
13
- import { setup } from "/src/local.ts";
13
+ import { setup } from "{{ entrypointLocal }}";
14
14
  import App from "{{ entrypoint }}";
15
15
 
16
16
  const selector = "#app";
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.48.1"
8
+ "packageVersion": "7.49.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -336,7 +336,7 @@ var require_dist = __commonJS({
336
336
  "node_modules/@vitejs/plugin-vue/dist/index.cjs"(exports2, module2) {
337
337
  "use strict";
338
338
  Object.defineProperty(exports2, "__esModule", { value: true });
339
- var fs4 = require("node:fs");
339
+ var fs5 = require("node:fs");
340
340
  var vite = require("vite");
341
341
  var vue = require("vue");
342
342
  var node_module = require("node:module");
@@ -348,7 +348,7 @@ var require_dist = __commonJS({
348
348
  function _interopDefaultCompat(e) {
349
349
  return e && typeof e === "object" && "default" in e ? e.default : e;
350
350
  }
351
- var fs__default = /* @__PURE__ */ _interopDefaultCompat(fs4);
351
+ var fs__default = /* @__PURE__ */ _interopDefaultCompat(fs5);
352
352
  var path__default = /* @__PURE__ */ _interopDefaultCompat(path4);
353
353
  var crypto__default = /* @__PURE__ */ _interopDefaultCompat(crypto);
354
354
  var require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0);
@@ -4949,6 +4949,23 @@ function customMappingPlugin() {
4949
4949
  // src/plugins/index-html-plugin.ts
4950
4950
  var import_promises = __toESM(require("node:fs/promises"));
4951
4951
  var import_node_path = __toESM(require("node:path"));
4952
+
4953
+ // src/utils/lookupFile.ts
4954
+ var import_node_fs = __toESM(require("node:fs"));
4955
+ var extensions = ["ts", "mts", "mjs", "js"];
4956
+ function lookupFile(nameWithoutExtension) {
4957
+ for (const extension of extensions) {
4958
+ const fileName = `${nameWithoutExtension}.${extension}`;
4959
+ if (import_node_fs.default.existsSync(fileName)) {
4960
+ return fileName;
4961
+ }
4962
+ }
4963
+ throw new Error(
4964
+ `Entry is missing. ${nameWithoutExtension}.{${extensions.join(",")}}`
4965
+ );
4966
+ }
4967
+
4968
+ // src/plugins/index-html-plugin.ts
4952
4969
  var templateFile = import_node_path.default.resolve(__dirname, "../assets/index.html");
4953
4970
  var VIRTUAL_ENTRYPOINT = "index.html";
4954
4971
  function isHtmlPage(url) {
@@ -4975,7 +4992,8 @@ function middleware(server) {
4975
4992
  }
4976
4993
  function indexHtmlPlugin() {
4977
4994
  const templateData = {
4978
- entrypoint: "/src/vite-dev/app.vue"
4995
+ entrypoint: "/src/vite-dev/app.vue",
4996
+ entrypointLocal: `/${lookupFile("src/local")}`
4979
4997
  };
4980
4998
  return {
4981
4999
  name: "fk:virtual-entrypoint",
@@ -9672,8 +9690,8 @@ var PathScurryBase = class {
9672
9690
  *
9673
9691
  * @internal
9674
9692
  */
9675
- constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs4 = defaultFS } = {}) {
9676
- this.#fs = fsFromOption(fs4);
9693
+ constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs5 = defaultFS } = {}) {
9694
+ this.#fs = fsFromOption(fs5);
9677
9695
  if (cwd instanceof URL || cwd.startsWith("file://")) {
9678
9696
  cwd = (0, import_node_url.fileURLToPath)(cwd);
9679
9697
  }
@@ -10231,8 +10249,8 @@ var PathScurryWin32 = class extends PathScurryBase {
10231
10249
  /**
10232
10250
  * @internal
10233
10251
  */
10234
- newRoot(fs4) {
10235
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
10252
+ newRoot(fs5) {
10253
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs5 });
10236
10254
  }
10237
10255
  /**
10238
10256
  * Return true if the provided path string is an absolute path
@@ -10260,8 +10278,8 @@ var PathScurryPosix = class extends PathScurryBase {
10260
10278
  /**
10261
10279
  * @internal
10262
10280
  */
10263
- newRoot(fs4) {
10264
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
10281
+ newRoot(fs5) {
10282
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs5 });
10265
10283
  }
10266
10284
  /**
10267
10285
  * Return true if the provided path string is an absolute path
@@ -11340,9 +11358,9 @@ var glob = Object.assign(glob_, {
11340
11358
  glob.glob = glob;
11341
11359
 
11342
11360
  // src/utils/read-json-file.ts
11343
- var import_node_fs = __toESM(require("node:fs"));
11361
+ var import_node_fs2 = __toESM(require("node:fs"));
11344
11362
  function readJsonFile(filename) {
11345
- return JSON.parse(import_node_fs.default.readFileSync(filename, "utf-8"));
11363
+ return JSON.parse(import_node_fs2.default.readFileSync(filename, "utf-8"));
11346
11364
  }
11347
11365
 
11348
11366
  // src/utils/detect-monorepo-packages.ts
@@ -11572,7 +11590,7 @@ var defaultConfig = {
11572
11590
  sourcemap: true,
11573
11591
  outDir: "dist/[custom-format]",
11574
11592
  lib: {
11575
- entry: "src/index.ts",
11593
+ entry: lookupFile("src/index"),
11576
11594
  formats: ["es", "cjs"]
11577
11595
  },
11578
11596
  rollupOptions: {
@@ -4925,8 +4925,25 @@ function customMappingPlugin() {
4925
4925
  }
4926
4926
 
4927
4927
  // src/plugins/index-html-plugin.ts
4928
- import fs2 from "node:fs/promises";
4928
+ import fs3 from "node:fs/promises";
4929
4929
  import path2 from "node:path";
4930
+
4931
+ // src/utils/lookupFile.ts
4932
+ import fs2 from "node:fs";
4933
+ var extensions = ["ts", "mts", "mjs", "js"];
4934
+ function lookupFile(nameWithoutExtension) {
4935
+ for (const extension of extensions) {
4936
+ const fileName = `${nameWithoutExtension}.${extension}`;
4937
+ if (fs2.existsSync(fileName)) {
4938
+ return fileName;
4939
+ }
4940
+ }
4941
+ throw new Error(
4942
+ `Entry is missing. ${nameWithoutExtension}.{${extensions.join(",")}}`
4943
+ );
4944
+ }
4945
+
4946
+ // src/plugins/index-html-plugin.ts
4930
4947
  var templateFile = path2.resolve(__dirname, "../assets/index.html");
4931
4948
  var VIRTUAL_ENTRYPOINT = "index.html";
4932
4949
  function isHtmlPage(url) {
@@ -4953,7 +4970,8 @@ function middleware(server) {
4953
4970
  }
4954
4971
  function indexHtmlPlugin() {
4955
4972
  const templateData = {
4956
- entrypoint: "/src/vite-dev/app.vue"
4973
+ entrypoint: "/src/vite-dev/app.vue",
4974
+ entrypointLocal: `/${lookupFile("src/local")}`
4957
4975
  };
4958
4976
  return {
4959
4977
  name: "fk:virtual-entrypoint",
@@ -4977,7 +4995,7 @@ function indexHtmlPlugin() {
4977
4995
  transformIndexHtml: {
4978
4996
  order: "pre",
4979
4997
  async handler() {
4980
- const content = await fs2.readFile(templateFile, "utf-8");
4998
+ const content = await fs3.readFile(templateFile, "utf-8");
4981
4999
  return content.replace(/{{([^}]+)}}/g, (match2, key) => {
4982
5000
  return templateData[key.trim()] ?? match2;
4983
5001
  });
@@ -5036,7 +5054,7 @@ function detectInternalDependencies(packages2, dependencies2) {
5036
5054
  }
5037
5055
 
5038
5056
  // src/utils/detect-monorepo-packages.ts
5039
- import fs4 from "fs";
5057
+ import fs5 from "fs";
5040
5058
  import path4 from "node:path";
5041
5059
 
5042
5060
  // node_modules/glob/node_modules/minimatch/dist/esm/index.js
@@ -9650,8 +9668,8 @@ var PathScurryBase = class {
9650
9668
  *
9651
9669
  * @internal
9652
9670
  */
9653
- constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs5 = defaultFS } = {}) {
9654
- this.#fs = fsFromOption(fs5);
9671
+ constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs6 = defaultFS } = {}) {
9672
+ this.#fs = fsFromOption(fs6);
9655
9673
  if (cwd instanceof URL || cwd.startsWith("file://")) {
9656
9674
  cwd = fileURLToPath(cwd);
9657
9675
  }
@@ -10209,8 +10227,8 @@ var PathScurryWin32 = class extends PathScurryBase {
10209
10227
  /**
10210
10228
  * @internal
10211
10229
  */
10212
- newRoot(fs5) {
10213
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs5 });
10230
+ newRoot(fs6) {
10231
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs6 });
10214
10232
  }
10215
10233
  /**
10216
10234
  * Return true if the provided path string is an absolute path
@@ -10238,8 +10256,8 @@ var PathScurryPosix = class extends PathScurryBase {
10238
10256
  /**
10239
10257
  * @internal
10240
10258
  */
10241
- newRoot(fs5) {
10242
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs5 });
10259
+ newRoot(fs6) {
10260
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs6 });
10243
10261
  }
10244
10262
  /**
10245
10263
  * Return true if the provided path string is an absolute path
@@ -11318,15 +11336,15 @@ var glob = Object.assign(glob_, {
11318
11336
  glob.glob = glob;
11319
11337
 
11320
11338
  // src/utils/read-json-file.ts
11321
- import fs3 from "node:fs";
11339
+ import fs4 from "node:fs";
11322
11340
  function readJsonFile(filename) {
11323
- return JSON.parse(fs3.readFileSync(filename, "utf-8"));
11341
+ return JSON.parse(fs4.readFileSync(filename, "utf-8"));
11324
11342
  }
11325
11343
 
11326
11344
  // src/utils/detect-monorepo-packages.ts
11327
11345
  function detectMonorepoPackages(...pkgPaths) {
11328
11346
  for (const pkgPath of pkgPaths) {
11329
- if (!fs4.existsSync(pkgPath)) {
11347
+ if (!fs5.existsSync(pkgPath)) {
11330
11348
  continue;
11331
11349
  }
11332
11350
  const rootDir = path4.dirname(pkgPath);
@@ -11552,7 +11570,7 @@ var defaultConfig = {
11552
11570
  sourcemap: true,
11553
11571
  outDir: "dist/[custom-format]",
11554
11572
  lib: {
11555
- entry: "src/index.ts",
11573
+ entry: lookupFile("src/index"),
11556
11574
  formats: ["es", "cjs"]
11557
11575
  },
11558
11576
  rollupOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vite-lib-config",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Försäkringskassan toolchain to build libraries with Vite",
5
5
  "keywords": [
6
6
  "vite"
@@ -42,7 +42,7 @@
42
42
  "dist"
43
43
  ],
44
44
  "dependencies": {
45
- "@microsoft/api-extractor": "7.48.1",
45
+ "@microsoft/api-extractor": "7.49.1",
46
46
  "@vue/babel-preset-app": "5.0.8"
47
47
  },
48
48
  "peerDependencies": {