kirbyup 4.0.0-alpha.5 → 4.0.0-alpha.6
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 +1 -3
- package/dist/client/config.d.mts +1 -1
- package/dist/client/config.mjs +1 -2
- package/dist/client/plugin.mjs +11 -5
- package/dist/node/cli.mjs +2 -5
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +2 -3
- package/dist/{node-B8aLFfzt.mjs → node-Do_IAs2E.mjs} +95 -169
- package/dist/{types-CFhX3iS8.d.mts → types-0NUTyTUQ.d.mts} +0 -1
- package/package.json +24 -22
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
# kirbyup
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/kirbyup)
|
|
6
|
-
|
|
7
5
|
The official bundler for Kirby Panel plugins with zero-config usage and built-in HMR.
|
|
8
6
|
|
|
9
7
|
- [✨ Release Notes](https://github.com/johannschopplich/kirbyup/releases)
|
|
@@ -35,7 +33,7 @@ npm i -D kirbyup
|
|
|
35
33
|
> [!TIP]
|
|
36
34
|
> [📖 Read the documentation](https://kirbyup.getkirby.com) or skip starting from scratch and pick one of the following starters:
|
|
37
35
|
> - [`eslint`](./examples/eslint)
|
|
38
|
-
> - [`
|
|
36
|
+
> - [`unocss`](./examples/unocss)
|
|
39
37
|
|
|
40
38
|
Having installed kirbyup, you can add the following scripts as shortcuts to the commands you will use most often:
|
|
41
39
|
|
package/dist/client/config.d.mts
CHANGED
package/dist/client/config.mjs
CHANGED
package/dist/client/plugin.mjs
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
//#region src/client/plugin.ts
|
|
2
|
-
const kirbyup = Object.freeze({
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const kirbyup = Object.freeze({
|
|
3
|
+
/**
|
|
4
|
+
* Auto-import Kirby Panel components, transformed by
|
|
5
|
+
* kirbyup's glob-import plugin for Vite.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* kirbyup.import('./components/blocks/*.vue')
|
|
9
|
+
*/
|
|
10
|
+
import(glob) {
|
|
11
|
+
return Object.entries(glob).reduce((accumulator, [path, component]) => {
|
|
5
12
|
accumulator[getComponentName(path)] = component.default;
|
|
6
13
|
return accumulator;
|
|
7
14
|
}, {});
|
|
@@ -9,6 +16,5 @@ const kirbyup = Object.freeze({ import(glob) {
|
|
|
9
16
|
function getComponentName(path) {
|
|
10
17
|
return path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".")).toLowerCase();
|
|
11
18
|
}
|
|
12
|
-
|
|
13
19
|
//#endregion
|
|
14
|
-
export { kirbyup };
|
|
20
|
+
export { kirbyup };
|
package/dist/node/cli.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as version, i as name, n as serve, r as handleError, t as build } from "../node-
|
|
1
|
+
import { a as version, i as name, n as serve, r as handleError, t as build } from "../node-Do_IAs2E.mjs";
|
|
2
2
|
import { cac } from "cac";
|
|
3
|
-
|
|
4
3
|
//#region src/node/cli-start.ts
|
|
5
4
|
async function startCli(cwd = process.cwd(), argv = process.argv) {
|
|
6
5
|
const cli = cac(name);
|
|
@@ -36,10 +35,8 @@ async function startCli(cwd = process.cwd(), argv = process.argv) {
|
|
|
36
35
|
cli.parse(argv, { run: false });
|
|
37
36
|
await cli.runMatchedCommand();
|
|
38
37
|
}
|
|
39
|
-
|
|
40
38
|
//#endregion
|
|
41
39
|
//#region src/node/cli.ts
|
|
42
40
|
startCli().catch(handleError);
|
|
43
|
-
|
|
44
41
|
//#endregion
|
|
45
|
-
export {
|
|
42
|
+
export {};
|
package/dist/node/index.d.mts
CHANGED
package/dist/node/index.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { n as serve, t as build } from "../node-
|
|
2
|
-
|
|
3
|
-
export { build, serve };
|
|
1
|
+
import { n as serve, t as build } from "../node-Do_IAs2E.mjs";
|
|
2
|
+
export { build, serve };
|
|
@@ -6,21 +6,20 @@ import { consola } from "consola";
|
|
|
6
6
|
import { colors } from "consola/utils";
|
|
7
7
|
import { basename, dirname, normalize, relative, resolve } from "pathe";
|
|
8
8
|
import { debounce } from "perfect-debounce";
|
|
9
|
-
import { build, createLogger, mergeConfig } from "vite";
|
|
9
|
+
import { build, createLogger, createServer, mergeConfig, normalizePath } from "vite";
|
|
10
10
|
import fullReloadPlugin from "vite-plugin-full-reload";
|
|
11
11
|
import * as vueCompilerSfc from "vue/compiler-sfc";
|
|
12
12
|
import { loadConfig } from "c12";
|
|
13
13
|
import postcssrc from "postcss-load-config";
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
15
|
import { detectPackageManager } from "nypm";
|
|
15
16
|
import { isIP } from "node:net";
|
|
16
17
|
import { Buffer } from "node:buffer";
|
|
17
18
|
import { promisify } from "node:util";
|
|
18
19
|
import { gzip } from "node:zlib";
|
|
19
|
-
|
|
20
20
|
//#region package.json
|
|
21
21
|
var name = "kirbyup";
|
|
22
|
-
var version = "4.0.0-alpha.
|
|
23
|
-
|
|
22
|
+
var version = "4.0.0-alpha.6";
|
|
24
23
|
//#endregion
|
|
25
24
|
//#region src/node/config.ts
|
|
26
25
|
function loadConfig$1(cwd = process.cwd()) {
|
|
@@ -38,7 +37,6 @@ async function resolvePostCSSConfig(cwd) {
|
|
|
38
37
|
if (!error.message.includes("No PostCSS Config found")) throw error;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
//#endregion
|
|
43
41
|
//#region src/node/errors.ts
|
|
44
42
|
var PrettyError = class extends Error {
|
|
@@ -53,7 +51,6 @@ function handleError(error) {
|
|
|
53
51
|
consola.error(error.message);
|
|
54
52
|
process.exitCode = 1;
|
|
55
53
|
}
|
|
56
|
-
|
|
57
54
|
//#endregion
|
|
58
55
|
//#region src/node/plugins/build-cleanup.ts
|
|
59
56
|
function kirbyupBuildCleanupPlugin(options) {
|
|
@@ -63,14 +60,14 @@ function kirbyupBuildCleanupPlugin(options) {
|
|
|
63
60
|
name: "kirbyup:build-cleanup",
|
|
64
61
|
configResolved(resolvedConfig) {
|
|
65
62
|
config = resolvedConfig;
|
|
66
|
-
devIndexPath = resolve(config.root, options.outDir, "index.dev.
|
|
63
|
+
devIndexPath = resolve(config.root, options.outDir, "index.dev.js");
|
|
67
64
|
},
|
|
68
65
|
writeBundle() {
|
|
66
|
+
if (options.watch) return;
|
|
69
67
|
if (fs.existsSync(devIndexPath)) fs.unlinkSync(devIndexPath);
|
|
70
68
|
}
|
|
71
69
|
};
|
|
72
70
|
}
|
|
73
|
-
|
|
74
71
|
//#endregion
|
|
75
72
|
//#region src/node/utils/server.ts
|
|
76
73
|
function resolveOriginFromServerOptions(serverOptions, port, fallbackHostname) {
|
|
@@ -103,178 +100,109 @@ function needsExplicitPort(protocol, port) {
|
|
|
103
100
|
if (protocol === "http") return port !== 80;
|
|
104
101
|
return port !== 443;
|
|
105
102
|
}
|
|
106
|
-
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/node/plugins/runtime/hmr-shim.js?raw
|
|
105
|
+
var hmr_shim_default = "/* eslint-disable no-undef */\nimport 'vue'\n\nif (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {\n const originalReload = __VUE_HMR_RUNTIME__.reload\n\n __VUE_HMR_RUNTIME__.reload = function (id, newComp) {\n const plugins = window.panel && window.panel.plugins\n const app = window.panel && window.panel.app\n\n if (\n plugins\n && app\n && plugins.components\n && typeof plugins.resolveComponentExtension === 'function'\n && typeof plugins.resolveComponentRender === 'function'\n && typeof plugins.resolveComponentMixins === 'function'\n ) {\n for (const name in plugins.components) {\n const pluginComp = plugins.components[name]\n if (\n pluginComp.__hmrId === id\n || (newComp.__file && pluginComp.__file === newComp.__file)\n ) {\n plugins.resolveComponentExtension(app, name, newComp)\n plugins.resolveComponentRender(newComp)\n plugins.resolveComponentMixins(newComp)\n break\n }\n }\n }\n\n return originalReload.call(this, id, newComp)\n }\n}\nelse {\n console.warn(\n '[kirbyup] Vue HMR runtime not detected; component changes will fall back to full page reload. The Kirby Panel may be loading a production build of Vue.',\n )\n}\n";
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/node/plugins/runtime/vue-stub.js?raw
|
|
108
|
+
var vue_stub_default = "const __kirbyupVueImportMapEl = typeof document !== 'undefined'\n ? document.querySelector('script[type=\"importmap\"]')\n : null\nconst __kirbyupVueImports = __kirbyupVueImportMapEl\n ? (() => {\n try {\n return JSON.parse(__kirbyupVueImportMapEl.textContent || '{}').imports || {}\n }\n // eslint-disable-next-line unused-imports/no-unused-vars\n catch (_) {\n return {}\n }\n })()\n : {}\nconst __kirbyupVueUrl = __kirbyupVueImports.vue\nif (!__kirbyupVueUrl) {\n throw new Error(\n '[kirbyup] No \"vue\" entry found in the page <script type=\"importmap\">. Ensure Kirby\\'s Panel is loaded with v6 import maps enabled.',\n )\n}\n// eslint-disable-next-line no-unused-vars, antfu/no-top-level-await\nconst __kirbyupVueModule = await import(/* @vite-ignore */ __kirbyupVueUrl)\n";
|
|
107
109
|
//#endregion
|
|
108
110
|
//#region src/node/plugins/utils.ts
|
|
109
111
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*
|
|
120
|
-
* }
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* However, Kirby does not register the exact object exported from a `.vue` file.
|
|
124
|
-
* Instead, it creates a new object and merges the definition in:
|
|
125
|
-
* https://github.com/getkirby/kirby/blob/main/panel/public/js/plugins.js
|
|
126
|
-
*
|
|
127
|
-
* After HMR changes, the runtime updates the stored definition and re-renders instances,
|
|
128
|
-
* but since they are derived from Kirby's modified object (not the stored definition),
|
|
129
|
-
* updates may not apply correctly.
|
|
130
|
-
*
|
|
131
|
-
* To fix this, we wrap `__VUE_HMR_RUNTIME__.rerender()` and `__VUE_HMR_RUNTIME__.reload()`:
|
|
132
|
-
*
|
|
133
|
-
* 1. **Before updates**, we check if the component belongs to a Kirby plugin by matching
|
|
134
|
-
* the `__hmrId` or `__file` properties against registered plugin components.
|
|
135
|
-
*
|
|
136
|
-
* 2. **If matched**, we look up the actual component definition used by Kirby
|
|
137
|
-
* (`window.panel.app.config.globalProperties.$root.$options.components`)
|
|
138
|
-
* and update the HMR map's reference to point to it.
|
|
139
|
-
*
|
|
140
|
-
* 3. **For section components** (detected by `k-*-section` name pattern), we add a
|
|
141
|
-
* `$_isSection` flag for special treatment in `$_applyKirbyModifications()`.
|
|
142
|
-
*
|
|
143
|
-
* `$_applyKirbyModifications()`:
|
|
144
|
-
*
|
|
145
|
-
* Kirby modifies component definitions before registration:
|
|
146
|
-
* - Adds the section mixin to section components
|
|
147
|
-
* - Gives templates priority over render functions
|
|
148
|
-
* - Resolves component names in `extends` to their definition objects
|
|
149
|
-
*
|
|
150
|
-
* When a module hot reloads, Vue 3 receives a fresh component definition missing
|
|
151
|
-
* these modifications. We re-apply them to ensure the runtime doesn't prune them
|
|
152
|
-
* when patching the stored definition with the updated one.
|
|
112
|
+
* Vue's `reload` does `Object.assign(record.initialDef, newComp)`, which would
|
|
113
|
+
* overwrite Kirby's in-place mutations on the stored definition. The shim
|
|
114
|
+
* re-runs Kirby's plugin helpers on `newComp` first; see
|
|
115
|
+
* https://github.com/getkirby/kirby/blob/v6/develop/panel/src/panel/plugins.ts
|
|
116
|
+
* ("expose helper functions for kirbyup"). `rerender` is not wrapped: in Vue 3
|
|
117
|
+
* it only swaps a render function, leaving Kirby's mutations untouched.
|
|
118
|
+
*/
|
|
119
|
+
const __HMR_SHIM_CODE__ = hmr_shim_default;
|
|
120
|
+
/**
|
|
121
|
+
* Extract public named exports from a Rollup-style ESM bundle. Vue's
|
|
122
|
+
* `dist/vue.esm-browser.js` ships a single trailing `export { ... }` block
|
|
123
|
+
* with a few `internalName as publicName` aliases.
|
|
153
124
|
*
|
|
154
|
-
*
|
|
155
|
-
* wrapper is installed only once, even though it's injected into every component.
|
|
125
|
+
* Only the last block is read; `as`-aliased entries yield the public name.
|
|
156
126
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
return originalReload.call(this, id, newComp);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
function $_getHmrRecord(id) {
|
|
180
|
-
// Vue 3's HMR map is not exposed, so we maintain our own parallel map
|
|
181
|
-
// by wrapping \`createRecord\` to track component definitions
|
|
182
|
-
if (!window.__KIRBYUP_MAP__) {
|
|
183
|
-
window.__KIRBYUP_MAP__ = new Map();
|
|
184
|
-
const originalCreate = __VUE_HMR_RUNTIME__.createRecord;
|
|
185
|
-
__VUE_HMR_RUNTIME__.createRecord = function(id, initialDef) {
|
|
186
|
-
window.__KIRBYUP_MAP__.set(id, { initialDef });
|
|
187
|
-
return originalCreate.call(this, id, initialDef);
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
return window.__KIRBYUP_MAP__.get(id);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function $_syncKirbyComponent(id, activeDef) {
|
|
194
|
-
const pluginComponents = window.panel?.plugins?.components;
|
|
195
|
-
const usedComponentDefs = window.panel?.app?.config?.globalProperties?.$root?.$options?.components;
|
|
196
|
-
|
|
197
|
-
if (!pluginComponents || !usedComponentDefs) return;
|
|
198
|
-
|
|
199
|
-
const record = $_getHmrRecord(id);
|
|
200
|
-
if (!record) return;
|
|
201
|
-
|
|
202
|
-
for (const componentName in pluginComponents) {
|
|
203
|
-
const pluginComp = pluginComponents[componentName];
|
|
204
|
-
|
|
205
|
-
if (pluginComp.__hmrId === id || pluginComp.__file === record.initialDef?.__file) {
|
|
206
|
-
const usedDef = usedComponentDefs[componentName];
|
|
207
|
-
|
|
208
|
-
if (usedDef && record.initialDef !== usedDef) {
|
|
209
|
-
record.initialDef = usedDef;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (activeDef && typeof activeDef.$_isSection !== 'boolean') {
|
|
213
|
-
activeDef.$_isSection = /^k-.*-section$/.test(componentName);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function $_applyKirbyModifications(activeDef, newDef) {
|
|
222
|
-
const usedComponentDefs = window.panel?.app?.config?.globalProperties?.$root?.$options?.components;
|
|
223
|
-
|
|
224
|
-
if (!usedComponentDefs) return;
|
|
225
|
-
|
|
226
|
-
// Give templates priority over render functions
|
|
227
|
-
if (newDef.template) {
|
|
228
|
-
newDef.render = null;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Re-apply section mixin for section components
|
|
232
|
-
if (activeDef.$_isSection) {
|
|
233
|
-
newDef.$_isSection = true;
|
|
234
|
-
if (!newDef.mixins?.[0]?.methods?.load) {
|
|
235
|
-
const sectionMixin = activeDef.mixins?.[0];
|
|
236
|
-
if (sectionMixin) {
|
|
237
|
-
newDef.mixins = [sectionMixin, ...(newDef.mixins || [])];
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// Resolve component name in extends to definition object
|
|
243
|
-
if (typeof newDef.extends === 'string') {
|
|
244
|
-
if (newDef.extends === activeDef.extends?.name) {
|
|
245
|
-
newDef.extends = activeDef.extends;
|
|
246
|
-
} else if (usedComponentDefs[newDef.extends]) {
|
|
247
|
-
newDef.extends = usedComponentDefs[newDef.extends];
|
|
248
|
-
} else {
|
|
249
|
-
newDef.extends = null;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
127
|
+
function extractEsmNamedExports(source) {
|
|
128
|
+
const blockMatches = [...source.matchAll(/export\s*\{([^}]*)\}/g)];
|
|
129
|
+
if (blockMatches.length === 0) return [];
|
|
130
|
+
return blockMatches.at(-1)[1].split(",").map((entry) => entry.trim()).filter(Boolean).map((entry) => {
|
|
131
|
+
const aliasMatch = entry.match(/^\S+\s+as\s+(\S+)$/);
|
|
132
|
+
return aliasMatch ? aliasMatch[1] : entry;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Reads Kirby's panel-vue URL at runtime from the page's
|
|
137
|
+
* `<script type="importmap">` and dynamic-imports it; the browser's module
|
|
138
|
+
* map dedups by URL, so plugin SFCs share Kirby's Vue instance (and
|
|
139
|
+
* `__VUE_HMR_RUNTIME__`). Top-level await lets consumers keep using ordinary
|
|
140
|
+
* `import { ... } from 'vue'` syntax.
|
|
141
|
+
*/
|
|
142
|
+
function buildVueStubCode(namedExports) {
|
|
143
|
+
if (namedExports.length === 0) return vue_stub_default;
|
|
144
|
+
return vue_stub_default + `\nexport const {\n${namedExports.map((name) => ` ${name},`).join("\n")}\n} = __kirbyupVueModule\n`;
|
|
253
145
|
}
|
|
254
|
-
/** -- */
|
|
255
|
-
`;
|
|
256
|
-
|
|
257
146
|
//#endregion
|
|
258
147
|
//#region src/node/plugins/hmr.ts
|
|
148
|
+
const SHIM_ID = "\0kirbyup:hmr-shim";
|
|
149
|
+
const SHIM_PUBLIC_ID = SHIM_ID.slice(1);
|
|
150
|
+
const VUE_STUB_ID = "\0kirbyup:vue-stub";
|
|
151
|
+
const VUE_STUB_PUBLIC_ID = VUE_STUB_ID.slice(1);
|
|
152
|
+
const VUE_NOT_FOUND_STUB = `throw new Error('[kirbyup] Cannot resolve "vue/dist/vue.esm-browser.js" from the plugin project. Make sure "vue" is installed as a dependency.')\n`;
|
|
259
153
|
function kirbyupHmrPlugin(options) {
|
|
260
154
|
let config;
|
|
261
155
|
let entry;
|
|
156
|
+
let entryId;
|
|
262
157
|
let devIndexPath;
|
|
158
|
+
let vueStubCode;
|
|
263
159
|
return {
|
|
264
160
|
name: "kirbyup:hmr",
|
|
265
161
|
apply: "serve",
|
|
162
|
+
enforce: "pre",
|
|
163
|
+
config() {
|
|
164
|
+
return {
|
|
165
|
+
optimizeDeps: { exclude: ["vue"] },
|
|
166
|
+
resolve: { alias: [{
|
|
167
|
+
find: /^vue$/,
|
|
168
|
+
replacement: VUE_STUB_ID
|
|
169
|
+
}] }
|
|
170
|
+
};
|
|
171
|
+
},
|
|
266
172
|
configResolved(resolvedConfig) {
|
|
267
173
|
config = resolvedConfig;
|
|
268
174
|
entry = resolve(config.root, options.entry);
|
|
269
|
-
|
|
175
|
+
entryId = normalizePath(entry);
|
|
176
|
+
devIndexPath = resolve(config.root, options.outDir ?? "", "index.dev.js");
|
|
177
|
+
try {
|
|
178
|
+
const vueUrl = import.meta.resolve("vue/dist/vue.esm-browser.js", pathToFileURL(`${config.root}/_`).href);
|
|
179
|
+
const namedExports = extractEsmNamedExports(fs.readFileSync(fileURLToPath(vueUrl), "utf8"));
|
|
180
|
+
vueStubCode = namedExports.length > 0 ? buildVueStubCode(namedExports) : void 0;
|
|
181
|
+
} catch {
|
|
182
|
+
vueStubCode = void 0;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
resolveId(source) {
|
|
186
|
+
if (source === SHIM_ID || source === SHIM_PUBLIC_ID) return SHIM_ID;
|
|
187
|
+
if (source === VUE_STUB_ID || source === VUE_STUB_PUBLIC_ID) return VUE_STUB_ID;
|
|
188
|
+
},
|
|
189
|
+
load(id) {
|
|
190
|
+
if (id === SHIM_ID) return {
|
|
191
|
+
code: __HMR_SHIM_CODE__,
|
|
192
|
+
map: null,
|
|
193
|
+
moduleType: "js"
|
|
194
|
+
};
|
|
195
|
+
if (id === VUE_STUB_ID) return {
|
|
196
|
+
code: vueStubCode ?? VUE_NOT_FOUND_STUB,
|
|
197
|
+
map: null,
|
|
198
|
+
moduleType: "js"
|
|
199
|
+
};
|
|
270
200
|
},
|
|
271
201
|
transform(code, id) {
|
|
272
|
-
if (
|
|
273
|
-
if (
|
|
274
|
-
const injectionPoint = code.indexOf("import.meta.hot.accept");
|
|
275
|
-
if (injectionPoint === -1) return;
|
|
202
|
+
if (normalizePath(id.split("?")[0]) !== entryId) return;
|
|
203
|
+
if (code.includes(SHIM_PUBLIC_ID)) return;
|
|
276
204
|
return {
|
|
277
|
-
code:
|
|
205
|
+
code: `import ${JSON.stringify(SHIM_ID)}\n${code}`,
|
|
278
206
|
map: null
|
|
279
207
|
};
|
|
280
208
|
},
|
|
@@ -293,9 +221,6 @@ function kirbyupHmrPlugin(options) {
|
|
|
293
221
|
}
|
|
294
222
|
};
|
|
295
223
|
}
|
|
296
|
-
/**
|
|
297
|
-
* Proxy the JS file to "forward" the plugin script loaded by Kirby to the Vite server
|
|
298
|
-
*/
|
|
299
224
|
function getViteProxyModule(entryUrl, packageManager) {
|
|
300
225
|
const pm = packageManager?.name || "npm";
|
|
301
226
|
return `
|
|
@@ -315,7 +240,6 @@ function getDevBaseUrl(server, config) {
|
|
|
315
240
|
const base = config.base ?? "/";
|
|
316
241
|
return new URL(base, normalizedOrigin).href;
|
|
317
242
|
}
|
|
318
|
-
|
|
319
243
|
//#endregion
|
|
320
244
|
//#region src/node/utils.ts
|
|
321
245
|
const compress = promisify(gzip);
|
|
@@ -333,7 +257,6 @@ async function printFileInfo({ root, outDir, filePath, content, type, maxLength
|
|
|
333
257
|
const writeColor = type === "chunk" ? colors.cyan : colors.magenta;
|
|
334
258
|
consola.log(colors.white(colors.dim(prettyOutDir)) + writeColor(filePath.padEnd(maxLength + 2)) + colors.dim(`${kibs.toFixed(2)} kB${compressedSize}`));
|
|
335
259
|
}
|
|
336
|
-
|
|
337
260
|
//#endregion
|
|
338
261
|
//#region src/node/index.ts
|
|
339
262
|
const DEV_OUTPUT_FILENAME = "index.dev.js";
|
|
@@ -373,7 +296,8 @@ function getViteConfig(command, options) {
|
|
|
373
296
|
server: {
|
|
374
297
|
port,
|
|
375
298
|
strictPort: true,
|
|
376
|
-
origin: inferredOrigin
|
|
299
|
+
origin: inferredOrigin,
|
|
300
|
+
cors: true
|
|
377
301
|
}
|
|
378
302
|
}), userConfig);
|
|
379
303
|
}
|
|
@@ -485,12 +409,14 @@ async function serve(options) {
|
|
|
485
409
|
resolvedKirbyupConfig = config ?? {};
|
|
486
410
|
resolvedPostCssConfig = await resolvePostCSSConfig(cwd);
|
|
487
411
|
consola.log(colors.green(`${name} v${version}`));
|
|
488
|
-
consola.info(
|
|
489
|
-
|
|
412
|
+
consola.info("Starting development server…");
|
|
413
|
+
const server = await createServer(getViteConfig("serve", options));
|
|
414
|
+
await server.listen();
|
|
415
|
+
consola.success(`Server is listening on :${server.config.server.port}`);
|
|
416
|
+
return server;
|
|
490
417
|
}
|
|
491
418
|
function assertEntryExists(options) {
|
|
492
419
|
if (!fs.existsSync(resolve(options.cwd, options.entry))) throw new PrettyError(`Cannot find "${options.entry}"`);
|
|
493
420
|
}
|
|
494
|
-
|
|
495
421
|
//#endregion
|
|
496
|
-
export { version as a, name as i, serve as n, handleError as r, build$1 as t };
|
|
422
|
+
export { version as a, name as i, serve as n, handleError as r, build$1 as t };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kirbyup",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "4.0.0-alpha.6",
|
|
5
|
+
"packageManager": "pnpm@10.33.3",
|
|
6
6
|
"description": "Zero-config bundler for Kirby Panel plugins",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Johann Schopplich",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"dist"
|
|
58
58
|
],
|
|
59
59
|
"engines": {
|
|
60
|
-
"node": ">=
|
|
60
|
+
"node": ">=24"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsdown",
|
|
@@ -71,32 +71,34 @@
|
|
|
71
71
|
"test:types": "tsc --noEmit"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
75
|
-
"@vitejs/plugin-vue-jsx": "^5.1.
|
|
76
|
-
"@vue/compiler-sfc": "^3.5.
|
|
77
|
-
"c12": "^
|
|
78
|
-
"cac": "^
|
|
74
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
75
|
+
"@vitejs/plugin-vue-jsx": "^5.1.5",
|
|
76
|
+
"@vue/compiler-sfc": "^3.5.34",
|
|
77
|
+
"c12": "^4.0.0-beta.4",
|
|
78
|
+
"cac": "^7.0.0",
|
|
79
79
|
"chokidar": "^5.0.0",
|
|
80
80
|
"consola": "^3.4.2",
|
|
81
81
|
"magic-string": "^0.30.21",
|
|
82
|
-
"nypm": "^0.6.
|
|
82
|
+
"nypm": "^0.6.6",
|
|
83
83
|
"pathe": "^2.0.3",
|
|
84
|
-
"perfect-debounce": "^2.
|
|
85
|
-
"postcss": "^8.5.
|
|
84
|
+
"perfect-debounce": "^2.1.0",
|
|
85
|
+
"postcss": "^8.5.14",
|
|
86
86
|
"postcss-load-config": "^6.0.1",
|
|
87
|
-
"sass": "^1.
|
|
88
|
-
"vite": "^
|
|
87
|
+
"sass": "^1.99.0",
|
|
88
|
+
"vite": "^8.0.10",
|
|
89
89
|
"vite-plugin-full-reload": "^1.2.0",
|
|
90
|
-
"vue": "^3.5.
|
|
90
|
+
"vue": "^3.5.34"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@antfu/eslint-config": "^
|
|
94
|
-
"@types/node": "^24.
|
|
95
|
-
"bumpp": "^
|
|
96
|
-
"eslint": "^
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
93
|
+
"@antfu/eslint-config": "^8.2.0",
|
|
94
|
+
"@types/node": "^24.12.2",
|
|
95
|
+
"bumpp": "^11.0.1",
|
|
96
|
+
"eslint": "^10.3.0",
|
|
97
|
+
"eslint-flat-config-utils": "^3.2.0",
|
|
98
|
+
"tinyglobby": "^0.2.16",
|
|
99
|
+
"tsdown": "^0.21.10",
|
|
100
|
+
"typescript": "^6.0.3",
|
|
101
|
+
"unplugin-raw": "^0.7.0",
|
|
102
|
+
"vitest": "^4.1.5"
|
|
101
103
|
}
|
|
102
104
|
}
|