kirbyup 3.1.4 → 4.0.0-alpha.1

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.DNMktHWN.mjs';
1
+ import { U as UserConfig } from '../shared/kirbyup.CPpXMJtV.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.DNMktHWN.js';
1
+ import { U as UserConfig } from '../shared/kirbyup.CPpXMJtV.js';
2
2
  import 'vite';
3
3
 
4
4
  declare function defineConfig(config: UserConfig): UserConfig;
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.DSMJ9KWQ.mjs';
2
+ import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.-18Bpk2m.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'pathe';
@@ -8,10 +8,9 @@ import 'consola/utils';
8
8
  import 'perfect-debounce';
9
9
  import 'vite';
10
10
  import 'vue/compiler-sfc';
11
- import '@vitejs/plugin-vue2';
12
- import '@vitejs/plugin-vue2-jsx';
11
+ import '@vitejs/plugin-vue';
12
+ import '@vitejs/plugin-vue-jsx';
13
13
  import 'vite-plugin-full-reload';
14
- import 'rollup-plugin-external-globals';
15
14
  import 'node:zlib';
16
15
  import 'node:util';
17
16
  import 'node:buffer';
@@ -19,7 +18,6 @@ import 'c12';
19
18
  import 'postcss-load-config';
20
19
  import 'postcss-logical';
21
20
  import 'postcss-dir-pseudo-class';
22
- import 'magic-string';
23
21
  import 'node:module';
24
22
 
25
23
  async function startCli(cwd = process.cwd(), argv = process.argv) {
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.DNMktHWN.mjs';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.CPpXMJtV.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.DNMktHWN.js';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.CPpXMJtV.js';
3
3
 
4
4
  declare function build(options: BuildOptions): Promise<void>;
5
5
  declare function serve(options: ServeOptions): Promise<vite.ViteDevServer>;
@@ -6,11 +6,10 @@ import 'consola/utils';
6
6
  import 'perfect-debounce';
7
7
  import 'vite';
8
8
  import 'vue/compiler-sfc';
9
- import '@vitejs/plugin-vue2';
10
- import '@vitejs/plugin-vue2-jsx';
9
+ import '@vitejs/plugin-vue';
10
+ import '@vitejs/plugin-vue-jsx';
11
11
  import 'vite-plugin-full-reload';
12
- import 'rollup-plugin-external-globals';
13
- export { b as build, s as serve } from '../shared/kirbyup.DSMJ9KWQ.mjs';
12
+ export { b as build, s as serve } from '../shared/kirbyup.-18Bpk2m.mjs';
14
13
  import 'node:zlib';
15
14
  import 'node:util';
16
15
  import 'node:buffer';
@@ -18,5 +17,4 @@ import 'c12';
18
17
  import 'postcss-load-config';
19
18
  import 'postcss-logical';
20
19
  import 'postcss-dir-pseudo-class';
21
- import 'magic-string';
22
20
  import 'node:module';
@@ -6,10 +6,9 @@ import { colors } from 'consola/utils';
6
6
  import { debounce } from 'perfect-debounce';
7
7
  import { createServer, mergeConfig, build as build$1 } from 'vite';
8
8
  import * as vueCompilerSfc from 'vue/compiler-sfc';
9
- import vuePlugin from '@vitejs/plugin-vue2';
10
- import vueJsxPlugin from '@vitejs/plugin-vue2-jsx';
9
+ import vuePlugin from '@vitejs/plugin-vue';
10
+ import vueJsxPlugin from '@vitejs/plugin-vue-jsx';
11
11
  import fullReloadPlugin from 'vite-plugin-full-reload';
12
- import externalGlobals from 'rollup-plugin-external-globals';
13
12
  import { gzip } from 'node:zlib';
14
13
  import { promisify } from 'node:util';
15
14
  import { Buffer } from 'node:buffer';
@@ -17,11 +16,10 @@ import { loadConfig as loadConfig$1 } from 'c12';
17
16
  import postcssrc from 'postcss-load-config';
18
17
  import postcssLogical from 'postcss-logical';
19
18
  import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
20
- import MagicString from 'magic-string';
21
19
  import 'node:module';
22
20
 
23
21
  const name = "kirbyup";
24
- const version = "3.1.4";
22
+ const version = "4.0.0-alpha.1";
25
23
 
26
24
  class PrettyError extends Error {
27
25
  constructor(message) {
@@ -82,110 +80,10 @@ async function resolvePostCSSConfig(cwd) {
82
80
  }
83
81
  }
84
82
 
85
- const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
86
- const singlelineCommentsRE = /\/\/.*/g;
87
- const HMR_RUNTIME_ID = "\0plugin-vue2:hmr-runtime";
88
- const JSX_HMR_RUNTIME_ID = "plugin-vue2-jsx:hmr-runtime";
89
- function isHmrRuntimeId(id) {
90
- return id === HMR_RUNTIME_ID || id === JSX_HMR_RUNTIME_ID;
91
- }
92
- const __INJECTED_HMR_CODE__ = `
93
- /** - injected by kirbyup - */
94
- for (const methodName of ['rerender', 'reload']) {
95
- const original = __VUE_HMR_RUNTIME__[methodName]
96
-
97
- __VUE_HMR_RUNTIME__[methodName] = function (id, updatedDef) {
98
- const key = updatedDef?.__file ? '__file' : updatedDef?.__hmrId ? '__hmrId' : null
99
-
100
- if (key) {
101
- const pluginComponents = window.panel.plugins.components
102
- // const usedComponentDefs = window.panel.app.$options.components
103
- const usedComponentDefs = window.panel.app._vnode.componentInstance.$options.components // #33
104
-
105
- for (const componentName in pluginComponents) {
106
- if (updatedDef[key] === pluginComponents[componentName][key]) {
107
- const usedDefinition = usedComponentDefs[componentName].options
108
-
109
- if (map[id].options !== usedDefinition)
110
- map[id].options = usedDefinition
111
-
112
- if (typeof map[id].options.$_isSection !== 'boolean')
113
- map[id].options.$_isSection = /^k-.*-section$/.test(componentName)
114
-
115
- break
116
- }
117
- }
118
- }
119
-
120
- return original.apply(this, arguments)
121
- }
122
- }
123
-
124
- function $_applyKirbyModifications(activeDef, newDef) {
125
- const usedComponentDefs = window.panel.app.$options.components
126
-
127
- if (newDef.template)
128
- newDef.render = null
129
-
130
- if (activeDef.$_isSection)
131
- newDef.$_isSection = true
132
- if (newDef.$_isSection && !newDef.mixins?.[0]?.methods?.load)
133
- newDef.mixins = [activeDef.mixins[0], ...(newDef.mixins || [])]
134
-
135
- if (typeof newDef.extends === 'string') {
136
- if (newDef.extends === activeDef.extends?.options?.name) {
137
- newDef.extends = activeDef.extends
138
- }
139
- else if (usedComponentDefs[newDef.extends]) {
140
- newDef.extends = usedComponentDefs[newDef.extends].extend({
141
- options: newDef,
142
- components: { ...usedComponentDefs, ...(newDef.components || {}) },
143
- })
144
- }
145
- else { newDef.extends = null }
146
- }
147
- }
148
- /** -- */
149
- `;
150
-
151
- function kirbyupGlobImportPlugin() {
152
- let config;
153
- return {
154
- name: "kirbyup:glob-import",
155
- configResolved(resolvedConfig) {
156
- config = resolvedConfig;
157
- },
158
- async transform(code) {
159
- if (!code.includes("kirbyup.import"))
160
- return;
161
- const kirbyupImportRE = /\bkirbyup\.import\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*\)/g;
162
- const noCommentsCode = code.replace(multilineCommentsRE, (m) => " ".repeat(m.length)).replace(singlelineCommentsRE, (m) => " ".repeat(m.length));
163
- let s;
164
- let match;
165
- while (match = kirbyupImportRE.exec(noCommentsCode)) {
166
- const { 0: exp, 1: rawPath, index } = match;
167
- if (!s)
168
- s = new MagicString(code);
169
- s.overwrite(
170
- index,
171
- index + exp.length,
172
- `kirbyup.import(import.meta.glob(${rawPath}, { eager: true }))`
173
- );
174
- }
175
- if (s) {
176
- return {
177
- code: s.toString(),
178
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : void 0
179
- };
180
- }
181
- }
182
- };
183
- }
184
-
185
83
  async function findup(cwd, match, options = {}) {
186
84
  const segments = normalize(cwd).split("/");
187
85
  while (segments.length > 0) {
188
- const path = segments.join("/");
86
+ const path = segments.join("/") || "/";
189
87
  const result = await match(path);
190
88
  if (result || !options.includeParentDirs) {
191
89
  return result;
@@ -195,7 +93,11 @@ async function findup(cwd, match, options = {}) {
195
93
  }
196
94
 
197
95
  const packageManagers = [
198
- { name: "npm", command: "npm", lockFile: "package-lock.json" },
96
+ {
97
+ name: "npm",
98
+ command: "npm",
99
+ lockFile: "package-lock.json"
100
+ },
199
101
  {
200
102
  name: "pnpm",
201
103
  command: "pnpm",
@@ -223,7 +125,7 @@ const packageManagers = [
223
125
  ];
224
126
  async function detectPackageManager(cwd, options = {}) {
225
127
  const detected = await findup(
226
- cwd,
128
+ resolve(cwd || "."),
227
129
  async (path) => {
228
130
  if (!options.ignorePackageJSON) {
229
131
  const packageJSONPath = join(path, "package.json");
@@ -265,9 +167,84 @@ async function detectPackageManager(cwd, options = {}) {
265
167
  includeParentDirs: options.includeParentDirs ?? true
266
168
  }
267
169
  );
170
+ if (!detected && !options.ignoreArgv) {
171
+ const scriptArg = process.argv[1];
172
+ if (scriptArg) {
173
+ for (const packageManager of packageManagers) {
174
+ const re = new RegExp(`[/\\\\]\\.?${packageManager.command}`);
175
+ if (re.test(scriptArg)) {
176
+ return packageManager;
177
+ }
178
+ }
179
+ }
180
+ }
268
181
  return detected;
269
182
  }
270
183
 
184
+ const HMR_RUNTIME_ID = "\0plugin-vue2:hmr-runtime";
185
+ const JSX_HMR_RUNTIME_ID = "plugin-vue2-jsx:hmr-runtime";
186
+ function isHmrRuntimeId(id) {
187
+ return id === HMR_RUNTIME_ID || id === JSX_HMR_RUNTIME_ID;
188
+ }
189
+ const __INJECTED_HMR_CODE__ = `
190
+ /** - injected by kirbyup - */
191
+ for (const methodName of ['rerender', 'reload']) {
192
+ const original = __VUE_HMR_RUNTIME__[methodName]
193
+
194
+ __VUE_HMR_RUNTIME__[methodName] = function (id, updatedDef) {
195
+ const key = updatedDef?.__file ? '__file' : updatedDef?.__hmrId ? '__hmrId' : null
196
+
197
+ if (key) {
198
+ const pluginComponents = window.panel.plugins.components
199
+ // const usedComponentDefs = window.panel.app.$options.components
200
+ const usedComponentDefs = window.panel.app._vnode.componentInstance.$options.components // #33
201
+
202
+ for (const componentName in pluginComponents) {
203
+ if (updatedDef[key] === pluginComponents[componentName][key]) {
204
+ const usedDefinition = usedComponentDefs[componentName].options
205
+
206
+ if (map[id].options !== usedDefinition)
207
+ map[id].options = usedDefinition
208
+
209
+ if (typeof map[id].options.$_isSection !== 'boolean')
210
+ map[id].options.$_isSection = /^k-.*-section$/.test(componentName)
211
+
212
+ break
213
+ }
214
+ }
215
+ }
216
+
217
+ return original.apply(this, arguments)
218
+ }
219
+ }
220
+
221
+ function $_applyKirbyModifications(activeDef, newDef) {
222
+ const usedComponentDefs = window.panel.app.$options.components
223
+
224
+ if (newDef.template)
225
+ newDef.render = null
226
+
227
+ if (activeDef.$_isSection)
228
+ newDef.$_isSection = true
229
+ if (newDef.$_isSection && !newDef.mixins?.[0]?.methods?.load)
230
+ newDef.mixins = [activeDef.mixins[0], ...(newDef.mixins || [])]
231
+
232
+ if (typeof newDef.extends === 'string') {
233
+ if (newDef.extends === activeDef.extends?.options?.name) {
234
+ newDef.extends = activeDef.extends
235
+ }
236
+ else if (usedComponentDefs[newDef.extends]) {
237
+ newDef.extends = usedComponentDefs[newDef.extends].extend({
238
+ options: newDef,
239
+ components: { ...usedComponentDefs, ...(newDef.components || {}) },
240
+ })
241
+ }
242
+ else { newDef.extends = null }
243
+ }
244
+ }
245
+ /** -- */
246
+ `;
247
+
271
248
  function kirbyupHmrPlugin(options) {
272
249
  let config;
273
250
  let entry;
@@ -342,9 +319,9 @@ let resolvedKirbyupConfig;
342
319
  let resolvedPostCssConfig;
343
320
  function getViteConfig(command, options) {
344
321
  const aliasDir = resolve(options.cwd, dirname(options.entry));
345
- const { alias = {}, vite, extendViteConfig } = resolvedKirbyupConfig;
346
- const userConfig = vite ?? extendViteConfig ?? {};
347
- const baseConfig = {
322
+ const { alias = {}, vite } = resolvedKirbyupConfig;
323
+ const userConfig = vite ?? {};
324
+ const sharedConfig = {
348
325
  resolve: {
349
326
  alias: {
350
327
  "~/": `${aliasDir}/`,
@@ -356,9 +333,7 @@ function getViteConfig(command, options) {
356
333
  // Explicitly pass the compiler, since the plugin's resolving of the compiler
357
334
  // looks in the current directory and breaks `npx kirbyup`
358
335
  vuePlugin({ compiler: vueCompilerSfc }),
359
- vueJsxPlugin(),
360
- kirbyupGlobImportPlugin(),
361
- { ...externalGlobals({ vue: "Vue" }), enforce: "post" }
336
+ vueJsxPlugin()
362
337
  ],
363
338
  css: { postcss: resolvedPostCssConfig },
364
339
  envPrefix: ["VITE_", "KIRBYUP_"],
@@ -366,7 +341,7 @@ function getViteConfig(command, options) {
366
341
  };
367
342
  if (command === "serve") {
368
343
  const { port, watch } = options;
369
- const serveConfig = mergeConfig(baseConfig, {
344
+ const serveConfig = mergeConfig(sharedConfig, {
370
345
  plugins: [
371
346
  kirbyupHmrPlugin(options),
372
347
  watch && fullReloadPlugin(watch)
@@ -379,20 +354,20 @@ function getViteConfig(command, options) {
379
354
  return mergeConfig(serveConfig, userConfig);
380
355
  }
381
356
  const mode = options.watch ? "development" : "production";
382
- const buildConfig = mergeConfig(baseConfig, {
357
+ const buildConfig = mergeConfig(sharedConfig, {
383
358
  plugins: [kirbyupBuildCleanupPlugin(options)],
384
359
  mode,
385
360
  build: {
386
361
  lib: {
387
362
  entry: resolve(options.cwd, options.entry),
388
- formats: ["iife"],
389
- name: "kirbyupExport",
363
+ formats: ["es"],
390
364
  fileName: () => "index.js"
391
365
  },
392
366
  minify: mode === "production",
393
367
  outDir: options.outDir,
394
368
  emptyOutDir: false,
395
369
  rollupOptions: {
370
+ external: ["vue"],
396
371
  output: {
397
372
  assetFileNames: "index.[ext]"
398
373
  }
@@ -433,7 +408,7 @@ async function generate(options) {
433
408
  return result;
434
409
  }
435
410
  async function build(options) {
436
- ensureEntry(options);
411
+ assertEntryExists(options);
437
412
  const { cwd } = options;
438
413
  const { config, configFile } = await loadConfig(cwd);
439
414
  resolvedKirbyupConfig = config ?? {};
@@ -454,7 +429,7 @@ async function build(options) {
454
429
  const ignored = [
455
430
  "**/{.git,node_modules}/**",
456
431
  // Always ignore dist files
457
- "index.{css,js}"
432
+ "index.{css,js,mjs}"
458
433
  ];
459
434
  const watchPaths = typeof options.watch === "boolean" ? dirname(options.entry) : Array.isArray(options.watch) ? options.watch.filter(
460
435
  (path) => typeof path === "string"
@@ -488,7 +463,7 @@ async function build(options) {
488
463
  startWatcher();
489
464
  }
490
465
  async function serve(options) {
491
- ensureEntry(options);
466
+ assertEntryExists(options);
492
467
  const { cwd } = options;
493
468
  const { config } = await loadConfig(cwd);
494
469
  resolvedKirbyupConfig = config ?? {};
@@ -502,7 +477,7 @@ async function serve(options) {
502
477
  consola.success(`Server is listening on :${server.config.server.port}`);
503
478
  return server;
504
479
  }
505
- function ensureEntry(options) {
480
+ function assertEntryExists(options) {
506
481
  if (!existsSync(resolve(options.cwd, options.entry)))
507
482
  throw new PrettyError(`Cannot find "${options.entry}"`);
508
483
  }
@@ -34,10 +34,6 @@ interface UserConfig {
34
34
  * })
35
35
  */
36
36
  vite?: InlineConfig;
37
- /**
38
- * @deprecated Use `vite` instead.
39
- */
40
- extendViteConfig?: InlineConfig;
41
37
  }
42
38
 
43
39
  export type { BuildOptions as B, ServeOptions as S, UserConfig as U };
@@ -34,10 +34,6 @@ interface UserConfig {
34
34
  * })
35
35
  */
36
36
  vite?: InlineConfig;
37
- /**
38
- * @deprecated Use `vite` instead.
39
- */
40
- extendViteConfig?: InlineConfig;
41
37
  }
42
38
 
43
39
  export type { BuildOptions as B, ServeOptions as S, UserConfig as U };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kirbyup",
3
3
  "type": "module",
4
- "version": "3.1.4",
5
- "packageManager": "pnpm@8.15.3",
4
+ "version": "4.0.0-alpha.1",
5
+ "packageManager": "pnpm@8.15.7",
6
6
  "description": "Zero-config bundler for Kirby Panel plugins",
7
7
  "author": {
8
8
  "name": "Johann Schopplich",
@@ -61,9 +61,9 @@
61
61
  "scripts": {
62
62
  "build": "unbuild",
63
63
  "dev": "UNBUILD_STUB=true unbuild",
64
- "docs": "pnpm -C docs run dev",
65
- "docs:build": "pnpm -C docs run build",
66
- "docs:serve": "pnpm -C docs run serve",
64
+ "docs:dev": "vitepress dev docs",
65
+ "docs:build": "vitepress build docs",
66
+ "docs:preview": "vitepress preview docs",
67
67
  "lint": "eslint .",
68
68
  "lint:fix": "eslint . --fix",
69
69
  "release": "bumpp --commit --push --tag",
@@ -72,40 +72,39 @@
72
72
  "prepare": "simple-git-hooks"
73
73
  },
74
74
  "dependencies": {
75
- "@vitejs/plugin-vue2": "2.2.0",
76
- "@vitejs/plugin-vue2-jsx": "1.1.0",
77
- "@vue/compiler-sfc": "^2.7.16",
78
- "c12": "^1.8.0",
75
+ "@vitejs/plugin-vue": "^5.0.4",
76
+ "@vitejs/plugin-vue-jsx": "^3.1.0",
77
+ "@vue/compiler-sfc": "^3.4.23",
78
+ "c12": "^1.10.0",
79
79
  "cac": "^6.7.14",
80
80
  "chokidar": "^3.6.0",
81
81
  "consola": "^3.2.3",
82
- "magic-string": "^0.30.7",
82
+ "magic-string": "^0.30.10",
83
83
  "pathe": "^1.1.2",
84
84
  "perfect-debounce": "^1.0.0",
85
- "postcss": "^8.4.35",
85
+ "postcss": "^8.4.38",
86
86
  "postcss-dir-pseudo-class": "^8.0.1",
87
87
  "postcss-load-config": "^5.0.3",
88
88
  "postcss-logical": "^7.0.1",
89
- "rollup-plugin-external-globals": "^0.9.2",
90
- "sass": "^1.70.0",
91
- "vite": "^5.1.2",
89
+ "sass": "^1.75.0",
90
+ "vite": "^5.2.10",
92
91
  "vite-plugin-full-reload": "^1.1.0",
93
- "vue": "^2.7.16"
92
+ "vue": "^3.4.23"
94
93
  },
95
94
  "devDependencies": {
96
- "@antfu/eslint-config": "^2.6.4",
95
+ "@antfu/eslint-config": "^2.15.0",
97
96
  "@types/fs-extra": "^11.0.4",
98
- "@types/node": "^20.11.18",
97
+ "@types/node": "^20.12.7",
99
98
  "@types/prompts": "^2.4.9",
100
- "bumpp": "^9.3.0",
101
- "eslint": "^8.56.0",
99
+ "bumpp": "^9.4.0",
100
+ "eslint": "^8.57.0",
102
101
  "fast-glob": "^3.3.2",
103
102
  "fs-extra": "^11.2.0",
104
- "nypm": "^0.3.6",
105
- "simple-git-hooks": "^2.9.0",
106
- "typescript": "~5.3.3",
103
+ "nypm": "^0.3.8",
104
+ "simple-git-hooks": "^2.11.1",
105
+ "typescript": "^5.4.5",
107
106
  "unbuild": "^3.0.0-rc.1",
108
- "vitest": "^1.2.2"
107
+ "vitest": "^1.5.0"
109
108
  },
110
109
  "simple-git-hooks": {
111
110
  "commit-msg": "node scripts/verifyCommit.mjs $1"