@wearejh/m2-pwa-engine 0.38.0 → 0.39.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.39.0](https://github.com/WeareJH/mage-mono/compare/v0.38.0...v0.39.0) (2025-11-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* separate fs imports from client-bundled code ([ce7ba53](https://github.com/WeareJH/mage-mono/commit/ce7ba53055bbfb088e3a4ee9196d0680fa71681b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.38.0](https://github.com/WeareJH/mage-mono/compare/v0.37.0...v0.38.0) (2025-11-07)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -3,19 +3,10 @@ import { join } from 'path';
|
|
|
3
3
|
|
|
4
4
|
import dlv from 'dlv';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
[chunkName: string]: {
|
|
8
|
-
chunks: number[];
|
|
9
|
-
assets: string[];
|
|
10
|
-
children: {};
|
|
11
|
-
childAssets: {};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
6
|
+
import { Stats, CriticalAssets } from './getCriticalAssets.types';
|
|
14
7
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
css: string;
|
|
18
|
-
};
|
|
8
|
+
export * from './getCriticalAssets.types';
|
|
9
|
+
export * from './getCriticalAssets.utils';
|
|
19
10
|
|
|
20
11
|
export function getCriticalAssets(stats: Stats, base: string): CriticalAssets {
|
|
21
12
|
const css = dlv(stats, ['client', 'assets'], []).filter((x) => x.match(/\.css$/));
|
|
@@ -27,52 +18,3 @@ export function getCriticalAssets(stats: Stats, base: string): CriticalAssets {
|
|
|
27
18
|
|
|
28
19
|
return output;
|
|
29
20
|
}
|
|
30
|
-
|
|
31
|
-
export function getCriticalCssPaths(stats: Stats): string[] {
|
|
32
|
-
return dlv(stats, ['client', 'assets'], []).filter((x) => x.match(/\.css$/));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function getJsEntryPointFilePaths(stats: Stats): string[] {
|
|
36
|
-
const entries = dlv(stats, ['client', 'assets'], []);
|
|
37
|
-
return entries.filter((x) => x.match(/\.js$/)).filter((x) => !x.match(/runtime~client/));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getAssetsForType(
|
|
41
|
-
componentNames: string[],
|
|
42
|
-
stats: Stats,
|
|
43
|
-
): { css: string[]; js: string[]; criticalCss: string[] } {
|
|
44
|
-
if (!componentNames.length) {
|
|
45
|
-
return { js: [], css: [], criticalCss: [] };
|
|
46
|
-
}
|
|
47
|
-
const typeName = componentNames[0];
|
|
48
|
-
const asRootName = `${typeName}_root`;
|
|
49
|
-
|
|
50
|
-
const firstMatch: string[] = Object.keys(stats)
|
|
51
|
-
.filter((x) => x === asRootName)
|
|
52
|
-
.map((x) => stats[x].assets)[0];
|
|
53
|
-
|
|
54
|
-
if (!firstMatch) {
|
|
55
|
-
return { js: [], css: [], criticalCss: [] };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const js = firstMatch.filter((x) => Boolean(x.match(/\.js$/)));
|
|
59
|
-
const criticalCss = getCriticalCssPaths(stats);
|
|
60
|
-
const css = firstMatch.filter((x) => Boolean(x.match(/\.css$/)));
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
js,
|
|
64
|
-
css,
|
|
65
|
-
criticalCss,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function assetToUrl(path: string, prefix: string, timestamp?: number): string {
|
|
70
|
-
if (timestamp) {
|
|
71
|
-
return join(prefix, path + '?' + String(timestamp));
|
|
72
|
-
}
|
|
73
|
-
return join(prefix, path);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function assetsToUrls(paths: string[], prefix: string, timestamp?: number): string[] {
|
|
77
|
-
return paths.map((path) => assetToUrl(path, prefix, timestamp));
|
|
78
|
-
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
|
|
3
|
+
import dlv from 'dlv';
|
|
4
|
+
|
|
5
|
+
import { Stats } from './getCriticalAssets.types';
|
|
6
|
+
|
|
7
|
+
export function getCriticalCssPaths(stats: Stats): string[] {
|
|
8
|
+
return dlv(stats, ['client', 'assets'], []).filter((x) => x.match(/\.css$/));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getJsEntryPointFilePaths(stats: Stats): string[] {
|
|
12
|
+
const entries = dlv(stats, ['client', 'assets'], []);
|
|
13
|
+
return entries.filter((x) => x.match(/\.js$/)).filter((x) => !x.match(/runtime~client/));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getAssetsForType(
|
|
17
|
+
componentNames: string[],
|
|
18
|
+
stats: Stats,
|
|
19
|
+
): { css: string[]; js: string[]; criticalCss: string[] } {
|
|
20
|
+
if (!componentNames.length) {
|
|
21
|
+
return { js: [], css: [], criticalCss: [] };
|
|
22
|
+
}
|
|
23
|
+
const typeName = componentNames[0];
|
|
24
|
+
const asRootName = `${typeName}_root`;
|
|
25
|
+
|
|
26
|
+
const firstMatch: string[] = Object.keys(stats)
|
|
27
|
+
.filter((x) => x === asRootName)
|
|
28
|
+
.map((x) => stats[x].assets)[0];
|
|
29
|
+
|
|
30
|
+
if (!firstMatch) {
|
|
31
|
+
return { js: [], css: [], criticalCss: [] };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const js = firstMatch.filter((x) => Boolean(x.match(/\.js$/)));
|
|
35
|
+
const criticalCss = getCriticalCssPaths(stats);
|
|
36
|
+
const css = firstMatch.filter((x) => Boolean(x.match(/\.css$/)));
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
js,
|
|
40
|
+
css,
|
|
41
|
+
criticalCss,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function assetToUrl(path: string, prefix: string, timestamp?: number): string {
|
|
46
|
+
if (timestamp) {
|
|
47
|
+
return join(prefix, path + '?' + String(timestamp));
|
|
48
|
+
}
|
|
49
|
+
return join(prefix, path);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function assetsToUrls(paths: string[], prefix: string, timestamp?: number): string[] {
|
|
53
|
+
return paths.map((path) => assetToUrl(path, prefix, timestamp));
|
|
54
|
+
}
|
|
@@ -8,7 +8,8 @@ import { blockingStylesheet, cssFiles } from './templates/cssFiles';
|
|
|
8
8
|
import { fsFiles } from './templates/js';
|
|
9
9
|
import { gqlState } from './templates/gqlState';
|
|
10
10
|
import { appEnv } from './templates/appEnv';
|
|
11
|
-
import { assetsToUrls, getAssetsForType, getJsEntryPointFilePaths
|
|
11
|
+
import { assetsToUrls, getAssetsForType, getJsEntryPointFilePaths } from './getCriticalAssets.utils';
|
|
12
|
+
import { Stats } from './getCriticalAssets.types';
|
|
12
13
|
import { SsrResult } from './ssrMiddleware';
|
|
13
14
|
import { reduxState as renderReduxState } from './templates/reduxState';
|
|
14
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wearejh/m2-pwa-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Shane Osbourne <shane.osbourne8@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@wearejh/m2-pwa-vars": "^0.
|
|
22
|
-
"@wearejh/swagger-rxjs": "^0.
|
|
21
|
+
"@wearejh/m2-pwa-vars": "^0.39.0",
|
|
22
|
+
"@wearejh/swagger-rxjs": "^0.39.0",
|
|
23
23
|
"history": "^4.10.1",
|
|
24
24
|
"loadcss": "^0.0.2"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "5ddc698e301ec2ca5df42fc298bf2ba57497f95d"
|
|
27
27
|
}
|