@forsakringskassan/vite-lib-config 1.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.
@@ -0,0 +1,3 @@
1
+ import { type TransformOptions } from "@babel/core";
2
+ declare function babelPreset(): TransformOptions;
3
+ export = babelPreset;
@@ -0,0 +1,39 @@
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 __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+
24
+ // src/babel.config.ts
25
+ function babelPreset() {
26
+ return {
27
+ plugins: [
28
+ /* we need this plugin for force `??` to be transpiled or Cypress/Webpack chokes on it */
29
+ require.resolve("@babel/plugin-transform-nullish-coalescing-operator")
30
+ ],
31
+ presets: [
32
+ [
33
+ require.resolve("@vue/babel-preset-app"),
34
+ { absoluteRuntime: false }
35
+ ]
36
+ ]
37
+ };
38
+ }
39
+ module.exports = babelPreset;
package/dist/cli.js ADDED
@@ -0,0 +1,165 @@
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 __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // node_modules/picocolors/picocolors.js
33
+ var require_picocolors = __commonJS({
34
+ "node_modules/picocolors/picocolors.js"(exports2, module2) {
35
+ var tty = require("tty");
36
+ var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
37
+ var formatter = (open, close, replace = open) => (input) => {
38
+ let string = "" + input;
39
+ let index = string.indexOf(close, open.length);
40
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
41
+ };
42
+ var replaceClose = (string, close, replace, index) => {
43
+ let start = string.substring(0, index) + replace;
44
+ let end = string.substring(index + close.length);
45
+ let nextIndex = end.indexOf(close);
46
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
47
+ };
48
+ var createColors = (enabled = isColorSupported) => ({
49
+ isColorSupported: enabled,
50
+ reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String,
51
+ bold: enabled ? formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
52
+ dim: enabled ? formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
53
+ italic: enabled ? formatter("\x1B[3m", "\x1B[23m") : String,
54
+ underline: enabled ? formatter("\x1B[4m", "\x1B[24m") : String,
55
+ inverse: enabled ? formatter("\x1B[7m", "\x1B[27m") : String,
56
+ hidden: enabled ? formatter("\x1B[8m", "\x1B[28m") : String,
57
+ strikethrough: enabled ? formatter("\x1B[9m", "\x1B[29m") : String,
58
+ black: enabled ? formatter("\x1B[30m", "\x1B[39m") : String,
59
+ red: enabled ? formatter("\x1B[31m", "\x1B[39m") : String,
60
+ green: enabled ? formatter("\x1B[32m", "\x1B[39m") : String,
61
+ yellow: enabled ? formatter("\x1B[33m", "\x1B[39m") : String,
62
+ blue: enabled ? formatter("\x1B[34m", "\x1B[39m") : String,
63
+ magenta: enabled ? formatter("\x1B[35m", "\x1B[39m") : String,
64
+ cyan: enabled ? formatter("\x1B[36m", "\x1B[39m") : String,
65
+ white: enabled ? formatter("\x1B[37m", "\x1B[39m") : String,
66
+ gray: enabled ? formatter("\x1B[90m", "\x1B[39m") : String,
67
+ bgBlack: enabled ? formatter("\x1B[40m", "\x1B[49m") : String,
68
+ bgRed: enabled ? formatter("\x1B[41m", "\x1B[49m") : String,
69
+ bgGreen: enabled ? formatter("\x1B[42m", "\x1B[49m") : String,
70
+ bgYellow: enabled ? formatter("\x1B[43m", "\x1B[49m") : String,
71
+ bgBlue: enabled ? formatter("\x1B[44m", "\x1B[49m") : String,
72
+ bgMagenta: enabled ? formatter("\x1B[45m", "\x1B[49m") : String,
73
+ bgCyan: enabled ? formatter("\x1B[46m", "\x1B[49m") : String,
74
+ bgWhite: enabled ? formatter("\x1B[47m", "\x1B[49m") : String
75
+ });
76
+ module2.exports = createColors();
77
+ module2.exports.createColors = createColors;
78
+ }
79
+ });
80
+
81
+ // src/cli.ts
82
+ var cli_exports = {};
83
+ __export(cli_exports, {
84
+ cli: () => cli
85
+ });
86
+ module.exports = __toCommonJS(cli_exports);
87
+ var import_promises = __toESM(require("node:fs/promises"));
88
+ var import_node_fs = require("node:fs");
89
+ var import_vite = require("vite");
90
+ var import_picocolors = __toESM(require_picocolors());
91
+ var babel = __toESM(require("@babel/core"));
92
+ var cjsSrcFile = "temp/index.cjs.js";
93
+ var esSrcFile = "temp/index.es.js";
94
+ var dstDir = "lib";
95
+ var cjsDstFile = `${dstDir}/index.cjs.js`;
96
+ var esDstFile = `${dstDir}/index.es.js`;
97
+ var logger = (0, import_vite.createLogger)();
98
+ function displayTime(time) {
99
+ if (time < 1e3) {
100
+ return `${time}ms`;
101
+ }
102
+ time = time / 1e3;
103
+ if (time < 60) {
104
+ return `${time.toFixed(2)}s`;
105
+ }
106
+ const mins = parseInt((time / 60).toString(), 10);
107
+ const seconds = time % 60;
108
+ const minuteString = `${mins}m`;
109
+ const secondString = seconds < 1 ? "" : ` ${seconds.toFixed(0)}s`;
110
+ return `${minuteString}m${secondString}`;
111
+ }
112
+ function prettySize(size) {
113
+ if (size < 1024) {
114
+ return `${size} B`;
115
+ } else if (size < 1024 * 1024) {
116
+ const divisor = 1024;
117
+ const rounded = (size / divisor).toFixed(2);
118
+ return `${rounded} kB`;
119
+ } else {
120
+ const divisor = 1024 * 1024;
121
+ const rounded = (size / divisor).toFixed(2);
122
+ return `${rounded} mB`;
123
+ }
124
+ }
125
+ async function transpile(src, dst) {
126
+ const dstMap = `${dst}.map`;
127
+ const result = await babel.transformFileAsync(src, {
128
+ sourceMaps: true,
129
+ comments: true
130
+ });
131
+ if (!result) {
132
+ throw new Error("babel transform failed");
133
+ }
134
+ const { code, map } = result;
135
+ await Promise.all([
136
+ import_promises.default.writeFile(dst, code ?? "", "utf-8"),
137
+ import_promises.default.writeFile(dstMap, JSON.stringify(map), "utf-8")
138
+ ]);
139
+ const stat = await Promise.all([import_promises.default.stat(dst), import_promises.default.stat(dstMap)]);
140
+ const size = stat.map((it) => prettySize(it.size));
141
+ logger.info(`${src} -> ${dst} ${import_picocolors.default.bold(size[0])} | map: ${size[1]}`);
142
+ }
143
+ async function cli() {
144
+ const startTime = Date.now();
145
+ await (0, import_vite.build)();
146
+ if (!(0, import_node_fs.existsSync)(dstDir)) {
147
+ await import_promises.default.mkdir(dstDir);
148
+ }
149
+ console.log();
150
+ console.log(
151
+ import_picocolors.default.cyan(`babel v${babel.version}`),
152
+ import_picocolors.default.green("transpiling...")
153
+ );
154
+ await Promise.all([
155
+ transpile(esSrcFile, esDstFile),
156
+ transpile(cjsSrcFile, cjsDstFile)
157
+ ]);
158
+ const duration = displayTime(Date.now() - startTime);
159
+ console.log();
160
+ console.log(import_picocolors.default.green(`Build successful (${duration}) \u{1F389}`));
161
+ }
162
+ // Annotate the CommonJS export names for ESM import in node:
163
+ 0 && (module.exports = {
164
+ cli
165
+ });
@@ -0,0 +1,15 @@
1
+ import { Component } from 'vue';
2
+
3
+ /**
4
+ * Options passed from the toolchain to the `setup` function in `src/local.ts`.
5
+ *
6
+ * @public
7
+ */
8
+ export declare interface SetupOptions {
9
+ /** The component expected to be mounted by the application */
10
+ rootComponent: Component;
11
+ /** Where the application should be mounted */
12
+ selector: string;
13
+ }
14
+
15
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/index.ts
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.42.3"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,39 @@
1
+ import { vitePlugin as apimockPlugin } from '@forsakringskassan/apimock-express';
2
+ import { MockEntry } from '@forsakringskassan/apimock-express';
3
+ import { Plugin as Plugin_2 } from 'vite';
4
+ import { UserConfig as UserConfig_2 } from 'vite';
5
+
6
+ export { apimockPlugin }
7
+
8
+ /**
9
+ * @public
10
+ */
11
+ export declare function defineConfig(config?: UserConfig): UserConfig;
12
+
13
+ /**
14
+ * @public
15
+ */
16
+ export declare interface FKConfig {
17
+ /** @deprecated Not used any longer. Final application should enable banner instead. */
18
+ enableBanner?: boolean;
19
+ /** path to component to mount by default (default `src/dev-vite/app.vue`) */
20
+ entrypoint?: string;
21
+ /** mocks to configure with apimock-express (default `[]`) */
22
+ mocks?: MockEntry[];
23
+ }
24
+
25
+ export { MockEntry }
26
+
27
+ /**
28
+ * @public
29
+ */
30
+ export declare type UserConfig = UserConfig_2 & {
31
+ fk?: FKConfig;
32
+ };
33
+
34
+ /**
35
+ * @public
36
+ */
37
+ export declare function vuePlugin(config?: Record<string, unknown>): Plugin_2;
38
+
39
+ export { }