vite-plugin-lib 1.0.1 → 1.1.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/dist/index.cjs +14 -14
- package/dist/index.d.ts +1 -2
- package/dist/index.mjs +14 -14
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ function log(text) {
|
|
|
26
26
|
function logError(text) {
|
|
27
27
|
console.error(`${c.red("[vite:lib]")} ${text}`);
|
|
28
28
|
}
|
|
29
|
-
const tsconfigPaths = (
|
|
29
|
+
const tsconfigPaths = () => {
|
|
30
30
|
return {
|
|
31
31
|
name: "vite-plugin-lib:alias",
|
|
32
32
|
enforce: "pre",
|
|
@@ -48,15 +48,12 @@ const tsconfigPaths = ({ verbose } = {}) => {
|
|
|
48
48
|
);
|
|
49
49
|
if (aliasOptions.length > 0) {
|
|
50
50
|
log(`Injected ${c.green(aliasOptions.length)} aliases.`);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
)} configured`
|
|
58
|
-
)
|
|
59
|
-
);
|
|
51
|
+
const base = `${path.resolve(config.root ?? ".")}/`;
|
|
52
|
+
aliasOptions.map(
|
|
53
|
+
({ find, replacement }) => `${c.gray(">")} ${c.green(find.toString())} ${c.gray(
|
|
54
|
+
c.bold("->")
|
|
55
|
+
)} ${c.green(replacement.replace(base, ""))}`
|
|
56
|
+
).forEach(log);
|
|
60
57
|
}
|
|
61
58
|
const existingAlias = transformExistingAlias(config.resolve?.alias);
|
|
62
59
|
return {
|
|
@@ -76,7 +73,7 @@ const buildConfig = ({
|
|
|
76
73
|
externalPackages
|
|
77
74
|
}) => {
|
|
78
75
|
if (!externalPackages) {
|
|
79
|
-
log("
|
|
76
|
+
log("Externalized all packages.");
|
|
80
77
|
}
|
|
81
78
|
return {
|
|
82
79
|
name: "vite-plugin-lib:build",
|
|
@@ -116,7 +113,7 @@ function formatToFileName(entry, format) {
|
|
|
116
113
|
}
|
|
117
114
|
function library(options) {
|
|
118
115
|
return [
|
|
119
|
-
tsconfigPaths(
|
|
116
|
+
tsconfigPaths(),
|
|
120
117
|
buildConfig(options),
|
|
121
118
|
dts({
|
|
122
119
|
cleanVueFileName: true,
|
|
@@ -142,6 +139,9 @@ async function readConfig(configPath) {
|
|
|
142
139
|
try {
|
|
143
140
|
const configFileText = await promises.readFile(configPath, { encoding: "utf-8" });
|
|
144
141
|
const { config } = typescript.parseConfigFileTextToJson(configPath, configFileText);
|
|
142
|
+
if (!("baseUrl" in config?.compilerOptions)) {
|
|
143
|
+
throw new Error("No baseUrl provided in tsconfig.json.");
|
|
144
|
+
}
|
|
145
145
|
const { options } = typescript.parseJsonConfigFileContent(
|
|
146
146
|
config,
|
|
147
147
|
typescript.sys,
|
|
@@ -150,8 +150,8 @@ async function readConfig(configPath) {
|
|
|
150
150
|
return options;
|
|
151
151
|
} catch (error) {
|
|
152
152
|
const message = "message" in error ? error.message : error;
|
|
153
|
-
logError(`Could not read tsconfig.json: ${message}
|
|
154
|
-
|
|
153
|
+
logError(`Could not read tsconfig.json: ${message}`);
|
|
154
|
+
throw error;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,8 @@ interface Options {
|
|
|
7
7
|
entry: string;
|
|
8
8
|
formats?: LibraryFormats[];
|
|
9
9
|
externalPackages?: (string | RegExp)[];
|
|
10
|
-
verbose?: boolean;
|
|
11
10
|
}
|
|
12
|
-
declare const tsconfigPaths: (
|
|
11
|
+
declare const tsconfigPaths: () => Plugin;
|
|
13
12
|
declare function library(options: Options): Plugin[];
|
|
14
13
|
|
|
15
14
|
export { Options, library, tsconfigPaths };
|
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ function log(text) {
|
|
|
13
13
|
function logError(text) {
|
|
14
14
|
console.error(`${c.red("[vite:lib]")} ${text}`);
|
|
15
15
|
}
|
|
16
|
-
const tsconfigPaths = (
|
|
16
|
+
const tsconfigPaths = () => {
|
|
17
17
|
return {
|
|
18
18
|
name: "vite-plugin-lib:alias",
|
|
19
19
|
enforce: "pre",
|
|
@@ -35,15 +35,12 @@ const tsconfigPaths = ({ verbose } = {}) => {
|
|
|
35
35
|
);
|
|
36
36
|
if (aliasOptions.length > 0) {
|
|
37
37
|
log(`Injected ${c.green(aliasOptions.length)} aliases.`);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)} configured`
|
|
45
|
-
)
|
|
46
|
-
);
|
|
38
|
+
const base = `${path.resolve(config.root ?? ".")}/`;
|
|
39
|
+
aliasOptions.map(
|
|
40
|
+
({ find, replacement }) => `${c.gray(">")} ${c.green(find.toString())} ${c.gray(
|
|
41
|
+
c.bold("->")
|
|
42
|
+
)} ${c.green(replacement.replace(base, ""))}`
|
|
43
|
+
).forEach(log);
|
|
47
44
|
}
|
|
48
45
|
const existingAlias = transformExistingAlias(config.resolve?.alias);
|
|
49
46
|
return {
|
|
@@ -63,7 +60,7 @@ const buildConfig = ({
|
|
|
63
60
|
externalPackages
|
|
64
61
|
}) => {
|
|
65
62
|
if (!externalPackages) {
|
|
66
|
-
log("
|
|
63
|
+
log("Externalized all packages.");
|
|
67
64
|
}
|
|
68
65
|
return {
|
|
69
66
|
name: "vite-plugin-lib:build",
|
|
@@ -103,7 +100,7 @@ function formatToFileName(entry, format) {
|
|
|
103
100
|
}
|
|
104
101
|
function library(options) {
|
|
105
102
|
return [
|
|
106
|
-
tsconfigPaths(
|
|
103
|
+
tsconfigPaths(),
|
|
107
104
|
buildConfig(options),
|
|
108
105
|
dts__default({
|
|
109
106
|
cleanVueFileName: true,
|
|
@@ -129,6 +126,9 @@ async function readConfig(configPath) {
|
|
|
129
126
|
try {
|
|
130
127
|
const configFileText = await readFile(configPath, { encoding: "utf-8" });
|
|
131
128
|
const { config } = parseConfigFileTextToJson(configPath, configFileText);
|
|
129
|
+
if (!("baseUrl" in config?.compilerOptions)) {
|
|
130
|
+
throw new Error("No baseUrl provided in tsconfig.json.");
|
|
131
|
+
}
|
|
132
132
|
const { options } = parseJsonConfigFileContent(
|
|
133
133
|
config,
|
|
134
134
|
sys,
|
|
@@ -137,8 +137,8 @@ async function readConfig(configPath) {
|
|
|
137
137
|
return options;
|
|
138
138
|
} catch (error) {
|
|
139
139
|
const message = "message" in error ? error.message : error;
|
|
140
|
-
logError(`Could not read tsconfig.json: ${message}
|
|
141
|
-
|
|
140
|
+
logError(`Could not read tsconfig.json: ${message}`);
|
|
141
|
+
throw error;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-lib",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Vite plugin for build configuration, automatic aliases, and type declarations.",
|
|
5
5
|
"author": "Jan Müller <janmueller3698@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "18.11.13",
|
|
43
|
-
"@vitest/ui": "0.26.
|
|
43
|
+
"@vitest/ui": "0.26.3",
|
|
44
44
|
"typescript": "4.9.4",
|
|
45
45
|
"unbuild": "1.0.2",
|
|
46
46
|
"vite": "4.0.0",
|