vite-plugin-lib 2.1.5 → 2.2.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
@@ -46,7 +46,8 @@ export default defineConfig({
46
46
  formats: ['es'], // optional, default is ['es']
47
47
  name: 'YourGlobalUMDName', // optional if format does not include 'umd' or 'iife'
48
48
  external: ['some-package'], // optional, default is all node_modules and builtin modules
49
- manifest: 'package.json', // relative path to package.json, default is package.json
49
+ manifest: 'package.json', // relative path to package.json, default is package.json,
50
+ tsconfig: 'tsconfig.json', // relative path to tsconfig.json, default is tsconfig.json
50
51
  }),
51
52
  ],
52
53
  })
package/dist/index.d.mts CHANGED
@@ -20,6 +20,8 @@ interface Options {
20
20
  verbose?: boolean;
21
21
  /** Remove any temporary build files. Defaults to `true`. */
22
22
  cleanup?: boolean;
23
+ /** Path to the tsconfig file (relative to the project root). Defaults to `./tsconfig.json` */
24
+ tsconfig: string;
23
25
  }
24
26
  declare function tsconfigPaths(options?: Partial<Options>): Plugin;
25
27
  declare function library(options?: Partial<Options>): Plugin[];
package/dist/index.d.ts CHANGED
@@ -20,6 +20,8 @@ interface Options {
20
20
  verbose?: boolean;
21
21
  /** Remove any temporary build files. Defaults to `true`. */
22
22
  cleanup?: boolean;
23
+ /** Path to the tsconfig file (relative to the project root). Defaults to `./tsconfig.json` */
24
+ tsconfig: string;
23
25
  }
24
26
  declare function tsconfigPaths(options?: Partial<Options>): Plugin;
25
27
  declare function library(options?: Partial<Options>): Plugin[];
package/dist/index.mjs CHANGED
@@ -60,7 +60,7 @@ function transformStaticImport(file, line, quote, verbose) {
60
60
  const importPathMarker = `from ${quote}`;
61
61
  const isStaticImport = line.includes("import ") && line.includes(`${importPathMarker}.`);
62
62
  if (!isStaticImport) {
63
- return undefined;
63
+ return void 0;
64
64
  }
65
65
  const importStartIndex = line.lastIndexOf(importPathMarker);
66
66
  const importPath = line.substring(
@@ -80,7 +80,7 @@ function transformExport(file, line, quote, verbose) {
80
80
  const exportPathMarker = ` from ${quote}`;
81
81
  const isStaticExport = line.includes("export ") && line.includes(`${exportPathMarker}.`);
82
82
  if (!isStaticExport) {
83
- return undefined;
83
+ return void 0;
84
84
  }
85
85
  const exportStartIndex = line.lastIndexOf(exportPathMarker);
86
86
  const exportPath = line.substring(
@@ -108,7 +108,8 @@ const defaults = {
108
108
  entry: "src/index.ts",
109
109
  formats: ["es"],
110
110
  manifest: "package.json",
111
- cleanup: true
111
+ cleanup: true,
112
+ tsconfig: "./tsconfig.json"
112
113
  };
113
114
  function mergeWithDefaults(options) {
114
115
  return {
@@ -117,19 +118,19 @@ function mergeWithDefaults(options) {
117
118
  };
118
119
  }
119
120
  function tsconfigPaths(options = {}) {
120
- const { verbose } = mergeWithDefaults(options);
121
+ const { verbose, tsconfig } = mergeWithDefaults(options);
121
122
  return {
122
123
  name: "vite-plugin-lib:alias",
123
124
  enforce: "pre",
124
125
  config: async (config) => {
125
- const tsconfigPath = path.resolve(config.root ?? ".", "tsconfig.json");
126
+ const tsconfigPath = path.resolve(config.root ?? ".", tsconfig);
126
127
  const { baseUrl, paths } = await readConfig(tsconfigPath);
127
128
  if (!baseUrl || !paths) {
128
129
  log("No paths found in tsconfig.json.");
129
130
  return config;
130
131
  }
131
132
  const pathToAlias = pathToAliasFactory(tsconfigPath, baseUrl, verbose);
132
- const aliasOptions = Object.entries(paths).map(pathToAlias).filter((alias) => alias !== undefined);
133
+ const aliasOptions = Object.entries(paths).map(pathToAlias).filter((alias) => alias !== void 0);
133
134
  if (aliasOptions.length > 0) {
134
135
  logInjectedAliases(aliasOptions, config, verbose);
135
136
  }
@@ -211,7 +212,7 @@ function pathToAliasFactory(tsconfigPath, baseUrl, verbose) {
211
212
  if (verbose) {
212
213
  logWarn(`No replacements for alias ${c.green(alias)}.`);
213
214
  }
214
- return undefined;
215
+ return void 0;
215
216
  }
216
217
  if (verbose && replacements.length > 1) {
217
218
  logWarn(`Found more than one replacement for alias ${c.green(alias)}.`);
@@ -228,7 +229,7 @@ function pathToAliasFactory(tsconfigPath, baseUrl, verbose) {
228
229
  if (verbose) {
229
230
  logWarn(`No replacement found for alias ${c.green(alias)}.`);
230
231
  }
231
- return undefined;
232
+ return void 0;
232
233
  }
233
234
  return {
234
235
  find,
@@ -247,7 +248,7 @@ function getFirstExistingReplacement(tsconfigPath, baseUrl, replacements, find,
247
248
  return resolvedReplacement;
248
249
  }
249
250
  }
250
- return undefined;
251
+ return void 0;
251
252
  }
252
253
  function formatToFileName(entry, format) {
253
254
  const entryFileName = entry.substring(
@@ -273,6 +274,7 @@ function library(options = {}) {
273
274
  include: `${path.resolve(mergedOptions.entry, "..")}/**`,
274
275
  outDir: typesDir,
275
276
  staticImport: true,
277
+ tsconfigPath: mergedOptions.tsconfig,
276
278
  afterBuild: async () => {
277
279
  if (includesESFormat(mergedOptions.formats)) {
278
280
  await generateMTSDeclarations(
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-lib",
3
- "version": "2.1.5",
3
+ "type": "module",
4
+ "version": "2.2.0",
4
5
  "description": "Vite plugin for build configuration, automatic aliases, and type declarations.",
5
6
  "author": "Jan Müller <janmueller3698@gmail.com>",
6
7
  "license": "MIT",
@@ -39,14 +40,14 @@
39
40
  },
40
41
  "dependencies": {
41
42
  "picocolors": "1.1.1",
42
- "vite-plugin-dts": "4.5.0"
43
+ "vite-plugin-dts": "4.5.3"
43
44
  },
44
45
  "devDependencies": {
45
- "@types/node": "22.13.0",
46
- "typescript": "5.7.3",
47
- "unbuild": "3.3.1",
48
- "vite": "6.0.11",
49
- "@yeger/tsconfig": "2.0.9"
46
+ "@types/node": "22.14.1",
47
+ "typescript": "5.8.3",
48
+ "unbuild": "3.5.0",
49
+ "vite": "6.2.6",
50
+ "@yeger/tsconfig": "2.1.0"
50
51
  },
51
52
  "publishConfig": {
52
53
  "access": "public"