sku 14.1.0 → 14.1.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/CHANGELOG.md +6 -0
- package/dist/config/jest/jsBabelTransform.js +2 -2
- package/dist/config/jest/tsBabelTransform.js +2 -2
- package/dist/services/vite/helpers/createConfig.d.ts +1 -0
- package/dist/services/vite/helpers/createConfig.js +7 -0
- package/dist/services/vite/helpers/prerenderRoutes.js +1 -0
- package/dist/services/vite/loadable/collector.d.ts +4 -2
- package/dist/services/vite/loadable/collector.js +17 -5
- package/dist/services/vite/loadable/helpers/preloadUtils.js +4 -4
- package/dist/services/vite/loadable/helpers/scriptUtils.d.ts +1 -1
- package/dist/services/vite/loadable/helpers/scriptUtils.js +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createTransformer } from 'babel-jest';
|
|
2
2
|
import babelConfig from '../babel/babelConfig.js';
|
|
3
3
|
import targets from '../targets.json' with { type: 'json' };
|
|
4
4
|
import { getSkuContext } from "../../context/createSkuContext.js";
|
|
5
5
|
const { rootResolution } = getSkuContext();
|
|
6
|
-
export default
|
|
6
|
+
export default createTransformer(babelConfig({
|
|
7
7
|
target: 'jest',
|
|
8
8
|
rootResolution,
|
|
9
9
|
browserslist: targets.browserslistNodeTarget,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createTransformer } from 'babel-jest';
|
|
2
2
|
import babelConfig from '../babel/babelConfig.js';
|
|
3
3
|
import targets from '../targets.json' with { type: 'json' };
|
|
4
4
|
import { getSkuContext } from "../../context/createSkuContext.js";
|
|
5
5
|
const { rootResolution } = getSkuContext();
|
|
6
|
-
export default
|
|
6
|
+
export default createTransformer(babelConfig({
|
|
7
7
|
target: 'jest',
|
|
8
8
|
lang: 'ts',
|
|
9
9
|
rootResolution,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire, builtinModules } from 'node:module';
|
|
2
2
|
import react from '@vitejs/plugin-react-swc';
|
|
3
|
+
import { cjsInterop } from 'vite-plugin-cjs-interop';
|
|
3
4
|
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
|
4
5
|
import skuVitePreloadPlugin from '../plugins/skuVitePreloadPlugin.js';
|
|
5
6
|
import { fixViteVanillaExtractDepScanPlugin } from "../plugins/esbuild/fixViteVanillaExtractDepScanPlugin.js";
|
|
@@ -19,6 +20,9 @@ export const createViteConfig = ({ skuContext, configType = 'client', plugins =
|
|
|
19
20
|
return {
|
|
20
21
|
root: process.cwd(),
|
|
21
22
|
plugins: [
|
|
23
|
+
cjsInterop({
|
|
24
|
+
dependencies: ['@apollo/client', 'lodash'],
|
|
25
|
+
}),
|
|
22
26
|
react(),
|
|
23
27
|
vanillaExtractPlugin(),
|
|
24
28
|
skuVitePreloadPlugin(),
|
|
@@ -40,6 +44,9 @@ export const createViteConfig = ({ skuContext, configType = 'client', plugins =
|
|
|
40
44
|
ssr: configType === 'ssr' || configType === 'ssg',
|
|
41
45
|
manifest: configType === 'client',
|
|
42
46
|
ssrManifest: false,
|
|
47
|
+
// TODO Fix URL paths as a publicPath value. Absolute and relative paths work, but Vite removes the first `/` in URLs (http://foo.com -> http:/foo.com).
|
|
48
|
+
// TODO URL paths also output to url folders. e.g., /http:/foo.com/assets/[filename].js.
|
|
49
|
+
assetsDir: skuContext.publicPath.replace(/(^\/|\/$)/g, ''),
|
|
43
50
|
rollupOptions: {
|
|
44
51
|
input: input[configType],
|
|
45
52
|
output: {
|
|
@@ -12,6 +12,7 @@ export const prerenderRoutes = async (skuContext) => {
|
|
|
12
12
|
const render = (await import(resolve('./dist/render/render.js'))).default;
|
|
13
13
|
const loadableCollector = createCollector({
|
|
14
14
|
manifest,
|
|
15
|
+
base: skuContext.publicPath.startsWith('/') ? '/' : '',
|
|
15
16
|
});
|
|
16
17
|
const html = await createPreRenderedHtml({
|
|
17
18
|
url: route.route,
|
|
@@ -7,10 +7,11 @@ export declare class Collector {
|
|
|
7
7
|
nonce?: string | undefined;
|
|
8
8
|
externalJsFiles?: string[] | undefined;
|
|
9
9
|
entry?: string | undefined;
|
|
10
|
+
base?: string | undefined;
|
|
10
11
|
moduleIds: Set<string>;
|
|
11
12
|
preloadIds: Map<string, Preload>;
|
|
12
13
|
scriptIds: Map<string, InjectableScript>;
|
|
13
|
-
constructor(manifest: Manifest, nonce?: string | undefined, externalJsFiles?: string[] | undefined, entry?: string | undefined);
|
|
14
|
+
constructor(manifest: Manifest, nonce?: string | undefined, externalJsFiles?: string[] | undefined, entry?: string | undefined, base?: string | undefined);
|
|
14
15
|
register(moduleId: ModuleId): void;
|
|
15
16
|
getAllModules(): string[];
|
|
16
17
|
getAllPreloads(): string;
|
|
@@ -22,6 +23,7 @@ type CreateCollectorOptions = {
|
|
|
22
23
|
manifest?: Manifest;
|
|
23
24
|
nonce?: string;
|
|
24
25
|
entry?: string;
|
|
26
|
+
base?: string;
|
|
25
27
|
};
|
|
26
|
-
export declare const createCollector: ({ externalJsFiles, manifest, nonce, entry, }: CreateCollectorOptions) => Collector;
|
|
28
|
+
export declare const createCollector: ({ externalJsFiles, manifest, nonce, entry, base, }: CreateCollectorOptions) => Collector;
|
|
27
29
|
export {};
|
|
@@ -7,14 +7,16 @@ export class Collector {
|
|
|
7
7
|
nonce;
|
|
8
8
|
externalJsFiles;
|
|
9
9
|
entry;
|
|
10
|
+
base;
|
|
10
11
|
moduleIds = new Set();
|
|
11
12
|
preloadIds = new Map();
|
|
12
13
|
scriptIds = new Map();
|
|
13
|
-
constructor(manifest, nonce, externalJsFiles, entry) {
|
|
14
|
+
constructor(manifest, nonce, externalJsFiles, entry, base) {
|
|
14
15
|
this.manifest = manifest;
|
|
15
16
|
this.nonce = nonce;
|
|
16
17
|
this.externalJsFiles = externalJsFiles;
|
|
17
18
|
this.entry = entry;
|
|
19
|
+
this.base = base;
|
|
18
20
|
this.manifest = manifest;
|
|
19
21
|
this.nonce = nonce;
|
|
20
22
|
if (externalJsFiles) {
|
|
@@ -32,6 +34,7 @@ export class Collector {
|
|
|
32
34
|
preloads: this.preloadIds,
|
|
33
35
|
scripts: this.scriptIds,
|
|
34
36
|
nonce,
|
|
37
|
+
base,
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
register(moduleId) {
|
|
@@ -42,6 +45,7 @@ export class Collector {
|
|
|
42
45
|
preloads: this.preloadIds,
|
|
43
46
|
scripts: this.scriptIds,
|
|
44
47
|
nonce: this.nonce,
|
|
48
|
+
base: this.base,
|
|
45
49
|
});
|
|
46
50
|
}
|
|
47
51
|
getAllModules() {
|
|
@@ -69,11 +73,11 @@ export class Collector {
|
|
|
69
73
|
return linkTags;
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
const parseManifestForEntry = ({ manifest, entry, nonce, preloads, scripts, }) => {
|
|
76
|
+
const parseManifestForEntry = ({ manifest, entry, nonce, preloads, scripts, base, }) => {
|
|
73
77
|
if (!manifest) {
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
76
|
-
const entryChunk = manifest[entry];
|
|
80
|
+
const entryChunk = manifest[entry] && parseEntryChunk(manifest[entry], { base });
|
|
77
81
|
if (!entryChunk) {
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
@@ -102,11 +106,19 @@ const parseManifestForEntry = ({ manifest, entry, nonce, preloads, scripts, }) =
|
|
|
102
106
|
nonce,
|
|
103
107
|
preloads,
|
|
104
108
|
scripts,
|
|
109
|
+
base,
|
|
105
110
|
});
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
};
|
|
115
|
+
const parseEntryChunk = (entryChunk, { base = '/' }) => ({
|
|
116
|
+
...entryChunk,
|
|
117
|
+
// Overriding the path urls to include the base path.
|
|
118
|
+
css: entryChunk.css?.map((path) => `${base}${path}`),
|
|
119
|
+
assets: entryChunk.assets?.map((path) => `${base}${path}`),
|
|
120
|
+
file: `${base}${entryChunk.file}`,
|
|
121
|
+
});
|
|
110
122
|
const addFileToPreloads = ({ preloads, entryChunk, entry, nonce, }) => {
|
|
111
123
|
preloads.set(entry, {
|
|
112
124
|
rel: 'modulepreload',
|
|
@@ -152,7 +164,7 @@ const addAssetToPreloads = ({ preloads, chunk, nonce, }) => {
|
|
|
152
164
|
type: mimeType,
|
|
153
165
|
});
|
|
154
166
|
};
|
|
155
|
-
export const createCollector = ({ externalJsFiles, manifest, nonce, entry, }) => {
|
|
167
|
+
export const createCollector = ({ externalJsFiles, manifest, nonce, entry, base, }) => {
|
|
156
168
|
let entryPoint = entry || 'index.html';
|
|
157
169
|
const internalManifest = manifest || {};
|
|
158
170
|
if (!internalManifest[entryPoint]) {
|
|
@@ -161,5 +173,5 @@ export const createCollector = ({ externalJsFiles, manifest, nonce, entry, }) =>
|
|
|
161
173
|
entryPoint = entryChunk[0];
|
|
162
174
|
}
|
|
163
175
|
}
|
|
164
|
-
return new Collector(internalManifest, nonce, externalJsFiles, entryPoint);
|
|
176
|
+
return new Collector(internalManifest, nonce, externalJsFiles, entryPoint, base);
|
|
165
177
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const getNonce = (nonce) => (nonce ? ` nonce="${nonce}"` : '');
|
|
2
2
|
const tagTypes = {
|
|
3
|
-
stylesheet: ({ href, nonce }) => `<link rel="stylesheet" href="
|
|
4
|
-
modulepreload: ({ href, nonce }) => `<link rel="modulepreload" href="
|
|
5
|
-
module: ({ href, asyncScript, nonce }) => `<script type="module"${asyncScript ? ' async' : ''} src="
|
|
3
|
+
stylesheet: ({ href, nonce }) => `<link rel="stylesheet" href="${href}" crossorigin${getNonce(nonce)} />`,
|
|
4
|
+
modulepreload: ({ href, nonce }) => `<link rel="modulepreload" href="${href}" crossorigin${getNonce(nonce)} />`,
|
|
5
|
+
module: ({ href, asyncScript, nonce }) => `<script type="module"${asyncScript ? ' async' : ''} src="${href}" crossorigin${getNonce(nonce)}></script>`,
|
|
6
6
|
preload: ({ as, href, type }) => {
|
|
7
7
|
const crossorigin = as === 'font' || as === 'fetch';
|
|
8
|
-
return `<link rel="preload" href="
|
|
8
|
+
return `<link rel="preload" href="${href}" as="${as}" type="${type}"${crossorigin ? ' crossorigin' : ''} />`;
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
// Make this my style still
|
|
@@ -3,5 +3,5 @@ export type InjectableScript = {
|
|
|
3
3
|
isEntry: boolean;
|
|
4
4
|
nonce?: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const createScriptTag: (
|
|
6
|
+
export declare const createScriptTag: ({ nonce, src }: InjectableScript) => string;
|
|
7
7
|
export declare const sortInjectableScript: (a: InjectableScript) => 1 | -1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const createScriptTag = (
|
|
1
|
+
export const createScriptTag = ({ nonce, src }) => `<script type="module" src="${src}" ${nonce ? `nonce="${nonce}"` : ''}></script>`;
|
|
2
2
|
export const sortInjectableScript = (a) => a.isEntry ? 1 : -1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sku",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.1",
|
|
4
4
|
"description": "Front-end development toolkit, powered by Webpack, Babel, Vanilla Extract and Jest",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -168,6 +168,7 @@
|
|
|
168
168
|
"terser-webpack-plugin": "^5.1.4",
|
|
169
169
|
"typescript": "~5.6.0",
|
|
170
170
|
"vite": "^6.1.0",
|
|
171
|
+
"vite-plugin-cjs-interop": "^2.1.6",
|
|
171
172
|
"webpack": "^5.52.0",
|
|
172
173
|
"webpack-bundle-analyzer": "^4.6.1",
|
|
173
174
|
"webpack-dev-server": "^5.0.2",
|