@schalkneethling/miyagi-core 4.9.0 → 4.9.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.
- package/lib/cli/perf.js +1 -0
- package/lib/init/router.js +1 -0
- package/lib/performance/component.js +3 -1
- package/lib/performance/index.js +3 -0
- package/lib/performance/routes.js +2 -0
- package/lib/render/views/iframe/component.js +4 -1
- package/lib/render/views/main/component.js +1 -0
- package/package.json +1 -1
package/lib/cli/perf.js
CHANGED
package/lib/init/router.js
CHANGED
|
@@ -55,6 +55,7 @@ function resolveImportGraph(entryPath) {
|
|
|
55
55
|
* 50 kB util shows the real reachable size, not just the entry file.
|
|
56
56
|
* @param {{
|
|
57
57
|
* cwd: string,
|
|
58
|
+
* componentsFolder: string,
|
|
58
59
|
* componentPath: string,
|
|
59
60
|
* entry: { css?: { budget?: string }, js?: { budget?: string } },
|
|
60
61
|
* compression: "raw"|"gzip"|"brotli",
|
|
@@ -64,12 +65,13 @@ function resolveImportGraph(entryPath) {
|
|
|
64
65
|
*/
|
|
65
66
|
export function measureComponent({
|
|
66
67
|
cwd,
|
|
68
|
+
componentsFolder = "",
|
|
67
69
|
componentPath,
|
|
68
70
|
entry,
|
|
69
71
|
compression,
|
|
70
72
|
warnRatio,
|
|
71
73
|
}) {
|
|
72
|
-
const folder = path.join(cwd, componentPath);
|
|
74
|
+
const folder = path.join(cwd, componentsFolder, componentPath);
|
|
73
75
|
const componentName = path.basename(componentPath);
|
|
74
76
|
const cssPath = path.join(folder, `${componentName}.css`);
|
|
75
77
|
const jsPath = path.join(folder, `${componentName}.js`);
|
package/lib/performance/index.js
CHANGED
|
@@ -47,6 +47,7 @@ function tally(statuses) {
|
|
|
47
47
|
* declared page variation.
|
|
48
48
|
* @param {{
|
|
49
49
|
* cwd?: string,
|
|
50
|
+
* componentsFolder?: string,
|
|
50
51
|
* compression?: "raw"|"gzip"|"brotli",
|
|
51
52
|
* warnRatio?: number,
|
|
52
53
|
* render?: (templatePath: string, variation: string) => Promise<string>,
|
|
@@ -60,6 +61,7 @@ export async function runPerformance(options = {}) {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const cwd = options.cwd ?? process.cwd();
|
|
64
|
+
const componentsFolder = options.componentsFolder ?? "";
|
|
63
65
|
const compression = options.compression ?? config.compression;
|
|
64
66
|
const warnRatio = options.warnRatio ?? config.warnRatio;
|
|
65
67
|
|
|
@@ -68,6 +70,7 @@ export async function runPerformance(options = {}) {
|
|
|
68
70
|
for (const [componentPath, entry] of Object.entries(config.components)) {
|
|
69
71
|
const measurement = measureComponent({
|
|
70
72
|
cwd,
|
|
73
|
+
componentsFolder,
|
|
71
74
|
componentPath,
|
|
72
75
|
entry,
|
|
73
76
|
compression,
|
|
@@ -19,6 +19,7 @@ import { runPerformance } from "./index.js";
|
|
|
19
19
|
* @param {object} app - Express app
|
|
20
20
|
* @param {{
|
|
21
21
|
* cwd: string,
|
|
22
|
+
* componentsFolder?: string,
|
|
22
23
|
* render?: (templatePath: string, variation: string) => Promise<string>,
|
|
23
24
|
* }} options
|
|
24
25
|
* @returns {boolean} true when the config file exists at registration time
|
|
@@ -28,6 +29,7 @@ export function attachPerformanceRoutes(app, options) {
|
|
|
28
29
|
try {
|
|
29
30
|
const result = await runPerformance({
|
|
30
31
|
cwd: options.cwd,
|
|
32
|
+
componentsFolder: options.componentsFolder,
|
|
31
33
|
render: options.render,
|
|
32
34
|
});
|
|
33
35
|
if (!result.enabled) {
|
|
@@ -250,7 +250,10 @@ async function renderVariations({
|
|
|
250
250
|
|
|
251
251
|
let perfSection;
|
|
252
252
|
try {
|
|
253
|
-
const perfResult = await runPerformance({
|
|
253
|
+
const perfResult = await runPerformance({
|
|
254
|
+
cwd: process.cwd(),
|
|
255
|
+
componentsFolder: global.config.components.folder,
|
|
256
|
+
});
|
|
254
257
|
perfSection = buildComponentPerfSection(
|
|
255
258
|
perfResult,
|
|
256
259
|
component.paths.dir.short,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schalkneethling/miyagi-core",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.1",
|
|
4
4
|
"description": "miyagi is a component development tool for JavaScript template engines.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Schalk Neethling <schalkneethling@duck.com>, Michael Großklaus <mail@mgrossklaus.de> (https://www.mgrossklaus.de)",
|