kirbyup 3.1.2 → 3.1.3

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.
@@ -1,4 +1,4 @@
1
- import { U as UserConfig } from '../shared/kirbyup.1d99eeee.mjs';
1
+ import { U as UserConfig } from '../shared/kirbyup.bcda4592.mjs';
2
2
  import 'vite';
3
3
 
4
4
  declare function defineConfig(config: UserConfig): UserConfig;
@@ -1,4 +1,4 @@
1
- import { U as UserConfig } from '../shared/kirbyup.1d99eeee.js';
1
+ import { U as UserConfig } from '../shared/kirbyup.bcda4592.js';
2
2
  import 'vite';
3
3
 
4
4
  declare function defineConfig(config: UserConfig): UserConfig;
@@ -1,7 +1,7 @@
1
1
  declare const kirbyup: Readonly<{
2
2
  /**
3
- * Auto-import Kirby Panel components, will be transformed by
4
- * kirbyup's auto import plugin for Vite
3
+ * Auto-import Kirby Panel components, transformed by
4
+ * kirbyup's glob-import plugin for Vite.
5
5
  *
6
6
  * @example
7
7
  * kirbyup.import('./components/blocks/*.vue')
@@ -1,7 +1,7 @@
1
1
  declare const kirbyup: Readonly<{
2
2
  /**
3
- * Auto-import Kirby Panel components, will be transformed by
4
- * kirbyup's auto import plugin for Vite
3
+ * Auto-import Kirby Panel components, transformed by
4
+ * kirbyup's glob-import plugin for Vite.
5
5
  *
6
6
  * @example
7
7
  * kirbyup.import('./components/blocks/*.vue')
@@ -1,7 +1,7 @@
1
1
  const kirbyup = Object.freeze({
2
2
  /**
3
- * Auto-import Kirby Panel components, will be transformed by
4
- * kirbyup's auto import plugin for Vite
3
+ * Auto-import Kirby Panel components, transformed by
4
+ * kirbyup's glob-import plugin for Vite.
5
5
  *
6
6
  * @example
7
7
  * kirbyup.import('./components/blocks/*.vue')
package/dist/node/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cac } from 'cac';
2
- import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.5312ccaa.mjs';
2
+ import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.db20dc98.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'pathe';
@@ -12,13 +12,13 @@ import '@vitejs/plugin-vue2';
12
12
  import '@vitejs/plugin-vue2-jsx';
13
13
  import 'vite-plugin-full-reload';
14
14
  import 'rollup-plugin-external-globals';
15
- import 'postcss-load-config';
16
- import 'postcss-logical';
17
- import 'postcss-dir-pseudo-class';
18
15
  import 'node:zlib';
19
16
  import 'node:util';
20
17
  import 'node:buffer';
21
18
  import 'c12';
19
+ import 'postcss-load-config';
20
+ import 'postcss-logical';
21
+ import 'postcss-dir-pseudo-class';
22
22
  import 'magic-string';
23
23
  import 'node:module';
24
24
 
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.1d99eeee.mjs';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.bcda4592.mjs';
3
3
 
4
4
  declare function build(options: BuildOptions): Promise<void>;
5
5
  declare function serve(options: ServeOptions): Promise<vite.ViteDevServer>;
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.1d99eeee.js';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.bcda4592.js';
3
3
 
4
4
  declare function build(options: BuildOptions): Promise<void>;
5
5
  declare function serve(options: ServeOptions): Promise<vite.ViteDevServer>;
@@ -10,13 +10,13 @@ import '@vitejs/plugin-vue2';
10
10
  import '@vitejs/plugin-vue2-jsx';
11
11
  import 'vite-plugin-full-reload';
12
12
  import 'rollup-plugin-external-globals';
13
- import 'postcss-load-config';
14
- import 'postcss-logical';
15
- import 'postcss-dir-pseudo-class';
16
- export { b as build, s as serve } from '../shared/kirbyup.5312ccaa.mjs';
13
+ export { b as build, s as serve } from '../shared/kirbyup.db20dc98.mjs';
17
14
  import 'node:zlib';
18
15
  import 'node:util';
19
16
  import 'node:buffer';
20
17
  import 'c12';
18
+ import 'postcss-load-config';
19
+ import 'postcss-logical';
20
+ import 'postcss-dir-pseudo-class';
21
21
  import 'magic-string';
22
22
  import 'node:module';
@@ -15,8 +15,8 @@ interface BuildOptions extends BaseOptions {
15
15
  }
16
16
  interface UserConfig {
17
17
  /**
18
- * Specifies an `Object`, or an `Array` of `Object`,
19
- * which defines aliases used to replace values in `import` statements.
18
+ * Specifies an object or an array of objects, which defines aliases
19
+ * used to replace values in `import` statements.
20
20
  * With either format, the order of the entries is important,
21
21
  * in that the first defined rules are applied first.
22
22
  */
@@ -15,8 +15,8 @@ interface BuildOptions extends BaseOptions {
15
15
  }
16
16
  interface UserConfig {
17
17
  /**
18
- * Specifies an `Object`, or an `Array` of `Object`,
19
- * which defines aliases used to replace values in `import` statements.
18
+ * Specifies an object or an array of objects, which defines aliases
19
+ * used to replace values in `import` statements.
20
20
  * With either format, the order of the entries is important,
21
21
  * in that the first defined rules are applied first.
22
22
  */
@@ -10,18 +10,18 @@ import vuePlugin from '@vitejs/plugin-vue2';
10
10
  import vueJsxPlugin from '@vitejs/plugin-vue2-jsx';
11
11
  import fullReloadPlugin from 'vite-plugin-full-reload';
12
12
  import externalGlobals from 'rollup-plugin-external-globals';
13
- import postcssrc from 'postcss-load-config';
14
- import postcssLogical from 'postcss-logical';
15
- import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
16
13
  import { gzip } from 'node:zlib';
17
14
  import { promisify } from 'node:util';
18
15
  import { Buffer } from 'node:buffer';
19
16
  import { loadConfig as loadConfig$1 } from 'c12';
17
+ import postcssrc from 'postcss-load-config';
18
+ import postcssLogical from 'postcss-logical';
19
+ import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
20
20
  import MagicString from 'magic-string';
21
21
  import 'node:module';
22
22
 
23
23
  const name = "kirbyup";
24
- const version = "3.1.2";
24
+ const version = "3.1.3";
25
25
 
26
26
  class PrettyError extends Error {
27
27
  constructor(message) {
@@ -70,6 +70,18 @@ function loadConfig(cwd = process.cwd()) {
70
70
  }
71
71
  });
72
72
  }
73
+ async function resolvePostCSSConfig(cwd) {
74
+ try {
75
+ const config = await postcssrc(void 0, void 0, { stopDir: cwd });
76
+ return config;
77
+ } catch (error) {
78
+ if (!error.message.includes("No PostCSS Config found"))
79
+ throw error;
80
+ return {
81
+ plugins: [postcssLogical(), postcssDirPseudoClass()]
82
+ };
83
+ }
84
+ }
73
85
 
74
86
  const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
75
87
  const singlelineCommentsRE = /\/\/.*/g;
@@ -137,10 +149,10 @@ function $_applyKirbyModifications(activeDef, newDef) {
137
149
  /** -- */
138
150
  `;
139
151
 
140
- function kirbyupAutoImportPlugin() {
152
+ function kirbyupGlobImportPlugin() {
141
153
  let config;
142
154
  return {
143
- name: "kirbyup:auto-import",
155
+ name: "kirbyup:glob-import",
144
156
  configResolved(resolvedConfig) {
145
157
  config = resolvedConfig;
146
158
  },
@@ -260,19 +272,19 @@ async function detectPackageManager(cwd, options = {}) {
260
272
  function kirbyupHmrPlugin(options) {
261
273
  let config;
262
274
  let entry;
263
- let indexMjs;
275
+ let devIndexPath;
264
276
  return {
265
277
  name: "kirbyup:hmr",
266
278
  apply: "serve",
267
279
  configResolved(resolvedConfig) {
268
280
  config = resolvedConfig;
269
281
  entry = resolve(config.root, options.entry);
270
- indexMjs = resolve(config.root, options.outDir || "", "index.dev.mjs");
282
+ devIndexPath = resolve(config.root, options.outDir || "", "index.dev.mjs");
271
283
  },
272
284
  transform(code, id) {
273
285
  if (isHmrRuntimeId(id)) {
274
286
  return code.replace(
275
- // https://github.com/vitejs/vite-plugin-vue2/blob/06ede94/src/utils/hmrRuntime.ts#L173
287
+ // https://github.com/vitejs/vite-plugin-vue2/blob/8de73ea6b8a1df4c14308da2885db195dacc2b14/src/utils/hmrRuntime.ts#L173
276
288
  /^.*=\s*record\.Ctor\.super\.extend\(options\)/m,
277
289
  "$_applyKirbyModifications(record.Ctor.options, options) // injected by kirbyup\n$&"
278
290
  ) + __INJECTED_HMR_CODE__;
@@ -288,12 +300,12 @@ function kirbyupHmrPlugin(options) {
288
300
  const baseUrl = `http://${hostname}:${port}${config.base}`;
289
301
  const entryUrl = new URL(entryPath, baseUrl).href;
290
302
  const pm = await detectPackageManager(config.root);
291
- await writeFile(indexMjs, getViteProxyModule(entryUrl, pm));
303
+ await writeFile(devIndexPath, getViteProxyModule(entryUrl, pm));
292
304
  });
293
305
  },
294
306
  closeBundle() {
295
- if (existsSync(indexMjs))
296
- unlinkSync(indexMjs);
307
+ if (existsSync(devIndexPath))
308
+ unlinkSync(devIndexPath);
297
309
  }
298
310
  };
299
311
  }
@@ -307,21 +319,22 @@ try {
307
319
  "[kirbyup] Couldn't connect to the development server. Run \`${pm} run serve\` to start Vite or build the plugin with \`${pm} run build\` so Kirby uses the production version."
308
320
  );
309
321
  throw err;
310
- }`.trim();
322
+ }
323
+ `.trimStart();
311
324
  }
312
325
 
313
326
  function kirbyupBuildCleanupPlugin(options) {
314
327
  let config;
315
- let indexMjs;
328
+ let devIndexPath;
316
329
  return {
317
330
  name: "kirbyup:build-cleanup",
318
331
  configResolved(resolvedConfig) {
319
332
  config = resolvedConfig;
320
- indexMjs = resolve(config.root, options.outDir, "index.dev.mjs");
333
+ devIndexPath = resolve(config.root, options.outDir, "index.dev.mjs");
321
334
  },
322
335
  writeBundle() {
323
- if (existsSync(indexMjs))
324
- unlinkSync(indexMjs);
336
+ if (existsSync(devIndexPath))
337
+ unlinkSync(devIndexPath);
325
338
  }
326
339
  };
327
340
  }
@@ -345,7 +358,7 @@ function getViteConfig(command, options) {
345
358
  // looks in the current directory and breaks `npx kirbyup`
346
359
  vuePlugin({ compiler: vueCompilerSfc }),
347
360
  vueJsxPlugin(),
348
- kirbyupAutoImportPlugin(),
361
+ kirbyupGlobImportPlugin(),
349
362
  { ...externalGlobals({ vue: "Vue" }), enforce: "post" }
350
363
  ],
351
364
  css: { postcss: resolvedPostCssConfig },
@@ -358,8 +371,8 @@ function getViteConfig(command, options) {
358
371
  plugins: [
359
372
  kirbyupHmrPlugin(options),
360
373
  watch && fullReloadPlugin(watch)
361
- ],
362
- // Input needs to be specified so dep pre-bundling works
374
+ ].filter(Boolean),
375
+ // Input needs to be specified so dependency pre-bundling works
363
376
  build: { rollupOptions: { input: resolve(options.cwd, options.entry) } },
364
377
  // Specify origin so asset URLs include Vite server host
365
378
  server: { port, strictPort: true, origin: `http://localhost:${port}` }
@@ -446,7 +459,7 @@ async function build(options) {
446
459
  const { watch } = await import('chokidar');
447
460
  const ignored = [
448
461
  "**/{.git,node_modules}/**",
449
- // Always ignore out files
462
+ // Always ignore dist files
450
463
  "index.{css,js}"
451
464
  ];
452
465
  const watchPaths = typeof options.watch === "boolean" ? dirname(options.entry) : Array.isArray(options.watch) ? options.watch.filter(
@@ -464,7 +477,8 @@ async function build(options) {
464
477
  if (configFile)
465
478
  watcher.add(configFile);
466
479
  watcher.on("all", async (type, file) => {
467
- if (configFile === file) {
480
+ const absolutePath = resolve(cwd, file);
481
+ if (configFile === absolutePath) {
468
482
  resolvedKirbyupConfig = (await loadConfig(cwd)).config ?? {};
469
483
  consola.info(
470
484
  `${colors.cyan(basename(file))} changed, setting new config`
@@ -498,17 +512,5 @@ function ensureEntry(options) {
498
512
  if (!existsSync(resolve(options.cwd, options.entry)))
499
513
  throw new PrettyError(`Cannot find "${options.entry}"`);
500
514
  }
501
- async function resolvePostCSSConfig(cwd) {
502
- try {
503
- const config = await postcssrc(void 0, void 0, { stopDir: cwd });
504
- return config;
505
- } catch (error) {
506
- if (!error.message.includes("No PostCSS Config found"))
507
- throw error;
508
- return {
509
- plugins: [postcssLogical(), postcssDirPseudoClass()]
510
- };
511
- }
512
- }
513
515
 
514
516
  export { build as b, handleError as h, name as n, serve as s, version as v };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kirbyup",
3
3
  "type": "module",
4
- "version": "3.1.2",
4
+ "version": "3.1.3",
5
5
  "packageManager": "pnpm@8.15.1",
6
6
  "description": "Zero-config bundler for Kirby Panel plugins",
7
7
  "author": {