kirbyup 2.1.2 → 2.2.0-beta.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/LICENSE +2 -2
- package/README.md +4 -4
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +3 -4
- package/dist/index.mjs +3 -4
- package/dist/plugin.mjs +10 -1
- package/dist/shared/{kirbyup.f44725b4.mjs → kirbyup.54d984e1.mjs} +79 -43
- package/package.json +20 -20
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021-
|
|
4
|
-
Copyright (c) 2022 Jonas Kuske <https://github.com/jonaskuske>
|
|
3
|
+
Copyright (c) 2021-2023 Johann Schopplich <https://github.com/johannschopplich>
|
|
4
|
+
Copyright (c) 2022-2023 Jonas Kuske <https://github.com/jonaskuske>
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ If you want to use kirbyup right away, there is no need to install it. Simply ca
|
|
|
43
43
|
|
|
44
44
|
> If `npx` doesn't use the latest kirbyup version, although it is available, run `npx -y kirbyup@latest` instead or delete the `~/.npm/_npx` cache folder.
|
|
45
45
|
|
|
46
|
-
While kirbyup will stay backwards compatible, exact build reproducibility may be of importance to you. If so, I recommend
|
|
46
|
+
While kirbyup will stay backwards compatible, exact build reproducibility may be of importance to you. If so, I recommend targeting a specific package version, rather than using `npx`. Install kirbyup with a package manager of your choice locally to your project:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
npm i kirbyup --save-dev
|
|
@@ -184,7 +184,7 @@ Only `KIRBYUP_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to yo
|
|
|
184
184
|
Create a `kirbyup.config.js` or `kirbyup.config.ts` configuration file the root-level of your project to customize kirbyup.
|
|
185
185
|
|
|
186
186
|
```js
|
|
187
|
-
import { resolve } from 'path'
|
|
187
|
+
import { resolve } from 'node:path'
|
|
188
188
|
import { defineConfig } from 'kirbyup/config'
|
|
189
189
|
|
|
190
190
|
export default defineConfig({
|
|
@@ -252,6 +252,6 @@ Disables the default behavior of watching all PHP files for changes.
|
|
|
252
252
|
|
|
253
253
|
## License
|
|
254
254
|
|
|
255
|
-
[MIT](./LICENSE) License © 2021-
|
|
255
|
+
[MIT](./LICENSE) License © 2021-2023 [Johann Schopplich](https://github.com/johannschopplich)
|
|
256
256
|
|
|
257
|
-
[MIT](./LICENSE) License © 2022 [Jonas Kuske](https://github.com/jonaskuske)
|
|
257
|
+
[MIT](./LICENSE) License © 2022-2023 [Jonas Kuske](https://github.com/jonaskuske)
|
package/dist/cli.d.ts
CHANGED
package/dist/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.
|
|
2
|
+
import { n as name, b as build, s as serve, v as version, h as handleError } from './shared/kirbyup.54d984e1.mjs';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:fs/promises';
|
|
5
5
|
import 'pathe';
|
|
@@ -14,9 +14,8 @@ import 'vite-plugin-full-reload';
|
|
|
14
14
|
import 'postcss-load-config';
|
|
15
15
|
import 'postcss-logical';
|
|
16
16
|
import 'postcss-dir-pseudo-class';
|
|
17
|
-
import 'zlib';
|
|
18
|
-
import 'util';
|
|
19
|
-
import 'fs';
|
|
17
|
+
import 'node:zlib';
|
|
18
|
+
import 'node:util';
|
|
20
19
|
import 'unconfig';
|
|
21
20
|
import 'magic-string';
|
|
22
21
|
import 'detect-package-manager';
|
package/dist/index.mjs
CHANGED
|
@@ -12,10 +12,9 @@ import 'vite-plugin-full-reload';
|
|
|
12
12
|
import 'postcss-load-config';
|
|
13
13
|
import 'postcss-logical';
|
|
14
14
|
import 'postcss-dir-pseudo-class';
|
|
15
|
-
export { b as build, s as serve } from './shared/kirbyup.
|
|
16
|
-
import 'zlib';
|
|
17
|
-
import 'util';
|
|
18
|
-
import 'fs';
|
|
15
|
+
export { b as build, s as serve } from './shared/kirbyup.54d984e1.mjs';
|
|
16
|
+
import 'node:zlib';
|
|
17
|
+
import 'node:util';
|
|
19
18
|
import 'unconfig';
|
|
20
19
|
import 'magic-string';
|
|
21
20
|
import 'detect-package-manager';
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
const getComponentName = (path) => path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".")).toLowerCase();
|
|
2
1
|
const kirbyup = Object.freeze({
|
|
2
|
+
/**
|
|
3
|
+
* Auto-import Kirby Panel components, will be transformed by
|
|
4
|
+
* kirbyup's auto import plugin for Vite
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* kirbyup.import('./components/blocks/*.vue')
|
|
8
|
+
*/
|
|
3
9
|
import(glob) {
|
|
4
10
|
const modules = glob;
|
|
5
11
|
return Object.entries(modules).reduce(
|
|
@@ -11,5 +17,8 @@ const kirbyup = Object.freeze({
|
|
|
11
17
|
);
|
|
12
18
|
}
|
|
13
19
|
});
|
|
20
|
+
function getComponentName(path) {
|
|
21
|
+
return path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".")).toLowerCase();
|
|
22
|
+
}
|
|
14
23
|
|
|
15
24
|
export { kirbyup };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync
|
|
1
|
+
import { existsSync, statSync, unlinkSync } from 'node:fs';
|
|
2
2
|
import { writeFile, readFile } from 'node:fs/promises';
|
|
3
3
|
import { normalize, relative, resolve, dirname, basename } from 'pathe';
|
|
4
4
|
import consola from 'consola';
|
|
@@ -12,15 +12,14 @@ import fullReloadPlugin from 'vite-plugin-full-reload';
|
|
|
12
12
|
import postcssrc from 'postcss-load-config';
|
|
13
13
|
import postcssLogical from 'postcss-logical';
|
|
14
14
|
import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
|
|
15
|
-
import { gzip } from 'zlib';
|
|
16
|
-
import { promisify } from 'util';
|
|
17
|
-
import { existsSync, statSync } from 'fs';
|
|
15
|
+
import { gzip } from 'node:zlib';
|
|
16
|
+
import { promisify } from 'node:util';
|
|
18
17
|
import { createConfigLoader } from 'unconfig';
|
|
19
18
|
import MagicString from 'magic-string';
|
|
20
19
|
import { detect } from 'detect-package-manager';
|
|
21
20
|
|
|
22
21
|
const name = "kirbyup";
|
|
23
|
-
const version = "2.
|
|
22
|
+
const version = "2.2.0-beta.0";
|
|
24
23
|
|
|
25
24
|
class PrettyError extends Error {
|
|
26
25
|
constructor(message) {
|
|
@@ -101,7 +100,9 @@ const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
|
|
|
101
100
|
const singlelineCommentsRE = /\/\/.*/g;
|
|
102
101
|
const HMR_RUNTIME_ID = "\0plugin-vue2:hmr-runtime";
|
|
103
102
|
const JSX_HMR_RUNTIME_ID = "plugin-vue2-jsx:hmr-runtime";
|
|
104
|
-
|
|
103
|
+
function isHmrRuntimeId(id) {
|
|
104
|
+
return id === HMR_RUNTIME_ID || id === JSX_HMR_RUNTIME_ID;
|
|
105
|
+
}
|
|
105
106
|
const __INJECTED_HMR_CODE__ = `
|
|
106
107
|
/** - injected by kirbyup - */
|
|
107
108
|
for (const methodName of ['rerender', 'reload']) {
|
|
@@ -120,7 +121,7 @@ for (const methodName of ['rerender', 'reload']) {
|
|
|
120
121
|
|
|
121
122
|
if (map[id].options !== usedDefinition)
|
|
122
123
|
map[id].options = usedDefinition
|
|
123
|
-
|
|
124
|
+
|
|
124
125
|
if (typeof map[id].options.$_isSection !== 'boolean')
|
|
125
126
|
map[id].options.$_isSection = /^k-.*-section$/.test(componentName)
|
|
126
127
|
|
|
@@ -168,42 +169,52 @@ function kirbyupAutoImportPlugin() {
|
|
|
168
169
|
config = resolvedConfig;
|
|
169
170
|
},
|
|
170
171
|
async transform(code) {
|
|
171
|
-
if (code.includes("kirbyup.import"))
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
s
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
}
|
|
172
|
+
if (!code.includes("kirbyup.import"))
|
|
173
|
+
return;
|
|
174
|
+
const kirbyupImportRE = /\bkirbyup\.import\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*\)/g;
|
|
175
|
+
const noCommentsCode = code.replace(multilineCommentsRE, (m) => " ".repeat(m.length)).replace(singlelineCommentsRE, (m) => " ".repeat(m.length));
|
|
176
|
+
let s;
|
|
177
|
+
let match;
|
|
178
|
+
while (match = kirbyupImportRE.exec(noCommentsCode)) {
|
|
179
|
+
const { 0: exp, 1: rawPath, index } = match;
|
|
180
|
+
if (!s)
|
|
181
|
+
s = new MagicString(code);
|
|
182
|
+
s.overwrite(
|
|
183
|
+
index,
|
|
184
|
+
index + exp.length,
|
|
185
|
+
`kirbyup.import(import.meta.glob(${rawPath}, { eager: true }))`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
if (s) {
|
|
189
|
+
return {
|
|
190
|
+
code: s.toString(),
|
|
191
|
+
map: config.build.sourcemap ? s.generateMap({ hires: true }) : void 0
|
|
192
|
+
};
|
|
192
193
|
}
|
|
193
|
-
return null;
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
function kirbyupComponentCleanupPlugin() {
|
|
199
|
+
return {
|
|
200
|
+
name: "kirbyup:component-cleanup",
|
|
201
|
+
async transform(code) {
|
|
202
|
+
if (!code.includes("__component__.options.__file"))
|
|
203
|
+
return;
|
|
204
|
+
const fileOptionRE = /\b__component__.options.__file\s*=\s*('[^']+'|"[^"]+"|`[^`]+`)/g;
|
|
205
|
+
const match = fileOptionRE.exec(code);
|
|
206
|
+
if (!match)
|
|
207
|
+
return;
|
|
208
|
+
const { 0: exp, index } = match;
|
|
209
|
+
const s = new MagicString(code);
|
|
210
|
+
s.remove(index, index + exp.length);
|
|
211
|
+
return {
|
|
212
|
+
code: s.toString()
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
207
218
|
function kirbyupHmrPlugin(options) {
|
|
208
219
|
let config;
|
|
209
220
|
let entry;
|
|
@@ -219,6 +230,7 @@ function kirbyupHmrPlugin(options) {
|
|
|
219
230
|
transform(code, id) {
|
|
220
231
|
if (isHmrRuntimeId(id)) {
|
|
221
232
|
return code.replace(
|
|
233
|
+
// https://github.com/vitejs/vite-plugin-vue2/blob/06ede94/src/utils/hmrRuntime.ts#L173
|
|
222
234
|
/^.*=\s*record\.Ctor\.super\.extend\(options\)/m,
|
|
223
235
|
"$_applyKirbyModifications(record.Ctor.options, options) // injected by kirbyup\n$&"
|
|
224
236
|
) + __INJECTED_HMR_CODE__;
|
|
@@ -238,11 +250,22 @@ function kirbyupHmrPlugin(options) {
|
|
|
238
250
|
});
|
|
239
251
|
},
|
|
240
252
|
closeBundle() {
|
|
241
|
-
if (existsSync
|
|
253
|
+
if (existsSync(indexMjs))
|
|
242
254
|
unlinkSync(indexMjs);
|
|
243
255
|
}
|
|
244
256
|
};
|
|
245
257
|
}
|
|
258
|
+
function getViteProxyModule(entryUrl, pm) {
|
|
259
|
+
return `
|
|
260
|
+
try {
|
|
261
|
+
await import("${entryUrl}");
|
|
262
|
+
} catch (err) {
|
|
263
|
+
console.error(
|
|
264
|
+
"[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."
|
|
265
|
+
);
|
|
266
|
+
throw err;
|
|
267
|
+
}`.trim();
|
|
268
|
+
}
|
|
246
269
|
|
|
247
270
|
function kirbyupBuildCleanupPlugin(options) {
|
|
248
271
|
let config;
|
|
@@ -254,7 +277,7 @@ function kirbyupBuildCleanupPlugin(options) {
|
|
|
254
277
|
indexMjs = resolve(config.root, options.outDir, "index.dev.mjs");
|
|
255
278
|
},
|
|
256
279
|
writeBundle() {
|
|
257
|
-
if (existsSync
|
|
280
|
+
if (existsSync(indexMjs))
|
|
258
281
|
unlinkSync(indexMjs);
|
|
259
282
|
}
|
|
260
283
|
};
|
|
@@ -267,12 +290,19 @@ function getViteConfig(command, options) {
|
|
|
267
290
|
const { alias = {}, extendViteConfig = {} } = resolvedKirbyupConfig;
|
|
268
291
|
const baseConfig = {
|
|
269
292
|
resolve: {
|
|
270
|
-
alias: {
|
|
293
|
+
alias: {
|
|
294
|
+
"~/": `${aliasDir}/`,
|
|
295
|
+
"@/": `${aliasDir}/`,
|
|
296
|
+
...alias
|
|
297
|
+
}
|
|
271
298
|
},
|
|
272
299
|
plugins: [
|
|
300
|
+
// Explicitly pass the compiler, since the plugin's resolving of the compiler
|
|
301
|
+
// looks in the current directory and breaks `npx kirbyup`
|
|
273
302
|
vuePlugin({ compiler: vueCompilerSfc }),
|
|
274
303
|
vueJsxPlugin(),
|
|
275
|
-
kirbyupAutoImportPlugin()
|
|
304
|
+
kirbyupAutoImportPlugin(),
|
|
305
|
+
kirbyupComponentCleanupPlugin()
|
|
276
306
|
],
|
|
277
307
|
css: { postcss: resolvedPostCssConfig },
|
|
278
308
|
envPrefix: ["VITE_", "KIRBYUP_"],
|
|
@@ -285,7 +315,9 @@ function getViteConfig(command, options) {
|
|
|
285
315
|
kirbyupHmrPlugin(options),
|
|
286
316
|
watch && fullReloadPlugin(watch)
|
|
287
317
|
],
|
|
318
|
+
// Input needs to be specified so dep pre-bundling works
|
|
288
319
|
build: { rollupOptions: { input: resolve(options.cwd, options.entry) } },
|
|
320
|
+
// Specify origin so asset URLs include Vite server host
|
|
289
321
|
server: { port, strictPort: true, origin: `http://localhost:${port}` }
|
|
290
322
|
});
|
|
291
323
|
return mergeConfig(serveConfig, extendViteConfig);
|
|
@@ -336,6 +368,7 @@ async function generate(options) {
|
|
|
336
368
|
for (const {
|
|
337
369
|
fileName,
|
|
338
370
|
type,
|
|
371
|
+
// @ts-expect-error: `code` not available in `OutputAsset`
|
|
339
372
|
code
|
|
340
373
|
} of output) {
|
|
341
374
|
await printFileInfo(
|
|
@@ -361,6 +394,7 @@ async function build(options) {
|
|
|
361
394
|
if (!/No PostCSS Config found/.test(err.message))
|
|
362
395
|
throw err;
|
|
363
396
|
resolvedPostCssConfig = {
|
|
397
|
+
// @ts-expect-error: types won't match
|
|
364
398
|
plugins: [postcssLogical(), postcssDirPseudoClass()]
|
|
365
399
|
};
|
|
366
400
|
}
|
|
@@ -379,6 +413,7 @@ async function build(options) {
|
|
|
379
413
|
const { watch } = await import('chokidar');
|
|
380
414
|
const ignored = [
|
|
381
415
|
"**/{.git,node_modules}/**",
|
|
416
|
+
// Always ignore out files
|
|
382
417
|
"index.{css,js}"
|
|
383
418
|
];
|
|
384
419
|
const watchPaths = typeof options.watch === "boolean" ? dirname(options.entry) : Array.isArray(options.watch) ? options.watch.filter(
|
|
@@ -422,6 +457,7 @@ async function serve(options) {
|
|
|
422
457
|
if (!/No PostCSS Config found/.test(err.message))
|
|
423
458
|
throw err;
|
|
424
459
|
resolvedPostCssConfig = {
|
|
460
|
+
// @ts-expect-error: types won't match
|
|
425
461
|
plugins: [postcssLogical(), postcssDirPseudoClass()]
|
|
426
462
|
};
|
|
427
463
|
}
|
|
@@ -435,7 +471,7 @@ async function serve(options) {
|
|
|
435
471
|
return server;
|
|
436
472
|
}
|
|
437
473
|
function ensureEntry(options) {
|
|
438
|
-
if (!existsSync
|
|
474
|
+
if (!existsSync(resolve(options.cwd, options.entry)))
|
|
439
475
|
throw new PrettyError(`Cannot find "${options.entry}"`);
|
|
440
476
|
}
|
|
441
477
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kirbyup",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"packageManager": "pnpm@
|
|
3
|
+
"version": "2.2.0-beta.0",
|
|
4
|
+
"packageManager": "pnpm@8.1.0",
|
|
5
5
|
"description": "Zero-config bundler for Kirby Panel plugins",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Johann Schopplich",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dist"
|
|
56
56
|
],
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": "
|
|
58
|
+
"node": ">=16"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|
|
@@ -75,33 +75,33 @@
|
|
|
75
75
|
"chokidar": "^3.5.3",
|
|
76
76
|
"consola": "^2.15.3",
|
|
77
77
|
"detect-package-manager": "^2.0.1",
|
|
78
|
-
"magic-string": "^0.
|
|
79
|
-
"pathe": "^1.
|
|
78
|
+
"magic-string": "^0.30.0",
|
|
79
|
+
"pathe": "^1.1.0",
|
|
80
80
|
"perfect-debounce": "^0.1.3",
|
|
81
81
|
"picocolors": "^1.0.0",
|
|
82
|
-
"postcss": "^8.4.
|
|
83
|
-
"postcss-dir-pseudo-class": "^
|
|
82
|
+
"postcss": "^8.4.21",
|
|
83
|
+
"postcss-dir-pseudo-class": "^7.0.2",
|
|
84
84
|
"postcss-load-config": "^4.0.1",
|
|
85
|
-
"postcss-logical": "^
|
|
86
|
-
"sass": "^1.
|
|
85
|
+
"postcss-logical": "^6.1.0",
|
|
86
|
+
"sass": "^1.60.0",
|
|
87
87
|
"unconfig": "^0.3.7",
|
|
88
|
-
"vite": "^
|
|
88
|
+
"vite": "^4.2.1",
|
|
89
89
|
"vite-plugin-full-reload": "^1.0.5",
|
|
90
90
|
"vue": "^2.7.14"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@antfu/eslint-config": "^0.
|
|
94
|
-
"@types/fs-extra": "^
|
|
95
|
-
"@types/node": "^18.11
|
|
96
|
-
"@types/prompts": "^2.4.
|
|
97
|
-
"bumpp": "^
|
|
98
|
-
"eslint": "^8.
|
|
93
|
+
"@antfu/eslint-config": "^0.38.2",
|
|
94
|
+
"@types/fs-extra": "^11.0.1",
|
|
95
|
+
"@types/node": "^18.15.11",
|
|
96
|
+
"@types/prompts": "^2.4.4",
|
|
97
|
+
"bumpp": "^9.1.0",
|
|
98
|
+
"eslint": "^8.37.0",
|
|
99
99
|
"fast-glob": "^3.2.12",
|
|
100
|
-
"fs-extra": "^11.1.
|
|
100
|
+
"fs-extra": "^11.1.1",
|
|
101
101
|
"simple-git-hooks": "^2.8.1",
|
|
102
|
-
"typescript": "^
|
|
103
|
-
"unbuild": "^1.0
|
|
104
|
-
"vitest": "^0.
|
|
102
|
+
"typescript": "^5.0.3",
|
|
103
|
+
"unbuild": "^1.2.0",
|
|
104
|
+
"vitest": "^0.29.8"
|
|
105
105
|
},
|
|
106
106
|
"simple-git-hooks": {
|
|
107
107
|
"commit-msg": "node scripts/verifyCommit.mjs $1"
|