@forsakringskassan/vite-lib-config 4.7.0 → 4.7.1

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.
@@ -29,17 +29,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/build-selectors.ts
30
30
  var build_selectors_exports = {};
31
31
  __export(build_selectors_exports, {
32
+ getExternals: () => getExternals,
32
33
  run: () => run
33
34
  });
34
35
  module.exports = __toCommonJS(build_selectors_exports);
35
36
  var import_node_fs = require("node:fs");
37
+ var import_promises = __toESM(require("node:fs/promises"));
36
38
  var import_posix = __toESM(require("node:path/posix"));
37
39
  var esbuild = __toESM(require("esbuild"));
38
40
  var extension = {
39
41
  cjs: ".cjs",
40
42
  esm: ".mjs"
41
43
  };
42
- async function build2(entrypoint, formats) {
44
+ async function build2(entrypoint, options) {
45
+ const { external, formats } = options;
43
46
  if (!(0, import_node_fs.existsSync)(entrypoint)) {
44
47
  return;
45
48
  }
@@ -53,6 +56,7 @@ async function build2(entrypoint, formats) {
53
56
  format,
54
57
  target: "chrome119",
55
58
  sourcemap: true,
59
+ external,
56
60
  outExtension: {
57
61
  ".js": extension[format]
58
62
  },
@@ -65,6 +69,18 @@ async function build2(entrypoint, formats) {
65
69
  }
66
70
  }
67
71
  }
72
+ async function readJsonFile(filePath) {
73
+ const content = await import_promises.default.readFile(filePath, "utf8");
74
+ return JSON.parse(content);
75
+ }
76
+ function getExternals(pkg) {
77
+ const { peerDependencies = {}, externalDependencies = [] } = pkg;
78
+ const unique = /* @__PURE__ */ new Set([
79
+ ...Object.keys(peerDependencies),
80
+ ...externalDependencies
81
+ ]);
82
+ return Array.from(unique).toSorted((a, b) => a.localeCompare(b));
83
+ }
68
84
  async function run(argv) {
69
85
  const flags = new Set(argv.filter((it) => it.startsWith("--")));
70
86
  if (flags.has("--help")) {
@@ -73,11 +89,14 @@ async function run(argv) {
73
89
  --help Show this help.
74
90
  `);
75
91
  }
92
+ const pkg = await readJsonFile("package.json");
93
+ const external = getExternals(pkg);
76
94
  const formats = ["cjs", "esm"];
77
- await build2("src/cypress/index.ts", formats);
78
- await build2("src/selectors/index.ts", formats);
95
+ await build2("src/cypress/index.ts", { external, formats });
96
+ await build2("src/selectors/index.ts", { external, formats });
79
97
  }
80
98
  // Annotate the CommonJS export names for ESM import in node:
81
99
  0 && (module.exports = {
100
+ getExternals,
82
101
  run
83
102
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vite-lib-config",
3
- "version": "4.7.0",
3
+ "version": "4.7.1",
4
4
  "description": "Försäkringskassan toolchain to build libraries with Vite",
5
5
  "keywords": [
6
6
  "vite"