@hitachivantara/app-shell-vite-plugin 1.6.9 → 1.7.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/README.md +11 -13
- package/dist/automatic-utils.d.ts +0 -1
- package/dist/automatic-utils.js +16 -17
- package/dist/config-utils.d.ts +0 -1
- package/dist/config-utils.js +8 -9
- package/dist/esm-externals/emotion-cache.production.min.js +2 -2
- package/dist/esm-externals/emotion-cache.production.min.js.map +1 -1
- package/dist/esm-externals/emotion-react.production.min.js +2 -2
- package/dist/esm-externals/emotion-react.production.min.js.map +1 -1
- package/dist/esm-externals/react-dom.production.min.js +2 -2
- package/dist/esm-externals/react-dom.production.min.js.map +1 -1
- package/dist/esm-externals/react-router-dom.production.min.js +9 -9
- package/dist/esm-externals/react-router-dom.production.min.js.map +1 -1
- package/dist/esm-externals/react.production.min.js +2 -2
- package/dist/esm-externals/react.production.min.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +0 -2
- package/dist/nodeModule.d.ts +2 -4
- package/dist/nodeModule.js +11 -8
- package/dist/shared-dependencies.d.ts +0 -1
- package/dist/shared-dependencies.js +8 -9
- package/dist/tests/automatic-utils.test.d.ts +0 -1
- package/dist/tests/automatic-utils.test.js +102 -99
- package/dist/tests/config-utils.test.d.ts +0 -1
- package/dist/tests/config-utils.test.js +10 -10
- package/dist/tests/mocks/path.mock.d.ts +0 -1
- package/dist/tests/mocks/path.mock.js +1 -2
- package/dist/tests/vite-configuration-processor-plugin.test.d.ts +0 -1
- package/dist/tests/vite-configuration-processor-plugin.test.js +22 -23
- package/dist/tests/vite-crossorigin-fix-plugin.test.d.ts +0 -1
- package/dist/tests/vite-crossorigin-fix-plugin.test.js +2 -3
- package/dist/tests/vite-generate-base-plugin.test.d.ts +0 -1
- package/dist/tests/vite-generate-base-plugin.test.js +1 -2
- package/dist/tests/vite-metadata-plugin.test.d.ts +0 -1
- package/dist/tests/vite-metadata-plugin.test.js +9 -9
- package/dist/virtual-entrypoints.d.ts +0 -1
- package/dist/virtual-entrypoints.js +1 -2
- package/dist/vite-configuration-processor-plugin.d.ts +0 -1
- package/dist/vite-configuration-processor-plugin.js +18 -19
- package/dist/vite-crossorigin-fix-plugin.d.ts +1 -2
- package/dist/vite-crossorigin-fix-plugin.js +7 -8
- package/dist/vite-generate-base-plugin.d.ts +1 -2
- package/dist/vite-generate-base-plugin.js +8 -9
- package/dist/vite-generate-bash-script-plugin.d.ts +0 -1
- package/dist/vite-generate-bash-script-plugin.js +4 -5
- package/dist/vite-importmap-plugin.d.ts +0 -1
- package/dist/vite-importmap-plugin.js +21 -22
- package/dist/vite-metadata-plugin.d.ts +0 -1
- package/dist/vite-metadata-plugin.js +7 -8
- package/dist/vite-plugin.d.ts +1 -3
- package/dist/vite-plugin.js +25 -27
- package/dist/vite-watch-config-plugin.d.ts +0 -1
- package/dist/vite-watch-config-plugin.js +7 -8
- package/package.json +36 -44
- package/LICENSE +0 -201
- package/dist/automatic-utils.d.ts.map +0 -1
- package/dist/automatic-utils.js.map +0 -1
- package/dist/config-utils.d.ts.map +0 -1
- package/dist/config-utils.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/nodeModule.d.ts.map +0 -1
- package/dist/nodeModule.js.map +0 -1
- package/dist/shared-dependencies.d.ts.map +0 -1
- package/dist/shared-dependencies.js.map +0 -1
- package/dist/tests/automatic-utils.test.d.ts.map +0 -1
- package/dist/tests/automatic-utils.test.js.map +0 -1
- package/dist/tests/config-utils.test.d.ts.map +0 -1
- package/dist/tests/config-utils.test.js.map +0 -1
- package/dist/tests/mocks/path.mock.d.ts.map +0 -1
- package/dist/tests/mocks/path.mock.js.map +0 -1
- package/dist/tests/setup.d.ts +0 -2
- package/dist/tests/setup.d.ts.map +0 -1
- package/dist/tests/setup.js +0 -2
- package/dist/tests/setup.js.map +0 -1
- package/dist/tests/vite-configuration-processor-plugin.test.d.ts.map +0 -1
- package/dist/tests/vite-configuration-processor-plugin.test.js.map +0 -1
- package/dist/tests/vite-crossorigin-fix-plugin.test.d.ts.map +0 -1
- package/dist/tests/vite-crossorigin-fix-plugin.test.js.map +0 -1
- package/dist/tests/vite-generate-base-plugin.test.d.ts.map +0 -1
- package/dist/tests/vite-generate-base-plugin.test.js.map +0 -1
- package/dist/tests/vite-metadata-plugin.test.d.ts.map +0 -1
- package/dist/tests/vite-metadata-plugin.test.js.map +0 -1
- package/dist/virtual-entrypoints.d.ts.map +0 -1
- package/dist/virtual-entrypoints.js.map +0 -1
- package/dist/vite-configuration-processor-plugin.d.ts.map +0 -1
- package/dist/vite-configuration-processor-plugin.js.map +0 -1
- package/dist/vite-crossorigin-fix-plugin.d.ts.map +0 -1
- package/dist/vite-crossorigin-fix-plugin.js.map +0 -1
- package/dist/vite-generate-base-plugin.d.ts.map +0 -1
- package/dist/vite-generate-base-plugin.js.map +0 -1
- package/dist/vite-generate-bash-script-plugin.d.ts.map +0 -1
- package/dist/vite-generate-bash-script-plugin.js.map +0 -1
- package/dist/vite-importmap-plugin.d.ts.map +0 -1
- package/dist/vite-importmap-plugin.js.map +0 -1
- package/dist/vite-metadata-plugin.d.ts.map +0 -1
- package/dist/vite-metadata-plugin.js.map +0 -1
- package/dist/vite-plugin.d.ts.map +0 -1
- package/dist/vite-plugin.js.map +0 -1
- package/dist/vite-watch-config-plugin.d.ts.map +0 -1
- package/dist/vite-watch-config-plugin.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { checkCrossOrigin,
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { addUseCredentials, checkCrossOrigin, } from "../vite-crossorigin-fix-plugin";
|
|
3
3
|
describe("vite-crossorigin-fix", () => {
|
|
4
4
|
describe("checkCrossOrigin", () => {
|
|
5
5
|
it('should return an empty array if no scripts have crossorigin="use-credentials"', () => {
|
|
@@ -101,4 +101,3 @@ describe("vite-crossorigin-fix", () => {
|
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
|
-
//# sourceMappingURL=vite-crossorigin-fix-plugin.test.js.map
|
|
@@ -3,10 +3,9 @@ describe("test vite-generate-base plugin", () => {
|
|
|
3
3
|
describe("test `getAppTitle` method", () => {
|
|
4
4
|
test.each([
|
|
5
5
|
[false, { name: "dummyName" }, "dummyName"],
|
|
6
|
-
[true, {}, "%%APPSHELL_TITLE%%"]
|
|
6
|
+
[true, {}, "%%APPSHELL_TITLE%%"],
|
|
7
7
|
])("At mode %b, %j, app title matches %s", (value, config, expected) => {
|
|
8
8
|
expect(getAppTitle(value, config)).toBe(expected);
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
|
-
//# sourceMappingURL=vite-generate-base-plugin.test.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import fs from "fs";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { vi } from "vitest";
|
|
2
3
|
import injectMetadata from "../vite-metadata-plugin";
|
|
3
4
|
describe("test vite-metadata plugin", () => {
|
|
4
|
-
it("it returns the injectMetadata information", () => {
|
|
5
|
+
it.skip("it returns the injectMetadata information", () => {
|
|
5
6
|
const fsTmp = fs.existsSync;
|
|
6
7
|
fs.existsSync = vi.fn().mockImplementation((file) => {
|
|
7
8
|
return file.match("/dummyPath/dummyRootProject/app-shell.config.json");
|
|
@@ -21,22 +22,22 @@ describe("test vite-metadata plugin", () => {
|
|
|
21
22
|
});
|
|
22
23
|
const metadata = injectMetadata();
|
|
23
24
|
const { transformIndexHtml } = metadata;
|
|
24
|
-
// @ts-expect-error This is a function
|
|
25
|
+
// @ts-expect-error This is a function and is callable
|
|
25
26
|
expect(transformIndexHtml()).toMatchObject([
|
|
26
27
|
{
|
|
27
28
|
attrs: {
|
|
28
29
|
content: "appShellUIDummyVersion",
|
|
29
|
-
name: "app-shell-ui-version"
|
|
30
|
+
name: "app-shell-ui-version",
|
|
30
31
|
},
|
|
31
|
-
tag: "meta"
|
|
32
|
+
tag: "meta",
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
attrs: {
|
|
35
36
|
content: "appShellVitePluginDummyVersion",
|
|
36
|
-
name: "app-shell-vite-plugin-version"
|
|
37
|
+
name: "app-shell-vite-plugin-version",
|
|
37
38
|
},
|
|
38
|
-
tag: "meta"
|
|
39
|
-
}
|
|
39
|
+
tag: "meta",
|
|
40
|
+
},
|
|
40
41
|
]);
|
|
41
42
|
// Restore the original fs.existsSync
|
|
42
43
|
fs.existsSync = fsTmp;
|
|
@@ -44,4 +45,3 @@ describe("test vite-metadata plugin", () => {
|
|
|
44
45
|
fs.readFileSync = readFileSyncTmp;
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
|
-
//# sourceMappingURL=vite-metadata-plugin.test.js.map
|
|
@@ -17,4 +17,3 @@ export declare function replaceReferencesToSelf<T extends BundleDefinition>(bund
|
|
|
17
17
|
*/
|
|
18
18
|
export default function processConfiguration(root: string, appShellConfig: HvAppShellConfig, selfAppName: string, buildEntryPoint: boolean, inlineConfig: boolean, generateEmptyShell: boolean, modules?: string[]): PluginOption;
|
|
19
19
|
export {};
|
|
20
|
-
//# sourceMappingURL=vite-configuration-processor-plugin.d.ts.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { getAppModules, getBasePath, replaceSelf, startsWithSelf } from "./config-utils.js";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getAppModules, getBasePath, replaceSelf, startsWithSelf, } from "./config-utils.js";
|
|
4
4
|
var ViteCommand;
|
|
5
5
|
(function (ViteCommand) {
|
|
6
6
|
ViteCommand["BUILD"] = "build";
|
|
7
7
|
ViteCommand["SERVE"] = "serve";
|
|
8
8
|
})(ViteCommand || (ViteCommand = {}));
|
|
9
9
|
export function replaceReferencesToSelf(bundles, selfAppName) {
|
|
10
|
-
return bundles.map(bundleDefinition => {
|
|
10
|
+
return bundles.map((bundleDefinition) => {
|
|
11
11
|
if ("views" in bundleDefinition && bundleDefinition.views != null) {
|
|
12
12
|
return {
|
|
13
13
|
...bundleDefinition,
|
|
14
14
|
bundle: replaceSelf(bundleDefinition.bundle, `${selfAppName}/`),
|
|
15
|
-
views: replaceReferencesToSelf(bundleDefinition.views, selfAppName)
|
|
15
|
+
views: replaceReferencesToSelf(bundleDefinition.views, selfAppName),
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
if (startsWithSelf(bundleDefinition.bundle)) {
|
|
19
19
|
return {
|
|
20
20
|
...bundleDefinition,
|
|
21
|
-
bundle: replaceSelf(bundleDefinition.bundle, `${selfAppName}/`)
|
|
21
|
+
bundle: replaceSelf(bundleDefinition.bundle, `${selfAppName}/`),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
return bundleDefinition;
|
|
@@ -62,15 +62,15 @@ export default function processConfiguration(root, appShellConfig, selfAppName,
|
|
|
62
62
|
fs.existsSync(path.resolve(projectRoot, "index.html"))
|
|
63
63
|
? { main: path.resolve(projectRoot, "index.html") }
|
|
64
64
|
: {}),
|
|
65
|
-
...appModules
|
|
65
|
+
...appModules,
|
|
66
66
|
},
|
|
67
67
|
output: {
|
|
68
|
-
entryFileNames: "[name].js"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
68
|
+
entryFileNames: "[name].js",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
71
|
},
|
|
72
72
|
// if serve (preview/dev) it uses the basePath. Otherwise(build), use ./
|
|
73
|
-
base: command === ViteCommand.SERVE ? basePath : "./"
|
|
73
|
+
base: command === ViteCommand.SERVE ? basePath : "./",
|
|
74
74
|
};
|
|
75
75
|
},
|
|
76
76
|
/**
|
|
@@ -101,7 +101,7 @@ export default function processConfiguration(root, appShellConfig, selfAppName,
|
|
|
101
101
|
// theming structure does not rely on having the 'bundle' prop
|
|
102
102
|
const { theming } = appShellConfig;
|
|
103
103
|
if (theming != null) {
|
|
104
|
-
theming.themes = theming.themes?.map(theme => {
|
|
104
|
+
theming.themes = theming.themes?.map((theme) => {
|
|
105
105
|
if (startsWithSelf(theme)) {
|
|
106
106
|
const bundleName = replaceSelf(theme);
|
|
107
107
|
return `${selfAppName}/${bundleName}`;
|
|
@@ -130,7 +130,7 @@ export default function processConfiguration(root, appShellConfig, selfAppName,
|
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
transformIndexHtml: {
|
|
133
|
-
handler: html => {
|
|
133
|
+
handler: (html) => {
|
|
134
134
|
if (!inlineConfig) {
|
|
135
135
|
return undefined;
|
|
136
136
|
}
|
|
@@ -142,12 +142,11 @@ export default function processConfiguration(root, appShellConfig, selfAppName,
|
|
|
142
142
|
injectTo: "head-prepend",
|
|
143
143
|
children: `globalThis.__appshell_config__ = ${generateEmptyShell
|
|
144
144
|
? "%%APPSHELL_CONFIG%%"
|
|
145
|
-
: JSON.stringify(finalAppShellConfig ?? appShellConfig)}
|
|
146
|
-
}
|
|
147
|
-
]
|
|
145
|
+
: JSON.stringify(finalAppShellConfig ?? appShellConfig)};`,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
148
|
};
|
|
149
|
-
}
|
|
150
|
-
}
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
//# sourceMappingURL=vite-configuration-processor-plugin.js.map
|
|
@@ -4,7 +4,6 @@ export declare const externalRE: RegExp;
|
|
|
4
4
|
export declare const isExternalUrl: (url: string) => boolean;
|
|
5
5
|
export declare const dataUrlRE: RegExp;
|
|
6
6
|
export declare const isDataUrl: (url: string) => boolean;
|
|
7
|
-
export declare function checkCrossOrigin(html: string):
|
|
7
|
+
export declare function checkCrossOrigin(html: string): any[];
|
|
8
8
|
declare const fixCrossOrigin: () => PluginOption;
|
|
9
9
|
export default fixCrossOrigin;
|
|
10
|
-
//# sourceMappingURL=vite-crossorigin-fix-plugin.d.ts.map
|
|
@@ -17,7 +17,7 @@ function processScript(bundle, scriptSrc, html, seen = new Set()) {
|
|
|
17
17
|
return html;
|
|
18
18
|
}
|
|
19
19
|
let newHtml = addUseCredentials(script.fileName, html);
|
|
20
|
-
script.imports.forEach(importedScript => {
|
|
20
|
+
script.imports.forEach((importedScript) => {
|
|
21
21
|
if (!seen.has(importedScript)) {
|
|
22
22
|
newHtml = processScript(bundle, importedScript, newHtml, seen);
|
|
23
23
|
}
|
|
@@ -35,7 +35,7 @@ export function checkCrossOrigin(html) {
|
|
|
35
35
|
// search for script tags with crossorigin attribute set to use-credentials
|
|
36
36
|
const scriptTagsWithCors = html.match(/<script(?:\s+\w+(?:=(?:"[^"]*"|'[^']*'))?)*\s+crossorigin=(?:"use-credentials"|'use-credentials')(?:\s+\w+(?:=(?:"[^"]*"|'[^']*'))?)*\s*>/gi);
|
|
37
37
|
// ignore the script tags that are not modules
|
|
38
|
-
const modulesWithCors = scriptTagsWithCors?.filter(script => /type\s*=\s*(?:"module"|'module')/i.test(script));
|
|
38
|
+
const modulesWithCors = scriptTagsWithCors?.filter((script) => /type\s*=\s*(?:"module"|'module')/i.test(script));
|
|
39
39
|
const withCredentials = [];
|
|
40
40
|
if (modulesWithCors != null && modulesWithCors.length !== 0) {
|
|
41
41
|
for (let i = 0; i !== modulesWithCors.length; i += 1) {
|
|
@@ -57,8 +57,8 @@ const fixCrossOrigin = () => {
|
|
|
57
57
|
order: "pre",
|
|
58
58
|
handler(html, info) {
|
|
59
59
|
withCredentials[info.filename] = checkCrossOrigin(html);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
name: "vite-crossorigin-fix-replace-plugin",
|
|
@@ -75,10 +75,9 @@ const fixCrossOrigin = () => {
|
|
|
75
75
|
return processScript(context.bundle, context.chunk.fileName, html);
|
|
76
76
|
}
|
|
77
77
|
return html;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
81
|
];
|
|
82
82
|
};
|
|
83
83
|
export default fixCrossOrigin;
|
|
84
|
-
//# sourceMappingURL=vite-crossorigin-fix-plugin.js.map
|
|
@@ -8,11 +8,10 @@ import type { HvAppShellConfig } from "@hitachivantara/app-shell-shared";
|
|
|
8
8
|
* @param appShellConfig App shell config values
|
|
9
9
|
* @returns The app title
|
|
10
10
|
*/
|
|
11
|
-
export declare const getAppTitle: (generateEmptyShell: boolean, appShellConfig: HvAppShellConfig) =>
|
|
11
|
+
export declare const getAppTitle: (generateEmptyShell: boolean, appShellConfig: HvAppShellConfig) => any;
|
|
12
12
|
/**
|
|
13
13
|
* Add the <BASE> tag and icons preload in the index.html file.
|
|
14
14
|
* @param appShellConfig The app shell configuration.
|
|
15
15
|
* @param generateEmptyShell Flag that controls if an empty app shell application is created with tags instead of final values
|
|
16
16
|
*/
|
|
17
17
|
export default function generateBaseTag(appShellConfig: HvAppShellConfig, generateEmptyShell: boolean): PluginOption;
|
|
18
|
-
//# sourceMappingURL=vite-generate-base-plugin.d.ts.map
|
|
@@ -32,9 +32,9 @@ export default function generateBaseTag(appShellConfig, generateEmptyShell) {
|
|
|
32
32
|
{
|
|
33
33
|
tag: "base",
|
|
34
34
|
attrs: {
|
|
35
|
-
href: generateEmptyShell ? "%%APPSHELL_BASE%%" : basePath
|
|
35
|
+
href: generateEmptyShell ? "%%APPSHELL_BASE%%" : basePath,
|
|
36
36
|
},
|
|
37
|
-
injectTo: "head-prepend"
|
|
37
|
+
injectTo: "head-prepend",
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
tag: "link",
|
|
@@ -42,12 +42,11 @@ export default function generateBaseTag(appShellConfig, generateEmptyShell) {
|
|
|
42
42
|
attrs: {
|
|
43
43
|
rel: "preload",
|
|
44
44
|
as: "image",
|
|
45
|
-
href: "./icons/icons.svg"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
})
|
|
50
|
-
}
|
|
45
|
+
href: "./icons/icons.svg",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
//# sourceMappingURL=vite-generate-base-plugin.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import SHARED_DEPENDENCIES from "./shared-dependencies.js";
|
|
4
4
|
import { getExtraDependenciesString } from "./vite-importmap-plugin.js";
|
|
5
5
|
export default function generateBashScript(externalImportMap, inlineConfig) {
|
|
@@ -115,9 +115,8 @@ rm -f app-shell.config.json`
|
|
|
115
115
|
fi`}
|
|
116
116
|
`;
|
|
117
117
|
fs.writeFileSync(path.join(targetDir, "app-shell.sh"), script, {
|
|
118
|
-
encoding: "utf-8"
|
|
118
|
+
encoding: "utf-8",
|
|
119
119
|
});
|
|
120
|
-
}
|
|
120
|
+
},
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
//# sourceMappingURL=vite-generate-bash-script-plugin.js.map
|
|
@@ -14,4 +14,3 @@ export declare const getExtraDependenciesString: () => string;
|
|
|
14
14
|
* @param placeholderEntryPoint Flag to control if the importmap should be a placeholder
|
|
15
15
|
*/
|
|
16
16
|
export default function generateImportmap(importmapElements: Record<string, string>, packageName: string, sharedDependencies: string[], externalImportMap?: boolean, placeholderEntryPoint?: boolean): PluginOption;
|
|
17
|
-
//# sourceMappingURL=vite-importmap-plugin.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import virtual from "@rollup/plugin-virtual";
|
|
4
4
|
const ID_PREFIX = `/@id/`;
|
|
5
5
|
export const extraDependencies = {
|
|
6
|
-
"@hv/uikit-icons/": "./icons/"
|
|
6
|
+
"@hv/uikit-icons/": "./icons/",
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Auxiliary function to get the extraDependencies string
|
|
@@ -25,12 +25,12 @@ function replaceIdPrefix(keys, packageName) {
|
|
|
25
25
|
enforce: "pre",
|
|
26
26
|
apply: "serve",
|
|
27
27
|
// while in dev, we need to prevent 'vite:import-analysis' on runtime modules
|
|
28
|
-
transform: code => reg.test(code) ? code.replace(reg, (m, s1, s2) => s2) : code,
|
|
28
|
+
transform: (code) => reg.test(code) ? code.replace(reg, (m, s1, s2) => s2) : code,
|
|
29
29
|
// and to say its resolved (as external)
|
|
30
|
-
resolveId: (id) => keys.some(key => typeof key === "string" ? id.startsWith(key) : key.test(id))
|
|
30
|
+
resolveId: (id) => keys.some((key) => typeof key === "string" ? id.startsWith(key) : key.test(id))
|
|
31
31
|
? {
|
|
32
32
|
id,
|
|
33
|
-
external: true
|
|
33
|
+
external: true,
|
|
34
34
|
}
|
|
35
35
|
: undefined,
|
|
36
36
|
// Avoid the warning: The following dependencies are imported but could not be resolved: [dependency] (imported by [sourceFile])
|
|
@@ -41,7 +41,7 @@ function replaceIdPrefix(keys, packageName) {
|
|
|
41
41
|
return "export default {};";
|
|
42
42
|
}
|
|
43
43
|
return undefined;
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -54,7 +54,7 @@ function replaceIdPrefix(keys, packageName) {
|
|
|
54
54
|
*/
|
|
55
55
|
export default function generateImportmap(importmapElements, packageName, sharedDependencies, externalImportMap = false, placeholderEntryPoint = false) {
|
|
56
56
|
const keys = Object.keys(importmapElements);
|
|
57
|
-
const devKeys = keys.filter(key => !sharedDependencies.some(lib => lib.startsWith(key)));
|
|
57
|
+
const devKeys = keys.filter((key) => !sharedDependencies.some((lib) => lib.startsWith(key)));
|
|
58
58
|
let devMode = false;
|
|
59
59
|
const importmapString = JSON.stringify({ imports: importmapElements }, null, 2);
|
|
60
60
|
const importmapScript = `const im = document.createElement('script');
|
|
@@ -77,13 +77,13 @@ document.currentScript.after(im);
|
|
|
77
77
|
returnValue.optimizeDeps = returnValue.optimizeDeps ?? {};
|
|
78
78
|
returnValue.optimizeDeps.exclude = [
|
|
79
79
|
...(config.optimizeDeps?.exclude ?? []),
|
|
80
|
-
...(devMode ? devKeys : keys)
|
|
80
|
+
...(devMode ? devKeys : keys),
|
|
81
81
|
];
|
|
82
82
|
if (devMode) {
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
// mark the modules referenced in the importmap as external
|
|
86
|
-
const excludedModules = keys.map(key => {
|
|
86
|
+
const excludedModules = keys.map((key) => {
|
|
87
87
|
if (key.endsWith("/")) {
|
|
88
88
|
return new RegExp(`^${key}.*`);
|
|
89
89
|
}
|
|
@@ -100,7 +100,7 @@ document.currentScript.after(im);
|
|
|
100
100
|
// we wrap it and check our excluded modules first and call the original function if needed
|
|
101
101
|
const originalExternal = returnValue.build.rollupOptions.external;
|
|
102
102
|
returnValue.build.rollupOptions.external = (id, ...args) => {
|
|
103
|
-
if (excludedModules.some(m => m === id)) {
|
|
103
|
+
if (excludedModules.some((m) => m === id)) {
|
|
104
104
|
return true;
|
|
105
105
|
}
|
|
106
106
|
return originalExternal(id, ...args);
|
|
@@ -162,19 +162,19 @@ document.currentScript.after(im);
|
|
|
162
162
|
// inject the importmap script and also the es-module-shims script
|
|
163
163
|
transformIndexHtml: {
|
|
164
164
|
order: "post",
|
|
165
|
-
handler: html => ({
|
|
165
|
+
handler: (html) => ({
|
|
166
166
|
html,
|
|
167
167
|
tags: [
|
|
168
168
|
{
|
|
169
169
|
tag: "script",
|
|
170
170
|
attrs: { async: true, src: "./bundles/es-module-shims.js" },
|
|
171
|
-
injectTo: "head-prepend"
|
|
171
|
+
injectTo: "head-prepend",
|
|
172
172
|
},
|
|
173
173
|
externalImportMap
|
|
174
174
|
? {
|
|
175
175
|
tag: "script",
|
|
176
176
|
attrs: { src: "./importmap.js" },
|
|
177
|
-
injectTo: "head-prepend"
|
|
177
|
+
injectTo: "head-prepend",
|
|
178
178
|
}
|
|
179
179
|
: {
|
|
180
180
|
tag: "script",
|
|
@@ -182,17 +182,16 @@ document.currentScript.after(im);
|
|
|
182
182
|
injectTo: "head-prepend",
|
|
183
183
|
children: placeholderEntryPoint
|
|
184
184
|
? "%%APPSHELL_IMPORTMAP%%"
|
|
185
|
-
: importmapString
|
|
186
|
-
}
|
|
187
|
-
]
|
|
188
|
-
})
|
|
189
|
-
}
|
|
185
|
+
: importmapString,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
}),
|
|
189
|
+
},
|
|
190
190
|
},
|
|
191
191
|
externalImportMap
|
|
192
192
|
? virtual({
|
|
193
|
-
"/importmap.js": importmapScript
|
|
193
|
+
"/importmap.js": importmapScript,
|
|
194
194
|
})
|
|
195
|
-
: false
|
|
195
|
+
: false,
|
|
196
196
|
];
|
|
197
197
|
}
|
|
198
|
-
//# sourceMappingURL=vite-importmap-plugin.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from "fs";
|
|
1
|
+
import fs from "node:fs";
|
|
2
2
|
import { resolveModule } from "./nodeModule.js";
|
|
3
3
|
const extractVersion = (packageJsonFile) => {
|
|
4
4
|
const packageJson = fs.readFileSync(packageJsonFile, "utf8");
|
|
@@ -21,19 +21,18 @@ const injectMetadata = () => {
|
|
|
21
21
|
tag: "meta",
|
|
22
22
|
attrs: {
|
|
23
23
|
name: "app-shell-ui-version",
|
|
24
|
-
content: appShellUIVersion
|
|
25
|
-
}
|
|
24
|
+
content: appShellUIVersion,
|
|
25
|
+
},
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
tag: "meta",
|
|
29
29
|
attrs: {
|
|
30
30
|
name: "app-shell-vite-plugin-version",
|
|
31
|
-
content: appShellVitePluginVersion
|
|
32
|
-
}
|
|
33
|
-
}
|
|
31
|
+
content: appShellVitePluginVersion,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
34
|
];
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
export default injectMetadata;
|
|
39
|
-
//# sourceMappingURL=vite-metadata-plugin.js.map
|
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -96,6 +96,4 @@ export interface AppShellVitePluginOptions {
|
|
|
96
96
|
* @param opts Plugin options
|
|
97
97
|
* @param env Environment variable
|
|
98
98
|
*/
|
|
99
|
-
declare function
|
|
100
|
-
export default appShellVitePlugin;
|
|
101
|
-
//# sourceMappingURL=vite-plugin.d.ts.map
|
|
99
|
+
export declare function HvAppShellVitePlugin(opts?: AppShellVitePluginOptions, env?: Record<string, string>): PluginOption;
|
package/dist/vite-plugin.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import virtual from "@rollup/plugin-virtual";
|
|
4
|
-
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
5
4
|
import { loadEnv } from "vite";
|
|
6
|
-
import
|
|
5
|
+
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
6
|
+
import { applyAutomaticMenu, applyAutomaticViewsAndRoutes, } from "./automatic-utils.js";
|
|
7
|
+
import { findAppShellConfigFile, getFinalModuleName, loadConfigFile, } from "./config-utils.js";
|
|
8
|
+
import { getModulePath, resolveModule } from "./nodeModule.js";
|
|
9
|
+
import SHARED_DEPENDENCIES from "./shared-dependencies.js";
|
|
10
|
+
import getVirtualEntrypoints from "./virtual-entrypoints.js";
|
|
7
11
|
import processConfiguration from "./vite-configuration-processor-plugin.js";
|
|
12
|
+
import fixCrossOrigin from "./vite-crossorigin-fix-plugin.js";
|
|
8
13
|
import generateBaseTag from "./vite-generate-base-plugin.js";
|
|
14
|
+
import generateBashScript from "./vite-generate-bash-script-plugin.js";
|
|
15
|
+
import generateImportmap, { extraDependencies, } from "./vite-importmap-plugin.js";
|
|
9
16
|
import injectMetadata from "./vite-metadata-plugin.js";
|
|
10
17
|
import serveAppShellConfig from "./vite-watch-config-plugin.js";
|
|
11
|
-
import generateBashScript from "./vite-generate-bash-script-plugin.js";
|
|
12
|
-
import fixCrossOrigin from "./vite-crossorigin-fix-plugin.js";
|
|
13
|
-
import { findAppShellConfigFile, getFinalModuleName, loadConfigFile } from "./config-utils.js";
|
|
14
|
-
import { getModulePath, resolveModule } from "./nodeModule.js";
|
|
15
|
-
import { applyAutomaticMenu, applyAutomaticViewsAndRoutes } from "./automatic-utils.js";
|
|
16
|
-
import getVirtualEntrypoints from "./virtual-entrypoints.js";
|
|
17
|
-
import SHARED_DEPENDENCIES from "./shared-dependencies.js";
|
|
18
18
|
var ViteBuildMode;
|
|
19
19
|
(function (ViteBuildMode) {
|
|
20
20
|
ViteBuildMode["PRODUCTION"] = "production";
|
|
@@ -25,8 +25,8 @@ var ViteBuildMode;
|
|
|
25
25
|
* @param opts Plugin options
|
|
26
26
|
* @param env Environment variable
|
|
27
27
|
*/
|
|
28
|
-
function
|
|
29
|
-
const { root = process.cwd(), mode = ViteBuildMode.PRODUCTION, externalImportMap = false, viewsFolder = "src/pages", autoViewsAndRoutes = false, autoMenu = false, inlineConfig = opts.generateEmptyShell ?? false, generateEmptyShell = false, modules = [] } = opts;
|
|
28
|
+
export function HvAppShellVitePlugin(opts = {}, env = {}) {
|
|
29
|
+
const { root = process.cwd(), mode = ViteBuildMode.PRODUCTION, externalImportMap = false, viewsFolder = "src/pages", autoViewsAndRoutes = false, autoMenu = false, inlineConfig = opts.generateEmptyShell ?? false, generateEmptyShell = false, modules = [], } = opts;
|
|
30
30
|
const globalEnv = loadEnv(mode, process.cwd(), "");
|
|
31
31
|
const { type = globalEnv.CI ? "bundle" : "app" } = opts;
|
|
32
32
|
console.info(`Vite running in mode: ${mode}`);
|
|
@@ -55,19 +55,19 @@ function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
55
55
|
targets: [
|
|
56
56
|
{
|
|
57
57
|
src: getModulePath("es-module-shims", "dist/*"),
|
|
58
|
-
dest: "bundles"
|
|
58
|
+
dest: "bundles",
|
|
59
59
|
},
|
|
60
60
|
// copy the ui kit icons' sprites to the "icons" folder
|
|
61
61
|
{
|
|
62
62
|
src: [
|
|
63
|
-
getModulePath("@hitachivantara/uikit-react-icons", "dist/sprites/*.svg")
|
|
63
|
+
getModulePath("@hitachivantara/uikit-react-icons", "dist/sprites/*.svg"),
|
|
64
64
|
],
|
|
65
|
-
dest: "icons"
|
|
65
|
+
dest: "icons",
|
|
66
66
|
},
|
|
67
67
|
...(!devMode && buildEntryPoint
|
|
68
68
|
? [
|
|
69
69
|
{
|
|
70
|
-
src: SHARED_DEPENDENCIES.flatMap(dep => {
|
|
70
|
+
src: SHARED_DEPENDENCIES.flatMap((dep) => {
|
|
71
71
|
const module = resolveModule(dep.bundleSrc);
|
|
72
72
|
try {
|
|
73
73
|
return [module, resolveModule(`${dep.bundleSrc}.map`)];
|
|
@@ -76,11 +76,11 @@ function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
76
76
|
return [module];
|
|
77
77
|
}
|
|
78
78
|
}),
|
|
79
|
-
dest: "bundles"
|
|
80
|
-
}
|
|
79
|
+
dest: "bundles",
|
|
80
|
+
},
|
|
81
81
|
]
|
|
82
|
-
: [])
|
|
83
|
-
]
|
|
82
|
+
: []),
|
|
83
|
+
],
|
|
84
84
|
}),
|
|
85
85
|
// create virtual endpoints for shell code and for shared dependencies
|
|
86
86
|
virtual({
|
|
@@ -88,7 +88,7 @@ function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
88
88
|
...SHARED_DEPENDENCIES.reduce((acc, dep) => {
|
|
89
89
|
acc[`/bundles/${dep.bundle}`] = dep.virtualSrc;
|
|
90
90
|
return acc;
|
|
91
|
-
}, {})
|
|
91
|
+
}, {}),
|
|
92
92
|
}),
|
|
93
93
|
// generate the importmap for shared dependencies and for apps referenced in the config file
|
|
94
94
|
generateImportmap({
|
|
@@ -108,8 +108,8 @@ function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
108
108
|
acc[`${packageJson.name}/${finalModule}.js`] = `./${module}`;
|
|
109
109
|
return acc;
|
|
110
110
|
}, {})
|
|
111
|
-
: {})
|
|
112
|
-
}, packageJson.name, [...SHARED_DEPENDENCIES.map(dep => dep.moduleId), packageJson.name], externalImportMap && buildEntryPoint, generateEmptyShell),
|
|
111
|
+
: {}),
|
|
112
|
+
}, packageJson.name, [...SHARED_DEPENDENCIES.map((dep) => dep.moduleId), packageJson.name], externalImportMap && buildEntryPoint, generateEmptyShell),
|
|
113
113
|
// inject version metadata in the index.html
|
|
114
114
|
buildEntryPoint && injectMetadata(),
|
|
115
115
|
// set the base tag and replace the title in the index.html
|
|
@@ -122,8 +122,6 @@ function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
122
122
|
// serve the app shell config file as json and watch for changes
|
|
123
123
|
serveAppShellConfig(appShellConfiguration, root, packageJson.name, appShellConfigFile, autoViewsAndRoutes ? viewsFolder : undefined),
|
|
124
124
|
// generate the shell script to replace the placeholders in the index.html
|
|
125
|
-
generateEmptyShell && generateBashScript(externalImportMap, inlineConfig)
|
|
125
|
+
generateEmptyShell && generateBashScript(externalImportMap, inlineConfig),
|
|
126
126
|
];
|
|
127
127
|
}
|
|
128
|
-
export default appShellVitePlugin;
|
|
129
|
-
//# sourceMappingURL=vite-plugin.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { PluginOption } from "vite";
|
|
2
2
|
import type { HvAppShellConfig } from "@hitachivantara/app-shell-shared";
|
|
3
3
|
export default function serveAppShellConfig(appShellConfig: HvAppShellConfig, root: string, selfAppName: string, appShellConfigFile?: string, automaticViewsFolder?: string): PluginOption;
|
|
4
|
-
//# sourceMappingURL=vite-watch-config-plugin.d.ts.map
|