@forsakringskassan/vite-lib-config 4.6.9 → 4.7.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 +16 -0
- package/bin/build-selectors.mjs +12 -0
- package/dist/build-selectors.js +83 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Toolchain for building Vue framework libraries.
|
|
|
5
5
|
- Hybrid ESM/CJS packages.
|
|
6
6
|
- Transpiled with Babel.
|
|
7
7
|
- Supports monorepo.
|
|
8
|
+
- Optional: build pageobjects and selectors.
|
|
8
9
|
|
|
9
10
|
## Configuration
|
|
10
11
|
|
|
@@ -82,6 +83,21 @@ To fix global module augmentations use:
|
|
|
82
83
|
|
|
83
84
|
Use `--help` to see full description.
|
|
84
85
|
|
|
86
|
+
### Optional: build pageobjects and selectors
|
|
87
|
+
|
|
88
|
+
```diff
|
|
89
|
+
{
|
|
90
|
+
"scripts": {
|
|
91
|
+
"build": "fk-build-vue-lib",
|
|
92
|
+
+ "build:selectors": "fk-build-selectors",
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If `src/selectors/index.ts` it will be built to `dist/${format}/selectors.${cjs,mjs}`.
|
|
98
|
+
|
|
99
|
+
If `src/cypress/index.ts` it will be built to `dist/${format}/cypress.${cjs,mjs}`.
|
|
100
|
+
|
|
85
101
|
### Dev-server
|
|
86
102
|
|
|
87
103
|
```json
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/build-selectors.ts
|
|
30
|
+
var build_selectors_exports = {};
|
|
31
|
+
__export(build_selectors_exports, {
|
|
32
|
+
run: () => run
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(build_selectors_exports);
|
|
35
|
+
var import_node_fs = require("node:fs");
|
|
36
|
+
var import_posix = __toESM(require("node:path/posix"));
|
|
37
|
+
var esbuild = __toESM(require("esbuild"));
|
|
38
|
+
var extension = {
|
|
39
|
+
cjs: ".cjs",
|
|
40
|
+
esm: ".mjs"
|
|
41
|
+
};
|
|
42
|
+
async function build2(entrypoint, formats) {
|
|
43
|
+
if (!(0, import_node_fs.existsSync)(entrypoint)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const basename = import_posix.default.basename(import_posix.default.dirname(entrypoint));
|
|
47
|
+
for (const format of formats) {
|
|
48
|
+
const result = await esbuild.build({
|
|
49
|
+
entryPoints: [entrypoint],
|
|
50
|
+
outfile: `dist/${format}/${basename}.${format}.js`,
|
|
51
|
+
bundle: true,
|
|
52
|
+
platform: "browser",
|
|
53
|
+
format,
|
|
54
|
+
target: "chrome119",
|
|
55
|
+
sourcemap: true,
|
|
56
|
+
outExtension: {
|
|
57
|
+
".js": extension[format]
|
|
58
|
+
},
|
|
59
|
+
logLevel: "info",
|
|
60
|
+
metafile: true
|
|
61
|
+
});
|
|
62
|
+
if (format === "esm") {
|
|
63
|
+
const output = await esbuild.analyzeMetafile(result.metafile);
|
|
64
|
+
console.log(output);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function run(argv) {
|
|
69
|
+
const flags = new Set(argv.filter((it) => it.startsWith("--")));
|
|
70
|
+
if (flags.has("--help")) {
|
|
71
|
+
console.log("usage: fk-build-selectors [OPTIONS..]");
|
|
72
|
+
console.log(`
|
|
73
|
+
--help Show this help.
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
const formats = ["cjs", "esm"];
|
|
77
|
+
await build2("src/cypress/index.ts", formats);
|
|
78
|
+
await build2("src/selectors/index.ts", formats);
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
run
|
|
83
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/vite-lib-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Försäkringskassan toolchain to build libraries with Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite"
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
34
|
"bin": {
|
|
35
35
|
"fk-api-extractor": "bin/api-extractor.js",
|
|
36
|
-
"fk-build-vue-lib": "bin/build-vue-lib.mjs"
|
|
36
|
+
"fk-build-vue-lib": "bin/build-vue-lib.mjs",
|
|
37
|
+
"fk-build-selectors": "bin/build-selectors.mjs"
|
|
37
38
|
},
|
|
38
39
|
"files": [
|
|
39
40
|
"*.d.ts",
|
|
@@ -43,7 +44,8 @@
|
|
|
43
44
|
],
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@microsoft/api-extractor": "7.58.7",
|
|
46
|
-
"@vue/babel-preset-app": "5.0.9"
|
|
47
|
+
"@vue/babel-preset-app": "5.0.9",
|
|
48
|
+
"esbuild": "^0.28.0"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"@babel/core": "^7.22.0",
|