Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime layer resolve #3398

Closed
wants to merge 12 commits into from
11 changes: 10 additions & 1 deletion .cursorignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ packages/core
packages/utilities
packages/typescript
packages/native-*
packages/*
!packages/runtime
apps
**/configCases
!**/configCases/container
**/dist
apps/**
*.snap
*.js

webpack/*
tools/*
.github
.vscode
*.py
.husky
.changeset
11 changes: 11 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
for layers implementation:

- shareConfig should contain layer key / value, it may be undefiend if there is none set by user. there should be no issuerLayer in the runtime package
- the layer should be composited into shareScope as layer ? (layer)+shareScope : shareScope
- for resolving layers, we should reconstruct the composite scope then search for the version
- do not remove asserts
- do not delete code or comments
- do not add or remove early returns from the function flow


to run tests execute "pnpm runtime:test"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ apps/**/dist

# test cases
!packages/enhanced/test/configCases/**/**/node_modules
packages/enhanced/test/js
packages/enhanced/test/js/**
.ignored
**/.mf
**/.mf/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"docs": "typedoc",
"f": "nx format:write",
"enhanced:jest": "pnpm build && cd packages/enhanced && NODE_OPTIONS=--experimental-vm-modules npx jest test/ConfigTestCases.basictest.js",
"runtime:test": "pnpm build && nx run runtime:test",
"lint": "nx run-many --target=lint",
"test": "nx run-many --target=test",
"build": "nx run-many --target=build --parallel=5 --projects=tag:type:pkg",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// vite.config.ts
import { defineConfig } from 'file:///Users/bytedance/dev/universe/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/index.js';
import vue from 'file:///Users/bytedance/dev/universe/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@vitejs/plugin-vue/dist/index.mjs';
import path from 'path';
import dts from 'file:///Users/bytedance/dev/universe/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite-plugin-dts/dist/index.mjs';
import vueJsx from 'file:///Users/bytedance/dev/universe/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@vitejs/plugin-vue-jsx/dist/index.mjs';

// package.json
var package_default = {
name: '@module-federation/bridge-vue3',
author: 'zhouxiao <[email protected]>',
license: 'MIT',
repository: {
type: 'git',
url: 'https://github.com/module-federation/core',
directory: 'packages/vue3-bridge',
},
version: '0.8.3',
publishConfig: {
access: 'public',
},
type: 'module',
main: './dist/index.cjs.js',
module: './dist/index.es.js',
types: './dist/index.d.ts',
files: [
'dist/',
'src/',
'CHANGELOG.md',
'LICENSE',
'package.json',
'project.json',
'README.md',
'tsconfig.json',
'tsconfig.node.json',
'vite.config.ts',
],
scripts: {
dev: 'vite',
build: 'vite build',
preview: 'vite preview',
},
peerDependencies: {
vue: '=3',
'vue-router': '=3',
},
dependencies: {
'@module-federation/bridge-shared': 'workspace:*',
'@module-federation/sdk': 'workspace:*',
'@module-federation/runtime': 'workspace:*',
},
devDependencies: {
'@vitejs/plugin-vue': '^5.0.4',
'@vitejs/plugin-vue-jsx': '^4.0.0',
typescript: '^5.2.2',
vite: '^5.2.14',
'vite-plugin-dts': '^4.3.0',
vue: '^3.4.21',
'vue-router': '4.4.5',
'vue-tsc': '^2.0.6',
},
};

// vite.config.ts
var __vite_injected_original_dirname =
'/Users/bytedance/dev/universe/packages/bridge/vue3-bridge';
var vite_config_default = defineConfig({
plugins: [
vue(),
dts({
rollupTypes: true,
bundledPackages: ['@module-federation/bridge-shared'],
}),
vueJsx(),
],
build: {
lib: {
entry: path.resolve(__vite_injected_original_dirname, 'src/index.ts'),
formats: ['cjs', 'es'],
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
external: ['vue', 'vue-router'],
},
},
define: {
__APP_VERSION__: JSON.stringify(package_default.version),
},
});
export { vite_config_default as default };
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiLCAicGFja2FnZS5qc29uIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZGlybmFtZSA9IFwiL1VzZXJzL2J5dGVkYW5jZS9kZXYvdW5pdmVyc2UvcGFja2FnZXMvYnJpZGdlL3Z1ZTMtYnJpZGdlXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvVXNlcnMvYnl0ZWRhbmNlL2Rldi91bml2ZXJzZS9wYWNrYWdlcy9icmlkZ2UvdnVlMy1icmlkZ2Uvdml0ZS5jb25maWcudHNcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfaW1wb3J0X21ldGFfdXJsID0gXCJmaWxlOi8vL1VzZXJzL2J5dGVkYW5jZS9kZXYvdW5pdmVyc2UvcGFja2FnZXMvYnJpZGdlL3Z1ZTMtYnJpZGdlL3ZpdGUuY29uZmlnLnRzXCI7aW1wb3J0IHsgZGVmaW5lQ29uZmlnIH0gZnJvbSAndml0ZSc7XG5pbXBvcnQgdnVlIGZyb20gJ0B2aXRlanMvcGx1Z2luLXZ1ZSc7XG5pbXBvcnQgcGF0aCBmcm9tICdwYXRoJztcbmltcG9ydCBkdHMgZnJvbSAndml0ZS1wbHVnaW4tZHRzJztcbmltcG9ydCB2dWVKc3ggZnJvbSAnQHZpdGVqcy9wbHVnaW4tdnVlLWpzeCc7XG5pbXBvcnQgcGFja2FnZUpzb24gZnJvbSAnLi9wYWNrYWdlLmpzb24nO1xuXG5leHBvcnQgZGVmYXVsdCBkZWZpbmVDb25maWcoe1xuICBwbH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kFBWSxPQUFPO0FBQUEsRUFDckQ7QUFDRixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo=
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class ContainerReferencePlugin {
`.${data.request.slice(key.length)}`,
//@ts-ignore
config.shareScope,
data.contextInfo?.issuerLayer || undefined,
compiler.context
);
}
}
Expand Down
19 changes: 14 additions & 5 deletions packages/enhanced/src/lib/container/RemoteModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,24 @@ class RemoteModule extends Module {
* @param {string[]} externalRequests list of external requests to containers
* @param {string} internalRequest name of exposed module in container
* @param {string} shareScope the used share scope name
* @param {string=} layer optional layer name
* @param {string=} context optional context name
*/
constructor(
request: string,
externalRequests: string[],
internalRequest: string,
shareScope: string,
layer?: string,
context?: string
) {
super(WEBPACK_MODULE_TYPE_REMOTE);
super(WEBPACK_MODULE_TYPE_REMOTE, context, layer);
this.request = request;
this.externalRequests = externalRequests;
this.internalRequest = internalRequest;
this.shareScope = shareScope;
this._identifier = `remote (${shareScope}) ${this.externalRequests.join(
// Compose share scope with layer if present
this.shareScope = layer ? `(${layer})${shareScope}` : shareScope;
this._identifier = `remote (${this.shareScope}) ${this.externalRequests.join(
' ',
)} ${this.internalRequest}`;
}
Expand Down Expand Up @@ -106,7 +111,6 @@ class RemoteModule extends Module {
* @param {function(WebpackError=): void} callback callback function
* @returns {void}
*/
// @ts-ignore
override build(
options: WebpackOptionsNormalized,
compilation: Compilation,
Expand Down Expand Up @@ -157,7 +161,6 @@ class RemoteModule extends Module {
* @param {CodeGenerationContext} context context for code generation
* @returns {CodeGenerationResult} result
*/
// @ts-ignore
override codeGeneration(
context: CodeGenerationContext,
): CodeGenerationResult {
Expand All @@ -176,12 +179,18 @@ class RemoteModule extends Module {
]);
return { sources, data, runtimeRequirements: RUNTIME_REQUIREMENTS };
}

/**
* Serializes the module
* @param {any} context serialization context
*/
override serialize(context: any) {
const { write } = context;
write(this.request);
write(this.externalRequests);
write(this.internalRequest);
write(this.shareScope);
write(this.layer);
super.serialize(context);
}

Expand Down
1 change: 1 addition & 0 deletions packages/enhanced/src/lib/sharing/ProvideSharedModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class ProvideSharedModule extends Module {
requiredVersion: this._requiredVersion,
strictVersion: this._strictVersion,
singleton: this._singleton,
layer: this.layer,
},
});
return { sources, data, runtimeRequirements };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ProvideSharedModuleFactory extends ModuleFactory {
dep.requiredVersion,
dep.strictVersion,
dep.singleton,
dep.layer,
),
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/enhanced/src/lib/sharing/ProvideSharedPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ class ProvideSharedPlugin {
config.requiredVersion!,
config.strictVersion!,
config.singleton!,
config.layer,
),
{
name: undefined,
Expand Down
61 changes: 51 additions & 10 deletions packages/enhanced/src/lib/sharing/ShareRuntimeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ class ShareRuntimeModule extends RuntimeModule {
if (sharedOption) {
sharedInitOptions[sharedOption.name] =
sharedInitOptions[sharedOption.name] || [];
const isSameVersion = sharedInitOptions[sharedOption.name].find(
(s) => s.version === sharedOption.version,
const isSameVersionAndLayer = sharedInitOptions[
sharedOption.name
].find(
(s) =>
s.version === sharedOption.version &&
s.shareConfig?.layer === sharedOption.shareConfig?.layer,
);
if (!isSameVersion) {
if (!isSameVersionAndLayer) {
sharedInitOptions[sharedOption.name].push(sharedOption);
}
}
Expand All @@ -88,18 +92,19 @@ class ShareRuntimeModule extends RuntimeModule {
(sum, sharedName) => {
const sharedOptions = sharedInitOptions[sharedName];
let str = '';
sharedOptions.forEach((sharedOption) => {

// Ensure all options are included without filtering
sharedOptions.forEach((option) => {
str += `{${Template.indent([
`version: ${sharedOption.version},`,
`get: ${sharedOption.getter},`,
`scope: ${JSON.stringify(sharedOption.shareScope)},`,
`shareConfig: ${JSON.stringify(sharedOption.shareConfig)}`,
`version: ${option.version},`,
`get: ${option.getter},`,
`scope: ${JSON.stringify(option.shareScope)},`,
`shareConfig: ${JSON.stringify(option.shareConfig)}`,
])}},`;
});
str = `[${str}]`;

str = `[${str}]`;
sum += `${Template.indent([`"${sharedName}": ${str},`])}`;

return sum;
},
'',
Expand All @@ -108,6 +113,42 @@ class ShareRuntimeModule extends RuntimeModule {
const federationGlobal = getFederationGlobalScope(
RuntimeGlobals || ({} as typeof RuntimeGlobals),
);

// Group shared modules by scope and layer
const scopedModules = new Map<
string,
Map<string | undefined, Set<string>>
>();
for (const [scopeName, stages] of initCodePerScope) {
const layeredModules = new Map<string | undefined, Set<string>>();
scopedModules.set(scopeName, layeredModules);

for (const [, inits] of stages) {
for (const init of inits) {
const layer = init.match(/layer:\s*["']([^"']+)["']/)?.[1];
let moduleSet = layeredModules.get(layer);
if (!moduleSet) {
moduleSet = new Set();
layeredModules.set(layer, moduleSet);
}
moduleSet.add(init);
}
}
}

// Generate the registration code
const registrationCode = Array.from(scopedModules.entries())
.map(([scopeName, layeredModules]) => {
const cases = Array.from(layeredModules.entries())
.map(([layer, inits]) => {
const initCode = Array.from(inits).join('\n');
return `case "${scopeName}": {\n${Template.indent(initCode)}\n}`;
})
.join('\nbreak;\n');
return cases;
})
.join('\n');

return Template.asString([
`${getFederationGlobalScope(
RuntimeGlobals,
Expand Down
4 changes: 3 additions & 1 deletion packages/enhanced/src/lib/sharing/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { isRequiredVersion } from '@module-federation/sdk';
import type { ConsumeOptions } from 'webpack/lib/sharing/ConsumeSharedModule';
import type { ConsumeOptions } from '../../declarations/plugins/sharing/ConsumeSharedModule';
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
import type { InputFileSystem } from 'webpack/lib/util/fs';
const { join, dirname, readJson } = require(
Expand Down Expand Up @@ -459,6 +459,7 @@ export function normalizeConsumeShareOptions(consumeOptions: ConsumeOptions) {
eager,
shareKey,
shareScope,
layer,
} = consumeOptions;
return {
shareConfig: {
Expand All @@ -467,6 +468,7 @@ export function normalizeConsumeShareOptions(consumeOptions: ConsumeOptions) {
strictVersion,
singleton,
eager,
layer,
},
shareScope,
shareKey,
Expand Down
1 change: 1 addition & 0 deletions packages/enhanced/test/ConfigTestCases.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const describeCases = (config) => {
jest.setTimeout(20000);

for (const category of categories) {
if (category.name !== 'layers') continue;
// eslint-disable-next-line no-loop-func
describe(category.name, () => {
for (const testName of category.tests) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import ComponentA from 'containerA/ComponentA';
import ComponentALayers from 'containerA/ComponentALayers';

export default () => {
return `App rendered with [${React()}], [${ComponentA()}] and [${ComponentALayers()}]`;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export default () => {
return `ComponentA rendered with [${React()}]`;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';

export default () => {
debugger;
return `ComponentALayers rendered with [${React.layeredComponentsReact()}]`;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
it('should load the component from container', () => {
return import('./App').then(({ default: App }) => {
const rendered = App();
expect(rendered).toBe(
'App rendered with [This is react 0.1.2], [ComponentA rendered with [This is react 0.1.2]] and [ComponentALayers rendered with [This is layered react]]',
);
return import('./upgrade-react').then(({ default: upgrade }) => {
upgrade();
const rendered = App();
expect(rendered).toBe(
'App rendered with [This is react 1.2.3], [ComponentA rendered with [This is react 1.2.3]] and [ComponentALayers rendered with [This is layered react]]',
);
});
});
});
Loading
Loading