zephyr-repack-plugin 0.0.0 → 0.0.2
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 +3 -0
- package/dist/README.md +3 -0
- package/dist/delegate-module/delegate-module-template.d.ts +1 -0
- package/dist/delegate-module/delegate-module-template.js +78 -0
- package/dist/delegate-module/delegate-module-template.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils/get-platform.d.ts +9 -0
- package/dist/lib/utils/get-platform.js +18 -0
- package/dist/lib/utils/get-platform.js.map +1 -0
- package/dist/lib/utils/ze-util-verification.d.ts +21 -0
- package/dist/lib/utils/ze-util-verification.js +40 -0
- package/dist/lib/utils/ze-util-verification.js.map +1 -0
- package/dist/lib/with-zephyr.d.ts +3 -0
- package/dist/lib/with-zephyr.js +42 -0
- package/dist/lib/with-zephyr.js.map +1 -0
- package/dist/lib/ze-repack-plugin.d.ts +15 -0
- package/dist/lib/ze-repack-plugin.js +17 -0
- package/dist/lib/ze-repack-plugin.js.map +1 -0
- package/dist/package.json +23 -0
- package/dist/type/zephyr-internal-types.d.ts +6 -0
- package/dist/type/zephyr-internal-types.js +3 -0
- package/dist/type/zephyr-internal-types.js.map +1 -0
- package/package.json +20 -2
package/README.md
ADDED
package/dist/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function repack_delegate_module_template(): unknown;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repack_delegate_module_template = void 0;
|
|
4
|
+
function repack_delegate_module_template() {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const remote_entry_url = '__REMOTE_ENTRY_URL__';
|
|
7
|
+
const library_type = '__LIBRARY_TYPE__';
|
|
8
|
+
let edgeUrl = remote_entry_url;
|
|
9
|
+
let remote_name = '__REMOTE_NAME__';
|
|
10
|
+
if (edgeUrl.includes('@')) {
|
|
11
|
+
[remote_name, edgeUrl] = edgeUrl.split('@');
|
|
12
|
+
}
|
|
13
|
+
const resolve_entry = [
|
|
14
|
+
fetch(edgeUrl, {
|
|
15
|
+
method: 'HEAD',
|
|
16
|
+
headers: {
|
|
17
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
.then(() => edgeUrl)
|
|
21
|
+
.catch(() => false),
|
|
22
|
+
];
|
|
23
|
+
Promise.race(resolve_entry)
|
|
24
|
+
.then((remoteUrl) => {
|
|
25
|
+
if (typeof remoteUrl !== 'string')
|
|
26
|
+
return;
|
|
27
|
+
let _win = {};
|
|
28
|
+
_win =
|
|
29
|
+
globalThis !== undefined
|
|
30
|
+
? globalThis
|
|
31
|
+
: global;
|
|
32
|
+
const ScriptManager = __webpack_require__.repack.shared.scriptManager;
|
|
33
|
+
ScriptManager.addResolver(
|
|
34
|
+
// @ts-expect-error TODO fix await
|
|
35
|
+
(scriptId, caller, referenceUrl) => {
|
|
36
|
+
if (scriptId === remote_name) {
|
|
37
|
+
return { url: remoteUrl };
|
|
38
|
+
}
|
|
39
|
+
if (referenceUrl && caller === remote_name) {
|
|
40
|
+
const publicPath = remoteUrl.split('/').slice(0, -1).join('/');
|
|
41
|
+
const bundlePath = scriptId + referenceUrl.split(scriptId)[1];
|
|
42
|
+
return { url: publicPath + '/' + bundlePath };
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}, { key: remote_name });
|
|
46
|
+
if (typeof _win[remote_name] !== 'undefined') {
|
|
47
|
+
return resolve(_win[remote_name]);
|
|
48
|
+
}
|
|
49
|
+
if (typeof __webpack_require__ !== 'undefined' &&
|
|
50
|
+
typeof __webpack_require__.l === 'function' &&
|
|
51
|
+
// @ts-expect-error - library_type is inherited enum type instead of string
|
|
52
|
+
library_type !== 'self') {
|
|
53
|
+
// @ts-expect-error temp
|
|
54
|
+
__webpack_require__.l(remote_entry_url, () => {
|
|
55
|
+
resolve(_win[remote_name]);
|
|
56
|
+
}, remote_name
|
|
57
|
+
// remote_name
|
|
58
|
+
);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
return new Function(`return import("${remoteUrl}")`)()
|
|
62
|
+
.then((mod) => {
|
|
63
|
+
if (typeof _win[remote_name] !== 'undefined') {
|
|
64
|
+
return resolve(_win[remote_name]);
|
|
65
|
+
}
|
|
66
|
+
return resolve(mod);
|
|
67
|
+
})
|
|
68
|
+
.catch((err) => {
|
|
69
|
+
reject(err);
|
|
70
|
+
});
|
|
71
|
+
})
|
|
72
|
+
.catch((err) => {
|
|
73
|
+
console.error(`Zephyr: error loading remote entry ${remote_entry_url}`, err);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.repack_delegate_module_template = repack_delegate_module_template;
|
|
78
|
+
//# sourceMappingURL=delegate-module-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-module-template.js","sourceRoot":"","sources":["../../src/delegate-module/delegate-module-template.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { withZephyr } from './lib/with-zephyr';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withZephyr = void 0;
|
|
4
|
+
var with_zephyr_1 = require("./lib/with-zephyr");
|
|
5
|
+
Object.defineProperty(exports, "withZephyr", { enumerable: true, get: function () { return with_zephyr_1.withZephyr; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,yGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Configuration } from '@rspack/core';
|
|
2
|
+
import { DelegateConfig } from '../../type/zephyr-internal-types';
|
|
3
|
+
import { XPackConfiguration } from 'zephyr-xpack-internal';
|
|
4
|
+
import { Compiler } from '@rspack/core';
|
|
5
|
+
type Plugin = NonNullable<XPackConfiguration<Compiler>['plugins']>[number];
|
|
6
|
+
export declare function is_repack_plugin(plugin?: Plugin): any;
|
|
7
|
+
type Platform = DelegateConfig['target'];
|
|
8
|
+
export declare function get_platform_from_repack(config: Configuration): Platform;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_platform_from_repack = exports.is_repack_plugin = void 0;
|
|
4
|
+
function is_repack_plugin(plugin) {
|
|
5
|
+
if (!plugin || typeof plugin !== 'object') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return (plugin.constructor.name.includes('RepackPlugin') ||
|
|
9
|
+
plugin['name']?.includes('RepackPlugin'));
|
|
10
|
+
}
|
|
11
|
+
exports.is_repack_plugin = is_repack_plugin;
|
|
12
|
+
function get_platform_from_repack(config) {
|
|
13
|
+
return config.plugins
|
|
14
|
+
?.filter(is_repack_plugin)
|
|
15
|
+
?.map((plugin) => plugin.config.platform)[0];
|
|
16
|
+
}
|
|
17
|
+
exports.get_platform_from_repack = get_platform_from_repack;
|
|
18
|
+
//# sourceMappingURL=get-platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-platform.js","sourceRoot":"","sources":["../../../src/lib/utils/get-platform.ts"],"names":[],"mappings":";;;AAMA,SAAgB,gBAAgB,CAAC,MAAe;IAC9C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CACzC,CAAC;AACJ,CAAC;AARD,4CAQC;AAID,SAAgB,wBAAwB,CAAC,MAAqB;IAC5D,OAAO,MAAM,CAAC,OAAO;QACnB,EAAE,MAAM,CAAC,gBAAgB,CAAC;QAC1B,EAAE,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAJD,4DAIC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ZephyrEngine } from 'zephyr-agent';
|
|
2
|
+
interface RemotesConfig {
|
|
3
|
+
/** Container locations from which modules should be resolved and loaded at runtime. */
|
|
4
|
+
external: string | string[];
|
|
5
|
+
/** The name of the share scope shared with this remote. */
|
|
6
|
+
shareScope?: string;
|
|
7
|
+
}
|
|
8
|
+
interface RemotesObject {
|
|
9
|
+
[index: string]: string | RemotesConfig | string[];
|
|
10
|
+
}
|
|
11
|
+
interface KnownMfConfig {
|
|
12
|
+
config?: {
|
|
13
|
+
name: string;
|
|
14
|
+
library?: {
|
|
15
|
+
type?: string;
|
|
16
|
+
};
|
|
17
|
+
remotes?: (string | RemotesObject)[] | RemotesObject;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function verify_mf_fastly_config(mf_configs: KnownMfConfig[] | undefined, zephyr_engine: ZephyrEngine): Promise<void>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verify_mf_fastly_config = void 0;
|
|
4
|
+
// import { UploadProviderType } from '../../../../zephyr-agent/src/lib/node-persist/upload-provider-options';
|
|
5
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
6
|
+
const valid_identifiers = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
7
|
+
// Fastly doesn't allow underscore in domains, reference: https://datatracker.ietf.org/doc/html/rfc1035#:~:text=The%20labels%20must%20follow%20the%20rules%20for%20ARPANET%20host%20names.%20%20They%20must%0Astart%20with%20a%20letter%2C%20end%20with%20a%20letter%20or%20digit%2C%20and%20have%20as%20interior%0Acharacters%20only%20letters%2C%20digits%2C%20and%20hyphen.%20%20There%20are%20also%20some%0Arestrictions%20on%20the%20length.%20%20Labels%20must%20be%2063%20characters%20or%20less.
|
|
8
|
+
const valid_identifier_fastly = /^[a-zA-Z$][a-zA-Z0-9$]*$/;
|
|
9
|
+
async function verify_mf_fastly_config(mf_configs, zephyr_engine) {
|
|
10
|
+
if (!mf_configs)
|
|
11
|
+
return;
|
|
12
|
+
const platform = (await zephyr_engine.application_configuration).PLATFORM;
|
|
13
|
+
for (const mf_config of mf_configs) {
|
|
14
|
+
const mfConfig = mf_config.config;
|
|
15
|
+
if (!mfConfig)
|
|
16
|
+
return;
|
|
17
|
+
const condition = mfConfig?.library?.type === 'var' || typeof mfConfig?.library?.type === 'undefined';
|
|
18
|
+
if (condition &&
|
|
19
|
+
!valid_identifiers.test(mfConfig?.name)
|
|
20
|
+
// && platform === UploadProviderType.FASTLY
|
|
21
|
+
) {
|
|
22
|
+
throw new zephyr_agent_1.ZephyrError(zephyr_agent_1.ZeErrors.ERR_INVALID_MF_CONFIG, {
|
|
23
|
+
cause: zephyr_agent_1.ZeErrors.ERR_INVALID_MF_CONFIG.message.replace('{{library_name}}', mfConfig.name),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// Verify fastly config
|
|
27
|
+
const fastly_condition = !valid_identifier_fastly.test(mfConfig.name) ||
|
|
28
|
+
!valid_identifier_fastly.test(zephyr_engine.application_uid);
|
|
29
|
+
if (condition &&
|
|
30
|
+
!fastly_condition
|
|
31
|
+
// && platform === UploadProviderType.FASTLY
|
|
32
|
+
) {
|
|
33
|
+
throw new zephyr_agent_1.ZephyrError(zephyr_agent_1.ZeErrors.ERR_INVALID_APP_ID, {
|
|
34
|
+
cause: zephyr_agent_1.ZeErrors.ERR_INVALID_APP_ID.message.replace('{{application_uid}}', zephyr_engine.application_uid),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.verify_mf_fastly_config = verify_mf_fastly_config;
|
|
40
|
+
//# sourceMappingURL=ze-util-verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ze-util-verification.js","sourceRoot":"","sources":["../../../src/lib/utils/ze-util-verification.ts"],"names":[],"mappings":";;;AAAA,8GAA8G;AAC9G,+CAAqD;AAGrD,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AACvD,weAAwe;AACxe,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAsBpD,KAAK,UAAU,uBAAuB,CAC3C,UAAuC,EACvC,aAA2B;IAE3B,IAAI,CAAC,UAAU;QAAE,OAAO;IAExB,MAAM,QAAQ,GAAG,CAAC,MAAM,aAAa,CAAC,yBAAyB,CAAC,CAAC,QAAQ,CAAC;IAE1E,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC;QAElC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,MAAM,SAAS,GACb,QAAQ,EAAE,OAAO,EAAE,IAAI,KAAK,KAAK,IAAI,OAAO,QAAQ,EAAE,OAAO,EAAE,IAAI,KAAK,WAAW,CAAC;QAEtF,IACE,SAAS;YACT,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;QACvC,4CAA4C;UAC5C,CAAC;YACD,MAAM,IAAI,0BAAW,CAAC,uBAAQ,CAAC,qBAAqB,EAAE;gBACpD,KAAK,EAAE,uBAAQ,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CACnD,kBAAkB,EAClB,QAAQ,CAAC,IAAI,CACd;aACF,CAAC,CAAC;QACL,CAAC;QAED,uBAAuB;QAEvB,MAAM,gBAAgB,GACpB,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC5C,CAAC,uBAAuB,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAE/D,IACE,SAAS;YACT,CAAC,gBAAgB;QACjB,4CAA4C;UAC5C,CAAC;YACD,MAAM,IAAI,0BAAW,CAAC,uBAAQ,CAAC,kBAAkB,EAAE;gBACjD,KAAK,EAAE,uBAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAChD,qBAAqB,EACrB,aAAa,CAAC,eAAe,CAC9B;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC;AAhDD,0DAgDC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withZephyr = void 0;
|
|
4
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
5
|
+
const ze_repack_plugin_1 = require("./ze-repack-plugin");
|
|
6
|
+
const get_platform_1 = require("./utils/get-platform");
|
|
7
|
+
const zephyr_xpack_internal_1 = require("zephyr-xpack-internal");
|
|
8
|
+
const delegate_module_template_1 = require("../delegate-module/delegate-module-template");
|
|
9
|
+
const ze_util_verification_1 = require("./utils/ze-util-verification");
|
|
10
|
+
function withZephyr(zephyrPluginOptions) {
|
|
11
|
+
return (config) => _zephyr_configuration(config, zephyrPluginOptions);
|
|
12
|
+
}
|
|
13
|
+
exports.withZephyr = withZephyr;
|
|
14
|
+
async function _zephyr_configuration(config, _zephyrOptions) {
|
|
15
|
+
// create instance of ZephyrEngine to track the application
|
|
16
|
+
const zephyr_engine = await zephyr_agent_1.ZephyrEngine.create({
|
|
17
|
+
builder: 'repack',
|
|
18
|
+
context: config.context,
|
|
19
|
+
});
|
|
20
|
+
(0, zephyr_agent_1.ze_log)('Configuring with Zephyr...');
|
|
21
|
+
const target = (0, get_platform_1.get_platform_from_repack)(config);
|
|
22
|
+
(0, zephyr_agent_1.ze_log)('Deploy build target: ', target);
|
|
23
|
+
const dependency_pairs = (0, zephyr_xpack_internal_1.extractFederatedDependencyPairs)(config);
|
|
24
|
+
const resolved_dependency_pairs = await zephyr_engine.resolve_remote_dependencies(dependency_pairs, target);
|
|
25
|
+
zephyr_engine.upload_file = _zephyrOptions?.upload_file
|
|
26
|
+
? _zephyrOptions.upload_file
|
|
27
|
+
: true;
|
|
28
|
+
(0, zephyr_xpack_internal_1.mutWebpackFederatedRemotesConfig)(zephyr_engine, config, resolved_dependency_pairs, delegate_module_template_1.repack_delegate_module_template);
|
|
29
|
+
(0, zephyr_agent_1.ze_log)('dependency resolution completed successfully...or at least trying to...');
|
|
30
|
+
const mf_configs = (0, zephyr_xpack_internal_1.makeCopyOfModuleFederationOptions)(config);
|
|
31
|
+
// const app_config = await zephyr_engine.application_configuration;
|
|
32
|
+
// Verify Module Federation configuration's naming
|
|
33
|
+
await (0, ze_util_verification_1.verify_mf_fastly_config)(mf_configs, zephyr_engine);
|
|
34
|
+
(0, zephyr_agent_1.ze_log)('Application uid created...');
|
|
35
|
+
config.plugins?.push(new ze_repack_plugin_1.ZeRepackPlugin({
|
|
36
|
+
zephyr_engine,
|
|
37
|
+
target,
|
|
38
|
+
mfConfig: (0, zephyr_xpack_internal_1.makeCopyOfModuleFederationOptions)(config),
|
|
39
|
+
}));
|
|
40
|
+
return config;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=with-zephyr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-zephyr.js","sourceRoot":"","sources":["../../src/lib/with-zephyr.ts"],"names":[],"mappings":";;;AACA,+CAAoD;AAEpD,yDAA+E;AAC/E,uDAAgE;AAChE,iEAI+B;AAC/B,0FAA8F;AAC9F,uEAAuE;AAEvE,SAAgB,UAAU,CACxB,mBAA+C;IAE/C,OAAO,CAAC,MAAqB,EAAE,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AACvF,CAAC;AAJD,gCAIC;AACD,KAAK,UAAU,qBAAqB,CAClC,MAAqB,EACrB,cAA0C;IAE1C,2DAA2D;IAC3D,MAAM,aAAa,GAAG,MAAM,2BAAY,CAAC,MAAM,CAAC;QAC9C,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC,CAAC;IACH,IAAA,qBAAM,EAAC,4BAA4B,CAAC,CAAC;IAErC,MAAM,MAAM,GAAG,IAAA,uCAAwB,EAAC,MAAM,CAAC,CAAC;IAChD,IAAA,qBAAM,EAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IAExC,MAAM,gBAAgB,GAAG,IAAA,uDAA+B,EAAC,MAAM,CAAC,CAAC;IAEjE,MAAM,yBAAyB,GAAG,MAAM,aAAa,CAAC,2BAA2B,CAC/E,gBAAgB,EAChB,MAAM,CACP,CAAC;IAEF,aAAa,CAAC,WAAW,GAAG,cAAc,EAAE,WAAW;QACrD,CAAC,CAAC,cAAc,CAAC,WAAW;QAC5B,CAAC,CAAC,IAAI,CAAC;IAET,IAAA,wDAAgC,EAC9B,aAAa,EACb,MAAM,EACN,yBAAyB,EACzB,0DAA+B,CAChC,CAAC;IAEF,IAAA,qBAAM,EAAC,yEAAyE,CAAC,CAAC;IAElF,MAAM,UAAU,GAAG,IAAA,yDAAiC,EAAC,MAAM,CAAC,CAAC;IAC7D,oEAAoE;IACpE,kDAAkD;IAClD,MAAM,IAAA,8CAAuB,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAEzD,IAAA,qBAAM,EAAC,4BAA4B,CAAC,CAAC;IACrC,MAAM,CAAC,OAAO,EAAE,IAAI,CAClB,IAAI,iCAAc,CAAC;QACjB,aAAa;QACb,MAAM;QACN,QAAQ,EAAE,IAAA,yDAAiC,EAAC,MAAM,CAAC;KACpD,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Compiler } from '@rspack/core';
|
|
2
|
+
import { ZephyrEngine } from 'zephyr-agent';
|
|
3
|
+
import { ModuleFederationPlugin } from 'zephyr-xpack-internal';
|
|
4
|
+
export interface ZephyrRepackPluginOptions {
|
|
5
|
+
zephyr_engine: ZephyrEngine;
|
|
6
|
+
pluginName: string;
|
|
7
|
+
mfConfig: ModuleFederationPlugin[] | ModuleFederationPlugin | undefined;
|
|
8
|
+
target: 'ios' | 'android' | 'web' | undefined;
|
|
9
|
+
upload_file?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class ZeRepackPlugin {
|
|
12
|
+
_options: ZephyrRepackPluginOptions;
|
|
13
|
+
constructor(options: Omit<ZephyrRepackPluginOptions, 'pluginName'>);
|
|
14
|
+
apply(compiler: Compiler): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZeRepackPlugin = void 0;
|
|
4
|
+
const zephyr_xpack_internal_1 = require("zephyr-xpack-internal");
|
|
5
|
+
const pluginName = 'ZephyrRepackPlugin';
|
|
6
|
+
class ZeRepackPlugin {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this._options = Object.assign({ pluginName }, options);
|
|
9
|
+
}
|
|
10
|
+
apply(compiler) {
|
|
11
|
+
this._options.zephyr_engine.buildProperties.output = compiler.outputPath;
|
|
12
|
+
(0, zephyr_xpack_internal_1.logBuildSteps)(this._options, compiler);
|
|
13
|
+
(0, zephyr_xpack_internal_1.setupZeDeploy)(this._options, compiler);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.ZeRepackPlugin = ZeRepackPlugin;
|
|
17
|
+
//# sourceMappingURL=ze-repack-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ze-repack-plugin.js","sourceRoot":"","sources":["../../src/lib/ze-repack-plugin.ts"],"names":[],"mappings":";;;AAEA,iEAI+B;AAE/B,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAWxC,MAAa,cAAc;IAGzB,YAAY,OAAsD;QAChE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,QAAkB;QACtB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC;QACzE,IAAA,qCAAa,EAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvC,IAAA,qCAAa,EAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AAZD,wCAYC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zephyr-repack-plugin",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "nx build zephyr-repack-plugin",
|
|
10
|
+
"test": "nx test zephyr-repack-plugin",
|
|
11
|
+
"patch-version": "pnpm version"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"zephyr-agent": "workspace:*",
|
|
15
|
+
"zephyr-xpack-internal": "workspace:*"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@callstack/repack": "5.0.0-rc.0",
|
|
19
|
+
"@rspack/core": "1.0.8",
|
|
20
|
+
"@types/find-package-json": "^1.2.6",
|
|
21
|
+
"@types/is-ci": "^3.0.4"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zephyr-internal-types.js","sourceRoot":"","sources":["../../src/type/zephyr-internal-types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zephyr-repack-plugin",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"license": "Apache-2.0"
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"zephyr-agent": "0.0.31",
|
|
10
|
+
"zephyr-xpack-internal": "0.0.31"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@callstack/repack": "5.0.0-rc.0",
|
|
14
|
+
"@rspack/core": "1.0.8",
|
|
15
|
+
"@types/find-package-json": "^1.2.6",
|
|
16
|
+
"@types/is-ci": "^3.0.4"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "nx build zephyr-repack-plugin",
|
|
20
|
+
"test": "nx test zephyr-repack-plugin",
|
|
21
|
+
"patch-version": "pnpm version"
|
|
22
|
+
}
|
|
5
23
|
}
|