@module-federation/inject-external-runtime-core-plugin 0.0.0-next-20241230030326

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present zhanghang(2heal1)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # `@module-federation/inject-external-runtime-core-plugin`
2
+
3
+ This runtime plugin will inject `@module-federation/runtime-core` .
4
+
5
+ And the plugin will be automatic applied when set `experiments.externalRuntime: 'provide'` by build plugin.
6
+
7
+ The provider can use host's runtime when set `experiments.externalRuntime: true`.
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present zhanghang(2heal1)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export * from "./src/index";
2
+ export { default } from "./src/index";
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var runtimeCore = require('@module-federation/runtime-tools/runtime-core');
4
+
5
+ function _interopNamespaceDefault(e) {
6
+ var n = Object.create(null);
7
+ if (e) {
8
+ Object.keys(e).forEach(function (k) {
9
+ if (k !== 'default') {
10
+ var d = Object.getOwnPropertyDescriptor(e, k);
11
+ Object.defineProperty(n, k, d.get ? d : {
12
+ enumerable: true,
13
+ get: function () { return e[k]; }
14
+ });
15
+ }
16
+ });
17
+ }
18
+ n.default = e;
19
+ return Object.freeze(n);
20
+ }
21
+
22
+ var runtimeCore__namespace = /*#__PURE__*/_interopNamespaceDefault(runtimeCore);
23
+
24
+ function injectExternalRuntimeCorePlugin() {
25
+ return {
26
+ name: 'inject-external-runtime-core-plugin',
27
+ version: "0.8.5",
28
+ beforeInit (args) {
29
+ const name = args.options.name;
30
+ const version = "0.8.5";
31
+ if (runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE && runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE_FROM && (runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE_FROM.name !== name || runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE_FROM.version !== version)) {
32
+ console.warn(`Detect multiple module federation runtime! Injected runtime from ${runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE_FROM.name}@${runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE_FROM.version} and current is ${name}@${version}, pleasure ensure there is only one consumer to provider runtime!`);
33
+ return args;
34
+ }
35
+ runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE = runtimeCore__namespace;
36
+ runtimeCore__namespace.Global._FEDERATION_RUNTIME_CORE_FROM = {
37
+ version,
38
+ name
39
+ };
40
+ return args;
41
+ }
42
+ };
43
+ }
44
+
45
+ module.exports = injectExternalRuntimeCorePlugin;
@@ -0,0 +1,2 @@
1
+ export * from "./src/index";
2
+ export { default } from "./src/index";
@@ -0,0 +1,24 @@
1
+ import * as runtimeCore from '@module-federation/runtime-tools/runtime-core';
2
+
3
+ function injectExternalRuntimeCorePlugin() {
4
+ return {
5
+ name: 'inject-external-runtime-core-plugin',
6
+ version: "0.8.5",
7
+ beforeInit (args) {
8
+ const name = args.options.name;
9
+ const version = "0.8.5";
10
+ if (runtimeCore.Global._FEDERATION_RUNTIME_CORE && runtimeCore.Global._FEDERATION_RUNTIME_CORE_FROM && (runtimeCore.Global._FEDERATION_RUNTIME_CORE_FROM.name !== name || runtimeCore.Global._FEDERATION_RUNTIME_CORE_FROM.version !== version)) {
11
+ console.warn(`Detect multiple module federation runtime! Injected runtime from ${runtimeCore.Global._FEDERATION_RUNTIME_CORE_FROM.name}@${runtimeCore.Global._FEDERATION_RUNTIME_CORE_FROM.version} and current is ${name}@${version}, pleasure ensure there is only one consumer to provider runtime!`);
12
+ return args;
13
+ }
14
+ runtimeCore.Global._FEDERATION_RUNTIME_CORE = runtimeCore;
15
+ runtimeCore.Global._FEDERATION_RUNTIME_CORE_FROM = {
16
+ version,
17
+ name
18
+ };
19
+ return args;
20
+ }
21
+ };
22
+ }
23
+
24
+ export { injectExternalRuntimeCorePlugin as default };
@@ -0,0 +1,12 @@
1
+ import * as runtimeCore from '@module-federation/runtime-tools/runtime-core';
2
+ import type { FederationRuntimePlugin } from '@module-federation/runtime-tools/runtime-core';
3
+ declare global {
4
+ var __VERSION__: string;
5
+ var _FEDERATION_RUNTIME_CORE: typeof runtimeCore;
6
+ var _FEDERATION_RUNTIME_CORE_FROM: {
7
+ version: string;
8
+ name: string;
9
+ };
10
+ }
11
+ declare function injectExternalRuntimeCorePlugin(): FederationRuntimePlugin;
12
+ export default injectExternalRuntimeCorePlugin;
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@module-federation/inject-external-runtime-core-plugin",
3
+ "version": "0.0.0-next-20241230030326",
4
+ "license": "MIT",
5
+ "description": "A sdk for support module federation",
6
+ "keywords": [
7
+ "Module Federation",
8
+ "sdk"
9
+ ],
10
+ "files": [
11
+ "dist/",
12
+ "README.md"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "author": "zhanghang <hanric.zhang@gmail.com>",
18
+ "sideEffects": false,
19
+ "main": "./dist/index.cjs.js",
20
+ "module": "./dist/index.esm.mjs",
21
+ "types": "./dist/index.cjs.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.cjs.d.ts",
25
+ "import": "./dist/index.esm.mjs",
26
+ "require": "./dist/index.cjs.js"
27
+ }
28
+ },
29
+ "typesVersions": {
30
+ "*": {
31
+ ".": [
32
+ "./dist/index.cjs.d.ts"
33
+ ]
34
+ }
35
+ },
36
+ "peerDependencies": {
37
+ "@module-federation/runtime-tools": "0.0.0-next-20241230030326"
38
+ },
39
+ "devDependencies": {
40
+ "@module-federation/runtime-tools": "0.0.0-next-20241230030326"
41
+ }
42
+ }