vite-plugin-zephyr 0.0.19 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +38 -38
- package/dist/lib/load_static_entries.d.ts +1 -2
- package/dist/lib/load_static_entries.js +9 -16
- package/dist/lib/load_static_entries.js.map +1 -1
- package/dist/lib/remote_map_parser.d.ts +19 -0
- package/dist/lib/remote_map_parser.js +89 -0
- package/dist/lib/remote_map_parser.js.map +1 -0
- package/dist/lib/resolve_remote_dependency.d.ts +10 -0
- package/dist/lib/resolve_remote_dependency.js +33 -0
- package/dist/lib/resolve_remote_dependency.js.map +1 -0
- package/dist/lib/types/zephyr-internal-options.d.ts +48 -0
- package/dist/lib/types/zephyr-internal-options.js +3 -0
- package/dist/lib/types/zephyr-internal-options.js.map +1 -0
- package/dist/lib/vite-plugin-zephyr-partial.js +1 -1
- package/dist/lib/vite-plugin-zephyr-partial.js.map +1 -1
- package/dist/lib/vite-plugin-zephyr.d.ts +2 -1
- package/dist/lib/vite-plugin-zephyr.js +70 -31
- package/dist/lib/vite-plugin-zephyr.js.map +1 -1
- package/dist/package.json +10 -5
- package/package.json +10 -5
package/LICENSE
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
Apache License
|
2
|
-
Version 2.0, January 2004
|
3
|
-
http://www.apache.org/licenses/
|
4
|
-
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
-
|
7
|
-
1. Definitions.
|
8
|
-
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
-
|
12
|
-
...
|
13
|
-
|
14
|
-
END OF TERMS AND CONDITIONS
|
15
|
-
|
16
|
-
APPENDIX: How to apply the Apache License to your work.
|
17
|
-
|
18
|
-
To apply the Apache License to your work, attach the following
|
19
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
20
|
-
replaced with your own identifying information. (Don't include
|
21
|
-
the brackets!) The text should be enclosed in the appropriate
|
22
|
-
comment syntax for the file format. We also recommend that a
|
23
|
-
file or class name and description of purpose be included on the
|
24
|
-
same line as the copyright notice for each file. The "copyright"
|
25
|
-
word should be left as is (without quotes).
|
26
|
-
|
27
|
-
Copyright [2023] [Zephyr Cloud]
|
28
|
-
|
29
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
30
|
-
you may not use this file except in compliance with the License.
|
31
|
-
You may obtain a copy of the License at
|
32
|
-
|
33
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
34
|
-
|
35
|
-
Unless required by applicable law or agreed to in writing, software
|
36
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
37
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
38
|
-
See the License for the specific language governing permissions and
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
...
|
13
|
+
|
14
|
+
END OF TERMS AND CONDITIONS
|
15
|
+
|
16
|
+
APPENDIX: How to apply the Apache License to your work.
|
17
|
+
|
18
|
+
To apply the Apache License to your work, attach the following
|
19
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
20
|
+
replaced with your own identifying information. (Don't include
|
21
|
+
the brackets!) The text should be enclosed in the appropriate
|
22
|
+
comment syntax for the file format. We also recommend that a
|
23
|
+
file or class name and description of purpose be included on the
|
24
|
+
same line as the copyright notice for each file. The "copyright"
|
25
|
+
word should be left as is (without quotes).
|
26
|
+
|
27
|
+
Copyright [2023] [Zephyr Cloud]
|
28
|
+
|
29
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
30
|
+
you may not use this file except in compliance with the License.
|
31
|
+
You may obtain a copy of the License at
|
32
|
+
|
33
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
34
|
+
|
35
|
+
Unless required by applicable law or agreed to in writing, software
|
36
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
37
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
38
|
+
See the License for the specific language governing permissions and
|
39
39
|
limitations under the License.
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { OutputAsset
|
1
|
+
import { OutputAsset } from 'rollup';
|
2
2
|
interface LoadStaticEntriesOptions {
|
3
3
|
root: string;
|
4
|
-
bundle: OutputBundle;
|
5
4
|
outDir: string;
|
6
5
|
}
|
7
6
|
export declare function load_static_entries(props: LoadStaticEntriesOptions): Promise<OutputAsset[]>;
|
@@ -6,14 +6,9 @@ const node_path_1 = require("node:path");
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
7
7
|
const vite_1 = require("vite");
|
8
8
|
const node_util_1 = require("node:util");
|
9
|
-
const files_to_load = {
|
10
|
-
'index.html': true,
|
11
|
-
'404.html': true,
|
12
|
-
'q-data.json': true,
|
13
|
-
};
|
14
9
|
function load_static_entries(props) {
|
15
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
16
|
-
const { root
|
11
|
+
const { root } = props;
|
17
12
|
const publicAssets = [];
|
18
13
|
const root_dist_dir = (0, node_path_1.resolve)(root, props.outDir);
|
19
14
|
const loadDir = (destDir) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
@@ -25,16 +20,14 @@ function load_static_entries(props) {
|
|
25
20
|
continue;
|
26
21
|
}
|
27
22
|
const fileName = (0, vite_1.normalizePath)((0, node_path_1.relative)(root_dist_dir, destFile));
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
});
|
37
|
-
}
|
23
|
+
publicAssets.push({
|
24
|
+
fileName,
|
25
|
+
name: file,
|
26
|
+
needsCodeReference: false,
|
27
|
+
source: yield (0, node_util_1.promisify)(node_fs_1.readFile)(destFile),
|
28
|
+
type: 'asset',
|
29
|
+
originalFileName: file,
|
30
|
+
});
|
38
31
|
}
|
39
32
|
});
|
40
33
|
yield loadDir(root_dist_dir);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"load_static_entries.js","sourceRoot":"","sources":["../../src/lib/load_static_entries.ts"],"names":[],"mappings":";;;;AACA,yCAA8C;AAC9C,qCAA0D;AAC1D,+BAAqC;AACrC,yCAAsC;
|
1
|
+
{"version":3,"file":"load_static_entries.js","sourceRoot":"","sources":["../../src/lib/load_static_entries.ts"],"names":[],"mappings":";;;;AACA,yCAA8C;AAC9C,qCAA0D;AAC1D,+BAAqC;AACrC,yCAAsC;AAOtC,SAAsB,mBAAmB,CAAC,KAA+B;;QACvE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QACvB,MAAM,YAAY,GAAkB,EAAE,CAAC;QAEvC,MAAM,aAAa,GAAG,IAAA,mBAAO,EAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,OAAO,GAAG,CAAO,OAAe,EAAE,EAAE;YACxC,KAAK,MAAM,IAAI,IAAI,IAAA,qBAAW,EAAC,OAAO,CAAC,EAAE,CAAC;gBACxC,MAAM,QAAQ,GAAG,IAAA,mBAAO,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACxC,MAAM,IAAI,GAAG,IAAA,kBAAQ,EAAC,QAAQ,CAAC,CAAC;gBAChC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACvB,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;oBACxB,SAAS;gBACX,CAAC;gBACD,MAAM,QAAQ,GAAG,IAAA,oBAAa,EAAC,IAAA,oBAAQ,EAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAClE,YAAY,CAAC,IAAI,CAAC;oBAChB,QAAQ;oBACR,IAAI,EAAE,IAAI;oBACV,kBAAkB,EAAE,KAAK;oBACzB,MAAM,EAAE,MAAM,IAAA,qBAAS,EAAC,kBAAQ,CAAC,CAAC,QAAQ,CAAC;oBAC3C,IAAI,EAAE,OAAO;oBACb,gBAAgB,EAAE,IAAI;iBACvB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAA,CAAC;QACF,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;QAC7B,OAAO,YAAY,CAAC;IACtB,CAAC;CAAA;AA3BD,kDA2BC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export interface RemoteEntry {
|
2
|
+
name: string;
|
3
|
+
entryGlobalName?: string;
|
4
|
+
entry: string;
|
5
|
+
type?: string;
|
6
|
+
}
|
7
|
+
export interface RemoteMapExtraction {
|
8
|
+
remotesMap: RemoteEntry[];
|
9
|
+
startIndex: number;
|
10
|
+
endIndex: number;
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* Parses the provided code to extract the remotes object.
|
14
|
+
*
|
15
|
+
* @param code - The code containing the remotes object declaration.
|
16
|
+
* @returns An object containing the remotes object and the start and end indices of the remotes object declaration in the code, or undefined if parsing fails.
|
17
|
+
*/
|
18
|
+
export declare function parseRemoteMap(code: string, id: string): RemoteMapExtraction | undefined;
|
19
|
+
export declare function replaceProtocolAndHost(originalUrl: string, newProtocolAndHost: string): string;
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.replaceProtocolAndHost = exports.parseRemoteMap = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const json5_1 = tslib_1.__importDefault(require("json5"));
|
6
|
+
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
7
|
+
const acorn_1 = tslib_1.__importDefault(require("acorn"));
|
8
|
+
const acorn_walk_1 = tslib_1.__importDefault(require("acorn-walk"));
|
9
|
+
/**
|
10
|
+
* Parses the provided code to extract the remotes object.
|
11
|
+
*
|
12
|
+
* @param code - The code containing the remotes object declaration.
|
13
|
+
* @returns An object containing the remotes object and the start and end indices of the remotes object declaration in the code, or undefined if parsing fails.
|
14
|
+
*/
|
15
|
+
function parseRemoteMap(code, id) {
|
16
|
+
if (!id.includes('localSharedImportMap')) {
|
17
|
+
return undefined;
|
18
|
+
}
|
19
|
+
let arrayNode;
|
20
|
+
const startTime = Date.now();
|
21
|
+
// Parse the code into an AST
|
22
|
+
const ast = acorn_1.default.parse(code, {
|
23
|
+
ecmaVersion: 'latest',
|
24
|
+
sourceType: 'module',
|
25
|
+
locations: true, // Include line and column numbers
|
26
|
+
ranges: true, // Include start and end indices
|
27
|
+
});
|
28
|
+
// Visitor function to find the variable declaration
|
29
|
+
function findUsedRemotes(node) {
|
30
|
+
if (node.type === 'VariableDeclaration' && node.kind === 'const') {
|
31
|
+
for (const declarator of node.declarations) {
|
32
|
+
if (declarator.id.type === 'Identifier' && declarator.id.name === 'usedRemotes' && declarator.init) {
|
33
|
+
// Found the 'usedRemotes' variable
|
34
|
+
arrayNode = declarator.init;
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
acorn_walk_1.default.simple(ast, {
|
41
|
+
VariableDeclaration: findUsedRemotes,
|
42
|
+
});
|
43
|
+
const endTime = Date.now();
|
44
|
+
(0, zephyr_edge_contract_1.ze_log)(`parseRemoteMap took ${endTime - startTime}ms`);
|
45
|
+
if (!arrayNode) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
(0, zephyr_edge_contract_1.ze_log)('vite.arrayNode found: ', arrayNode);
|
49
|
+
// Get start and end indices
|
50
|
+
const startIndex = arrayNode.start;
|
51
|
+
const endIndex = arrayNode.end;
|
52
|
+
// Extract the array text from the code
|
53
|
+
const arrayText = code.slice(startIndex, endIndex);
|
54
|
+
let remotesArray;
|
55
|
+
try {
|
56
|
+
// Use a faster JSON parser if possible
|
57
|
+
remotesArray = JSON.parse(arrayText);
|
58
|
+
(0, zephyr_edge_contract_1.ze_log)('vite.parseRemoteMap.remotesArray: ', remotesArray);
|
59
|
+
}
|
60
|
+
catch (error) {
|
61
|
+
// Fallback to json5 only if necessary
|
62
|
+
try {
|
63
|
+
remotesArray = json5_1.default.parse(arrayText);
|
64
|
+
}
|
65
|
+
catch (innerError) {
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
return {
|
70
|
+
remotesMap: remotesArray,
|
71
|
+
startIndex,
|
72
|
+
endIndex,
|
73
|
+
};
|
74
|
+
}
|
75
|
+
exports.parseRemoteMap = parseRemoteMap;
|
76
|
+
function replaceProtocolAndHost(originalUrl, newProtocolAndHost) {
|
77
|
+
(0, zephyr_edge_contract_1.ze_log)('vite.replaceProtocalAndHost.originalUrl: ', originalUrl);
|
78
|
+
(0, zephyr_edge_contract_1.ze_log)('vite.replaceProtocalAndHost: ', newProtocolAndHost);
|
79
|
+
const url = new URL(originalUrl);
|
80
|
+
const newUrl = new URL(newProtocolAndHost);
|
81
|
+
// Replace protocol and hostname
|
82
|
+
url.protocol = newUrl.protocol;
|
83
|
+
url.hostname = newUrl.hostname;
|
84
|
+
url.port = '';
|
85
|
+
(0, zephyr_edge_contract_1.ze_log)('vite.transformedUrl: ', url.toString());
|
86
|
+
return url.toString();
|
87
|
+
}
|
88
|
+
exports.replaceProtocolAndHost = replaceProtocolAndHost;
|
89
|
+
//# sourceMappingURL=remote_map_parser.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"remote_map_parser.js","sourceRoot":"","sources":["../../src/lib/remote_map_parser.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,+DAA8C;AAC9C,0DAA0B;AAC1B,oEAA8B;AAe9B;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,EAAU;IAErD,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACzC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,SAAiC,CAAC;IAEtC,MAAM,SAAS,GAAG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AQ,CAAC,CAAC;IACnD,IAAI,YAA2B,CAAC;IAEhC,IAAI,CAAC;QACH,uCAAuC;QACvC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAkB,CAAC;QACtD,IAAA,6BAAM,EAAC,oCAAoC,EAAE,YAAY,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,sCAAsC;QACtC,IAAI,CAAC;YACH,YAAY,GAAG,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU,EAAE,YAAY;QACxB,UAAU;QACV,QAAQ;KACT,CAAC;AACJ,CAAC;AApED,wCAoEC;AAED,SAAgB,sBAAsB,CAAC,WAAmB,EAAE,kBAA0B;IACpF,IAAA,6BAAM,EAAC,2CAA2C,EAAE,WAAW,CAAC,CAAC;IACjE,IAAA,6BAAM,EAAC,+BAA+B,EAAE,kBAAkB,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAE3C,gCAAgC;IAChC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;IAEd,IAAA,6BAAM,EAAC,uBAAuB,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAdD,wDAcC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare function resolve_remote_dependency({ name, version }: {
|
2
|
+
name: string;
|
3
|
+
version: string;
|
4
|
+
}): Promise<ResolvedDependency | void>;
|
5
|
+
export interface ResolvedDependency {
|
6
|
+
remote_name: string;
|
7
|
+
default_url: string;
|
8
|
+
application_uid: string;
|
9
|
+
remote_entry_url: string;
|
10
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.resolve_remote_dependency = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
6
|
+
function resolve_remote_dependency(_a) {
|
7
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ name, version }) {
|
8
|
+
const resolveDependency = new URL(`${zephyr_edge_contract_1.ze_api_gateway.resolve}/${encodeURIComponent(name)}/${encodeURIComponent(version)}`, (0, zephyr_edge_contract_1.ZE_API_ENDPOINT)());
|
9
|
+
(0, zephyr_edge_contract_1.ze_log)('Resolving dependency', name, version, resolveDependency);
|
10
|
+
try {
|
11
|
+
const token = yield (0, zephyr_edge_contract_1.getToken)();
|
12
|
+
const res = yield fetch(resolveDependency, {
|
13
|
+
method: 'GET',
|
14
|
+
headers: {
|
15
|
+
'Content-Type': 'application/json',
|
16
|
+
Authorization: 'Bearer ' + token,
|
17
|
+
Accept: 'application/json',
|
18
|
+
},
|
19
|
+
});
|
20
|
+
if (!res.ok) {
|
21
|
+
throw new Error(res.statusText);
|
22
|
+
}
|
23
|
+
const response = (yield res.json());
|
24
|
+
(0, zephyr_edge_contract_1.ze_log)('[Vite]: resolve remote dependency response: ', response);
|
25
|
+
return response === null || response === void 0 ? void 0 : response.value;
|
26
|
+
}
|
27
|
+
catch (err) {
|
28
|
+
(0, zephyr_edge_contract_1.ze_error)('ERR_NOT_RESOLVE_APP_NAME_WITH_VERSION', `Could not resolve '${name}' with version '${version}'`);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
}
|
32
|
+
exports.resolve_remote_dependency = resolve_remote_dependency;
|
33
|
+
//# sourceMappingURL=resolve_remote_dependency.js.map
|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8DA2BC"}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
export interface ZephyrInternalOptions {
|
2
|
+
root: string;
|
3
|
+
outDir: string;
|
4
|
+
publicDir?: string;
|
5
|
+
dir?: string;
|
6
|
+
}
|
7
|
+
export interface RemoteObjectConfig {
|
8
|
+
type?: string;
|
9
|
+
name?: string;
|
10
|
+
entry: string;
|
11
|
+
entryGlobalName?: string;
|
12
|
+
shareScope?: string;
|
13
|
+
}
|
14
|
+
export interface ManifestOptions {
|
15
|
+
filePath?: string;
|
16
|
+
disableAssetsAnalyze?: boolean;
|
17
|
+
fileName?: string;
|
18
|
+
}
|
19
|
+
export interface ModuleFederationOptions {
|
20
|
+
exposes?: Record<string, string | {
|
21
|
+
import: string;
|
22
|
+
}> | undefined;
|
23
|
+
filename?: string;
|
24
|
+
library?: any;
|
25
|
+
name: string;
|
26
|
+
remotes?: Record<string, string | Partial<RemoteObjectConfig>> | undefined;
|
27
|
+
runtime?: any;
|
28
|
+
shareScope?: string;
|
29
|
+
shared?: string[] | Record<string, string | {
|
30
|
+
name?: string;
|
31
|
+
version?: string;
|
32
|
+
shareScope?: string;
|
33
|
+
singleton?: boolean;
|
34
|
+
requiredVersion?: string;
|
35
|
+
strictVersion?: boolean;
|
36
|
+
}> | undefined;
|
37
|
+
runtimePlugins?: string[];
|
38
|
+
getPublicPath?: any;
|
39
|
+
implementation?: any;
|
40
|
+
manifest?: ManifestOptions | boolean;
|
41
|
+
dev?: any;
|
42
|
+
dts?: any;
|
43
|
+
}
|
44
|
+
export interface ZephyrPartialInternalOptions {
|
45
|
+
root: string;
|
46
|
+
outDir: string;
|
47
|
+
publicDir?: string;
|
48
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"zephyr-internal-options.js","sourceRoot":"","sources":["../../../src/lib/types/zephyr-internal-options.ts"],"names":[],"mappings":""}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.withZephyrPartial = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
|
-
const isCI = require("is-ci");
|
5
|
+
const isCI = tslib_1.__importStar(require("is-ci"));
|
6
6
|
const zephyr_agent_1 = require("zephyr-agent");
|
7
7
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
8
8
|
const load_extra_files_from_dist_1 = require("./load_extra_files_from_dist");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vite-plugin-zephyr-partial.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-zephyr-partial.ts"],"names":[],"mappings":";;;;AAAA,
|
1
|
+
{"version":3,"file":"vite-plugin-zephyr-partial.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-zephyr-partial.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAG9B,+CAcsB;AACtB,+DAU8B;AAC9B,6EAA0E;AAC1E,uDAAoD;AAGpD,SAAgB,iBAAiB;IAC/B,IAAI,MAAM,GAAiB,EAAE,CAAC;IAC9B,MAAM,qBAAqB,GAAG,EAA2B,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,CAAO,MAAsB,EAAE,EAAE;YAC/C,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE;gBACnC,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;gBAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,CAAC,CAAA;QAED,WAAW,EAAE,CAAO,OAAgC,EAAE,OAAqB,EAAE,EAAE;YAC7E,qBAAqB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YACxC,MAAM,GAAG,OAAO,CAAC;QACnB,CAAC,CAAA;QAED,WAAW,EAAE,GAAS,EAAE;YACtB,MAAM,YA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AE,EAAE,CAC3E,IAAA,+BAAQ,EAAC,6BAA6B,EAAE,4BAA4B,EAAE,GAAG,CAAC,CAC3E,CAAC;QAEF,MAAM,aAAa,GAAG,IAAA,iCAAkB,EAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;QAElE,MAAM,mBAAmB,GAAG,MAAM,IAAA,6BAAc,EAAC,aAAa,EAAE;YAC9D,aAAa;YACb,SAAS;YACT,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM;SAClC,CAAC,CAAC;QAEH,IAAI,CAAC,mBAAmB;YAAE,OAAO,IAAA,+BAAQ,EAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;QAE3F,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,IAAA,+BAAgB,EAAC,eAAe,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,IAAA,0CAAmB,EAAC,eAAe,EAAE,MAAA,qBAAqB,CAAC,UAAU,mCAAI,SAAS,EAAE,SAAS,CAAC,CAAC;QAErG,QAAQ,CAAC;YACP,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,mBAAmB;YAC3B,OAAO,EAAE,mBAAmB,IAAA,6BAAM,EAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,IAAI;SAClE,CAAC,CAAC;IACL,CAAC;CAAA"}
|
@@ -2,28 +2,86 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.withZephyr = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
|
-
const isCI = require("is-ci");
|
5
|
+
const isCI = tslib_1.__importStar(require("is-ci"));
|
6
6
|
const zephyr_agent_1 = require("zephyr-agent");
|
7
7
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
8
8
|
const load_public_dir_1 = require("./load_public_dir");
|
9
9
|
const load_static_entries_1 = require("./load_static_entries");
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
const remote_map_parser_1 = require("./remote_map_parser");
|
11
|
+
const resolve_remote_dependency_1 = require("./resolve_remote_dependency");
|
12
|
+
const vite_1 = require("@module-federation/vite");
|
13
|
+
// Ensure ModuleFederationOptions extends the module's options
|
14
|
+
function withZephyr(_options) {
|
15
|
+
// @ts-expect-error Our library wants vite@5.0.3 but federation wants ^5.4.3
|
16
|
+
return (0, vite_1.federation)(_options).concat(zephyrPlugin(_options));
|
17
|
+
}
|
18
|
+
exports.withZephyr = withZephyr;
|
19
|
+
function zephyrPlugin(_options) {
|
20
|
+
let gitInfo;
|
21
|
+
let packageJson;
|
22
|
+
let application_uid;
|
13
23
|
const vite_internal_options = {};
|
14
24
|
return {
|
15
25
|
name: 'with-zephyr',
|
16
26
|
enforce: 'post',
|
17
27
|
configResolved: (config) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
28
|
+
var _a;
|
18
29
|
Object.assign(vite_internal_options, {
|
19
30
|
root: config.root,
|
20
|
-
|
21
|
-
outDir: config.build.outDir,
|
31
|
+
outDir: (_a = config.build) === null || _a === void 0 ? void 0 : _a.outDir,
|
22
32
|
publicDir: config.publicDir,
|
23
33
|
});
|
34
|
+
(0, zephyr_edge_contract_1.ze_log)('Configuring with Zephyr...');
|
35
|
+
packageJson = yield (0, zephyr_agent_1.getPackageJson)(vite_internal_options.root);
|
36
|
+
(0, zephyr_edge_contract_1.ze_log)('Loaded package.json.', packageJson);
|
37
|
+
if (!packageJson)
|
38
|
+
return (0, zephyr_edge_contract_1.ze_error)('ERR_PACKAGE_JSON_NOT_FOUND');
|
39
|
+
gitInfo = yield (0, zephyr_agent_1.getGitInfo)();
|
40
|
+
(0, zephyr_edge_contract_1.ze_log)('Loaded Git Info.', gitInfo);
|
41
|
+
if (!gitInfo || !(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.org) || !(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.project))
|
42
|
+
return (0, zephyr_edge_contract_1.ze_error)('ERR_NO_GIT_INFO', 'Could not get git info. \n Can you confirm this directory has initialized as a git repository? ');
|
43
|
+
if (!(packageJson === null || packageJson === void 0 ? void 0 : packageJson.name))
|
44
|
+
return (0, zephyr_edge_contract_1.ze_error)('ERR_PACKAGE_JSON_MUST_HAVE_NAME_VERSION');
|
45
|
+
application_uid = (0, zephyr_edge_contract_1.createApplicationUID)({
|
46
|
+
org: gitInfo.app.org,
|
47
|
+
project: gitInfo.app.project,
|
48
|
+
name: packageJson === null || packageJson === void 0 ? void 0 : packageJson.name,
|
49
|
+
});
|
50
|
+
(0, zephyr_edge_contract_1.ze_log)('vite-zephyr-options', vite_internal_options);
|
24
51
|
}),
|
25
|
-
|
26
|
-
|
52
|
+
transform: (code, id) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
53
|
+
const extractedRemotes = _options ? (0, remote_map_parser_1.parseRemoteMap)(code, id) : undefined;
|
54
|
+
if (extractedRemotes === undefined) {
|
55
|
+
return code;
|
56
|
+
}
|
57
|
+
const { remotesMap, startIndex, endIndex } = extractedRemotes;
|
58
|
+
const remotes = [];
|
59
|
+
for (const remote of remotesMap) {
|
60
|
+
const { name, entry, type } = remote;
|
61
|
+
(0, zephyr_edge_contract_1.ze_log)('Remote details:', JSON.stringify(remotesMap));
|
62
|
+
const remote_application_uuid = (0, zephyr_edge_contract_1.createApplicationUID)({
|
63
|
+
org: gitInfo.app.org,
|
64
|
+
project: gitInfo.app.project,
|
65
|
+
name: name,
|
66
|
+
});
|
67
|
+
(0, zephyr_edge_contract_1.ze_log)('Resolving remote:', remote_application_uuid, name);
|
68
|
+
const remoteDetails = yield (0, resolve_remote_dependency_1.resolve_remote_dependency)({ name: remote_application_uuid, version: name });
|
69
|
+
(0, zephyr_edge_contract_1.ze_log)('Resolved remote:', remoteDetails);
|
70
|
+
if (!remoteDetails) {
|
71
|
+
continue;
|
72
|
+
}
|
73
|
+
const updatedUrl = (0, remote_map_parser_1.replaceProtocolAndHost)(entry, remoteDetails.remote_entry_url);
|
74
|
+
(0, zephyr_edge_contract_1.ze_log)('Updating remote url:', entry, 'to ->', updatedUrl);
|
75
|
+
remotes.push({
|
76
|
+
name,
|
77
|
+
type,
|
78
|
+
entryGlobalName: name,
|
79
|
+
entry: updatedUrl,
|
80
|
+
});
|
81
|
+
(0, zephyr_edge_contract_1.ze_log)('Updated remote url:', entry);
|
82
|
+
}
|
83
|
+
(0, zephyr_edge_contract_1.ze_log)('Writing remotesMap to bundle:', remotes);
|
84
|
+
return code.slice(0, startIndex) + JSON.stringify(remotes) + code.slice(endIndex);
|
27
85
|
}),
|
28
86
|
closeBundle: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
29
87
|
const publicAssets = [];
|
@@ -37,35 +95,16 @@ function withZephyr() {
|
|
37
95
|
const _static_assets = yield (0, load_static_entries_1.load_static_entries)({
|
38
96
|
root: vite_internal_options.root,
|
39
97
|
outDir: vite_internal_options.outDir,
|
40
|
-
bundle,
|
41
98
|
});
|
42
99
|
publicAssets.push(..._static_assets);
|
43
|
-
const assets = Object.assign({},
|
44
|
-
yield _zephyr({ assets, vite_internal_options });
|
100
|
+
const assets = Object.assign({}, ...publicAssets.map((asset) => ({ [asset.fileName]: asset })));
|
101
|
+
yield _zephyr({ assets, vite_internal_options, application_uid, packageJson, gitInfo });
|
45
102
|
}),
|
46
103
|
};
|
47
104
|
}
|
48
|
-
exports.withZephyr = withZephyr;
|
49
105
|
function _zephyr(options) {
|
50
106
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
51
|
-
const { assets: _assets, vite_internal_options } = options;
|
52
|
-
const path_to_execution_dir = vite_internal_options.root;
|
53
|
-
(0, zephyr_edge_contract_1.ze_log)('Configuring with Zephyr...');
|
54
|
-
const packageJson = yield (0, zephyr_agent_1.getPackageJson)(path_to_execution_dir);
|
55
|
-
(0, zephyr_edge_contract_1.ze_log)('Loaded package.json.', packageJson);
|
56
|
-
if (!packageJson)
|
57
|
-
return (0, zephyr_edge_contract_1.ze_error)('ERR_PACKAGE_JSON_NOT_FOUND');
|
58
|
-
const gitInfo = yield (0, zephyr_agent_1.getGitInfo)();
|
59
|
-
(0, zephyr_edge_contract_1.ze_log)('Loaded Git Info.', gitInfo);
|
60
|
-
if (!gitInfo || !(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.org) || !(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.project))
|
61
|
-
return (0, zephyr_edge_contract_1.ze_error)('ERR_NO_GIT_INFO', 'Could not get git info. \n Can you confirm this directory has initialized as a git repository? ');
|
62
|
-
if (!(packageJson === null || packageJson === void 0 ? void 0 : packageJson.name))
|
63
|
-
return (0, zephyr_edge_contract_1.ze_error)('ERR_PACKAGE_JSON_MUST_HAVE_NAME_VERSION');
|
64
|
-
const application_uid = (0, zephyr_edge_contract_1.createApplicationUID)({
|
65
|
-
org: gitInfo.app.org,
|
66
|
-
project: gitInfo.app.project,
|
67
|
-
name: packageJson === null || packageJson === void 0 ? void 0 : packageJson.name,
|
68
|
-
});
|
107
|
+
const { assets: _assets, vite_internal_options, application_uid, packageJson, gitInfo } = options;
|
69
108
|
(0, zephyr_edge_contract_1.ze_log)('Going to check auth token or get it...');
|
70
109
|
yield (0, zephyr_agent_1.checkAuth)();
|
71
110
|
(0, zephyr_edge_contract_1.ze_log)('Got auth token, going to get application configuration and build id...');
|
@@ -79,7 +118,7 @@ function _zephyr(options) {
|
|
79
118
|
if (!buildId)
|
80
119
|
return (0, zephyr_edge_contract_1.ze_error)('ERR_GET_BUILD_ID');
|
81
120
|
const pluginOptions = {
|
82
|
-
pluginName: '
|
121
|
+
pluginName: 'vite-plugin-zephyr',
|
83
122
|
application_uid,
|
84
123
|
buildEnv: 'local',
|
85
124
|
username,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vite-plugin-zephyr.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-zephyr.ts"],"names":[],"mappings":";;;;AAAA,
|
1
|
+
{"version":3,"file":"vite-plugin-zeph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2
|
"name": "vite-plugin-zephyr",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.21",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -8,11 +8,16 @@
|
|
8
8
|
"build": "nx run vite-plugin-zephyr:build"
|
9
9
|
},
|
10
10
|
"dependencies": {
|
11
|
-
"
|
12
|
-
"
|
11
|
+
"@module-federation/runtime": "^0.6.6",
|
12
|
+
"@module-federation/vite": "^1.0.0",
|
13
|
+
"acorn": "^8.12.1",
|
14
|
+
"acorn-walk": "^8.3.4",
|
13
15
|
"is-ci": "^3",
|
14
|
-
"
|
15
|
-
"
|
16
|
+
"json5": "2.2.3",
|
17
|
+
"rollup": "^4.22.5",
|
18
|
+
"vite": "^5.4.8",
|
19
|
+
"zephyr-agent": "workspace:*",
|
20
|
+
"zephyr-edge-contract": "workspace:*"
|
16
21
|
},
|
17
22
|
"devDependencies": {
|
18
23
|
"@types/is-ci": "^3.0.4"
|
package/package.json
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"name": "vite-plugin-zephyr",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.21",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
7
7
|
"dependencies": {
|
8
|
-
"
|
9
|
-
"
|
8
|
+
"@module-federation/runtime": "^0.6.6",
|
9
|
+
"@module-federation/vite": "^1.0.0",
|
10
|
+
"acorn": "^8.12.1",
|
11
|
+
"acorn-walk": "^8.3.4",
|
10
12
|
"is-ci": "^3",
|
11
|
-
"
|
12
|
-
"
|
13
|
+
"json5": "2.2.3",
|
14
|
+
"rollup": "^4.22.5",
|
15
|
+
"vite": "^5.4.8",
|
16
|
+
"zephyr-agent": "0.0.21",
|
17
|
+
"zephyr-edge-contract": "0.0.21"
|
13
18
|
},
|
14
19
|
"devDependencies": {
|
15
20
|
"@types/is-ci": "^3.0.4"
|