kirbyup 3.1.5 → 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.DKFIHHbk.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.DKFIHHbk.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.5";
22
+ const version = "4.0.0-alpha.1";
25
23
 
26
24
  class PrettyError extends Error {
27
25
  constructor(message) {
@@ -82,106 +80,6 @@ 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) {
@@ -283,6 +181,70 @@ async function detectPackageManager(cwd, options = {}) {
283
181
  return detected;
284
182
  }
285
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
+
286
248
  function kirbyupHmrPlugin(options) {
287
249
  let config;
288
250
  let entry;
@@ -357,9 +319,9 @@ let resolvedKirbyupConfig;
357
319
  let resolvedPostCssConfig;
358
320
  function getViteConfig(command, options) {
359
321
  const aliasDir = resolve(options.cwd, dirname(options.entry));
360
- const { alias = {}, vite, extendViteConfig } = resolvedKirbyupConfig;
361
- const userConfig = vite ?? extendViteConfig ?? {};
362
- const baseConfig = {
322
+ const { alias = {}, vite } = resolvedKirbyupConfig;
323
+ const userConfig = vite ?? {};
324
+ const sharedConfig = {
363
325
  resolve: {
364
326
  alias: {
365
327
  "~/": `${aliasDir}/`,
@@ -371,9 +333,7 @@ function getViteConfig(command, options) {
371
333
  // Explicitly pass the compiler, since the plugin's resolving of the compiler
372
334
  // looks in the current directory and breaks `npx kirbyup`
373
335
  vuePlugin({ compiler: vueCompilerSfc }),
374
- vueJsxPlugin(),
375
- kirbyupGlobImportPlugin(),
376
- { ...externalGlobals({ vue: "Vue" }), enforce: "post" }
336
+ vueJsxPlugin()
377
337
  ],
378
338
  css: { postcss: resolvedPostCssConfig },
379
339
  envPrefix: ["VITE_", "KIRBYUP_"],
@@ -381,7 +341,7 @@ function getViteConfig(command, options) {
381
341
  };
382
342
  if (command === "serve") {
383
343
  const { port, watch } = options;
384
- const serveConfig = mergeConfig(baseConfig, {
344
+ const serveConfig = mergeConfig(sharedConfig, {
385
345
  plugins: [
386
346
  kirbyupHmrPlugin(options),
387
347
  watch && fullReloadPlugin(watch)
@@ -394,20 +354,20 @@ function getViteConfig(command, options) {
394
354
  return mergeConfig(serveConfig, userConfig);
395
355
  }
396
356
  const mode = options.watch ? "development" : "production";
397
- const buildConfig = mergeConfig(baseConfig, {
357
+ const buildConfig = mergeConfig(sharedConfig, {
398
358
  plugins: [kirbyupBuildCleanupPlugin(options)],
399
359
  mode,
400
360
  build: {
401
361
  lib: {
402
362
  entry: resolve(options.cwd, options.entry),
403
- formats: ["iife"],
404
- name: "kirbyupExport",
363
+ formats: ["es"],
405
364
  fileName: () => "index.js"
406
365
  },
407
366
  minify: mode === "production",
408
367
  outDir: options.outDir,
409
368
  emptyOutDir: false,
410
369
  rollupOptions: {
370
+ external: ["vue"],
411
371
  output: {
412
372
  assetFileNames: "index.[ext]"
413
373
  }
@@ -448,7 +408,7 @@ async function generate(options) {
448
408
  return result;
449
409
  }
450
410
  async function build(options) {
451
- ensureEntry(options);
411
+ assertEntryExists(options);
452
412
  const { cwd } = options;
453
413
  const { config, configFile } = await loadConfig(cwd);
454
414
  resolvedKirbyupConfig = config ?? {};
@@ -469,7 +429,7 @@ async function build(options) {
469
429
  const ignored = [
470
430
  "**/{.git,node_modules}/**",
471
431
  // Always ignore dist files
472
- "index.{css,js}"
432
+ "index.{css,js,mjs}"
473
433
  ];
474
434
  const watchPaths = typeof options.watch === "boolean" ? dirname(options.entry) : Array.isArray(options.watch) ? options.watch.filter(
475
435
  (path) => typeof path === "string"
@@ -503,7 +463,7 @@ async function build(options) {
503
463
  startWatcher();
504
464
  }
505
465
  async function serve(options) {
506
- ensureEntry(options);
466
+ assertEntryExists(options);
507
467
  const { cwd } = options;
508
468
  const { config } = await loadConfig(cwd);
509
469
  resolvedKirbyupConfig = config ?? {};
@@ -517,7 +477,7 @@ async function serve(options) {
517
477
  consola.success(`Server is listening on :${server.config.server.port}`);
518
478
  return server;
519
479
  }
520
- function ensureEntry(options) {
480
+ function assertEntryExists(options) {
521
481
  if (!existsSync(resolve(options.cwd, options.entry)))
522
482
  throw new PrettyError(`Cannot find "${options.entry}"`);
523
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.5",
5
- "packageManager": "pnpm@8.15.4",
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",
@@ -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",
75
+ "@vitejs/plugin-vue": "^5.0.4",
76
+ "@vitejs/plugin-vue-jsx": "^3.1.0",
77
+ "@vue/compiler-sfc": "^3.4.23",
78
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.8",
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.71.1",
91
- "vite": "^5.1.6",
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.8.0",
95
+ "@antfu/eslint-config": "^2.15.0",
97
96
  "@types/fs-extra": "^11.0.4",
98
- "@types/node": "^20.11.25",
97
+ "@types/node": "^20.12.7",
99
98
  "@types/prompts": "^2.4.9",
100
99
  "bumpp": "^9.4.0",
101
100
  "eslint": "^8.57.0",
102
101
  "fast-glob": "^3.3.2",
103
102
  "fs-extra": "^11.2.0",
104
103
  "nypm": "^0.3.8",
105
- "simple-git-hooks": "^2.10.0",
106
- "typescript": "~5.3.3",
104
+ "simple-git-hooks": "^2.11.1",
105
+ "typescript": "^5.4.5",
107
106
  "unbuild": "^3.0.0-rc.1",
108
- "vitest": "^1.3.1"
107
+ "vitest": "^1.5.0"
109
108
  },
110
109
  "simple-git-hooks": {
111
110
  "commit-msg": "node scripts/verifyCommit.mjs $1"