Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0542707
feat: integrate metro package into release pipeline and changesets
ScriptedAlchemy Sep 2, 2025
e3ab164
feat: integrate metro packages into CI/CD pipeline
ScriptedAlchemy Sep 2, 2025
cabe31b
Potential fix for code scanning alert no. 136: Workflow does not cont…
ScriptedAlchemy Sep 2, 2025
611a499
Potential fix for code scanning alert no. 135: Workflow does not cont…
ScriptedAlchemy Sep 2, 2025
7aec258
fix(module-federation): remove incorrect secrets: inherit from reusab…
ScriptedAlchemy Sep 2, 2025
f5006fe
fix(module-federation): remove duplicate permissions block in build-m…
ScriptedAlchemy Sep 2, 2025
008d63e
test(module-federation): trigger workflow to test fixes
ScriptedAlchemy Sep 2, 2025
8ac582e
fix(module-federation): complete e2e-modern-ssr workflow with actual …
ScriptedAlchemy Sep 2, 2025
7e6ed3b
fix(module-federation): move metro package publint checks to metro wo…
ScriptedAlchemy Sep 2, 2025
2a0df69
test(module-federation): trigger workflow with metro exclusions
ScriptedAlchemy Sep 2, 2025
98ccb58
fix(module-federation): optimize metro build workflow to preserve nx …
ScriptedAlchemy Sep 2, 2025
948daba
fix(metro-core): correct NX build configuration to avoid --prefix fla…
ScriptedAlchemy Sep 2, 2025
d79106a
fix(module-federation): integrate metro packages into main build work…
ScriptedAlchemy Sep 2, 2025
57aca25
fix(module-federation): properly separate metro build from main workflow
ScriptedAlchemy Sep 2, 2025
6879efa
fix(module-federation): build all packages in metro workflow without …
ScriptedAlchemy Sep 2, 2025
47cb755
fix(metro-core): resolve linting issues
ScriptedAlchemy Sep 2, 2025
e168de6
fix: resolve ESLint errors in metro-core package
ScriptedAlchemy Sep 3, 2025
1b9add4
fix: update metro-plugin-rnef build configuration
ScriptedAlchemy Sep 3, 2025
11b08ea
Merge branch 'main' into metro-ci
ScriptedAlchemy Sep 3, 2025
1847d3e
fix: add pnpm install after build to ensure workspace linking
ScriptedAlchemy Sep 3, 2025
0de2a9e
fix: remove redundant pnpm install from modernjs build command
ScriptedAlchemy Sep 3, 2025
8b2c322
fix: correct cypress config and sourceRoot paths in modernjs-ssr proj…
ScriptedAlchemy Sep 3, 2025
cb18e27
fix(module-federation): resolve ModernJS SSR CI failures
ScriptedAlchemy Sep 3, 2025
27e1631
fix(module-federation): debug and fix ModernJS SSR E2E issues
ScriptedAlchemy Sep 3, 2025
4f06e39
fix: add missing @module-federation/modern-js dependency to dynamic-r…
ScriptedAlchemy Sep 3, 2025
cd4715a
fix: simplify e2e-modern-ssr workflow and ensure proper package linking
ScriptedAlchemy Sep 3, 2025
5a12534
Apply suggested changes
ScriptedAlchemy Sep 3, 2025
b1ead79
fix: remove --prefer-offline flag from pnpm install
ScriptedAlchemy Sep 3, 2025
4d51454
chore: sourcemaps
ScriptedAlchemy Sep 3, 2025
660d568
Update README.md
ScriptedAlchemy Sep 3, 2025
bb42c6c
Update packages/metro-plugin-rnef/project.json
ScriptedAlchemy Sep 3, 2025
378950d
chore: format metro-plugin-rnef project.json
ScriptedAlchemy Sep 3, 2025
6f60766
chore: update changeset for metro packages
ScriptedAlchemy Sep 3, 2025
3a4cfbc
chore: sourcemaps
ScriptedAlchemy Sep 3, 2025
74d5cd3
chore: update changeset config and vscode launch configuration
ScriptedAlchemy Sep 3, 2025
6efc3b6
Merge branch 'main' into metro-ci
ScriptedAlchemy Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"@module-federation/runtime-core",
"create-module-federation",
"@module-federation/cli",
"@module-federation/rspress-plugin"
"@module-federation/rspress-plugin",
"@module-federation/metro",
"@module-federation/metro-plugin-rnef",
"@module-federation/metro-plugin-rnc-cli"
]
],
"ignorePatterns": ["^alpha|^beta"],
Expand Down
7 changes: 7 additions & 0 deletions .changeset/metro-package-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@module-federation/metro-plugin-rnc-cli': patch
'@module-federation/metro-plugin-rnef': patch
'@module-federation/metro': patch
---

Initial Release of Metro package
13 changes: 12 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Build Affected Packages

permissions:
contents: read

on:
pull_request:
branches: [main, '**']
Expand Down Expand Up @@ -72,7 +75,10 @@ jobs:
[ "$pkg" != "packages/core" ] && \
[ "$pkg" != "packages/esbuild" ] && \
[ "$pkg" != "packages/modernjs" ] && \
[ "$pkg" != "packages/utilities" ]; then
[ "$pkg" != "packages/utilities" ] && \
[ "$pkg" != "packages/metro-core" ] && \
[ "$pkg" != "packages/metro-plugin-rnef" ] && \
[ "$pkg" != "packages/metro-plugin-rnc-cli" ]; then
echo "Checking $pkg..."
npx publint "$pkg"
fi
Expand Down Expand Up @@ -134,3 +140,8 @@ jobs:
needs: checkout-install
uses: ./.github/workflows/e2e-router.yml
secrets: inherit

build-metro:
needs: checkout-install
uses: ./.github/workflows/build-metro.yml
secrets: inherit
57 changes: 57 additions & 0 deletions .github/workflows/build-metro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build Metro Packages

on:
workflow_call:

permissions:
contents: read

jobs:
build-metro:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Pnpm
run: |
corepack prepare pnpm@8.11.0 --activate
corepack enable

- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'

- name: Set Nx SHA
uses: nrwl/nx-set-shas@v3

- name: Install Dependencies
run: pnpm install

- name: Build All Required Packages
run: |
npx nx run-many --targets=build --projects=tag:type:pkg,tag:type:metro --parallel=4

- name: Test Metro Packages
uses: nick-fields/retry@v3
with:
max_attempts: 2
timeout_minutes: 5
command: npx nx affected -t test --parallel=2 --exclude='*,!tag:type:metro'

- name: Lint Metro Packages
run: npx nx run-many --targets=lint --projects=tag:type:metro --parallel=2

- name: Check Metro Package Publishing Compatibility
run: |
for pkg in packages/metro-*; do
if [ -f "$pkg/package.json" ]; then
echo "Checking $pkg..."
npx publint "$pkg"
fi
done
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
run: |
git fetch origin main
npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache
npx nx run-many --targets=build --projects=tag:type:metro
ls -l packages/*/dist packages/*/package.json

- name: Release
Expand Down
15 changes: 15 additions & 0 deletions apps/modernjs-ssr/dynamic-nested-remote/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
...nxE2EPreset(__filename, { cypressDir: 'cypress' }),
baseUrl: 'http://localhost:8080',
injectDocumentDomain: true,
},
defaultCommandTimeout: 20000,
retries: {
runMode: 2,
openMode: 1,
},
});
6 changes: 6 additions & 0 deletions apps/modernjs-ssr/dynamic-nested-remote/cypress/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('ModernJS SSR Dynamic Nested Remote', () => {
it('should load the app', () => {
cy.visit('http://localhost:8080');
cy.contains('dynamic-nested-remote');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file is processed and loaded automatically before your test files.
// You can change the location of this file or turn off processing it by setting the
// "supportFile" option to false.
// You can read more here: https://on.cypress.io/configuration
4 changes: 2 additions & 2 deletions apps/modernjs-ssr/dynamic-nested-remote/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-dynamic-nested-remote",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/modernjs-ssr/modernjs-ssr-dynamic-nested-remote/src",
"sourceRoot": "apps/modernjs-ssr/dynamic-nested-remote/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["typescript"],
Expand Down Expand Up @@ -43,7 +43,7 @@
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/modernjs-ssr/modernjs-ssr-dynamic-nested-remote/cypress.config.ts",
"cypressConfig": "apps/modernjs-ssr/dynamic-nested-remote/cypress.config.ts",
"testingType": "e2e",
"baseUrl": "http://localhost:4001",
"browser": "chrome"
Expand Down
4 changes: 2 additions & 2 deletions apps/modernjs-ssr/dynamic-remote-new-version/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-dynamic-remote-new-version",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/modernjs-ssr/modernjs-ssr-dynamic-remote-new-version/src",
"sourceRoot": "apps/modernjs-ssr/dynamic-remote-new-version/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["typescript"],
Expand Down Expand Up @@ -43,7 +43,7 @@
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/modernjs-ssr/modernjs-ssr-dynamic-remote-new-version/cypress.config.ts",
"cypressConfig": "apps/modernjs-ssr/dynamic-remote-new-version/cypress.config.ts",
"testingType": "e2e",
"baseUrl": "http://localhost:4001",
"browser": "chrome"
Expand Down
1 change: 1 addition & 0 deletions apps/modernjs-ssr/dynamic-remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"types": "./dist/cjs/index.d.ts",
"devDependencies": {
"@module-federation/enhanced": "workspace:*",
"@module-federation/modern-js": "workspace:*",
"@module-federation/rsbuild-plugin": "workspace:*",
"@rsbuild/plugin-react": "^1.3.1",
"@rslib/core": "^0.9.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/modernjs-ssr/dynamic-remote/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-dynamic-remote",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/modernjs-ssr/modernjs-ssr-dynamic-remote/src",
"sourceRoot": "apps/modernjs-ssr/dynamic-remote/src",
"projectType": "application",
"tags": [],
"targets": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/modernjs-ssr/modernjs-ssr-dynamic-remote/cypress.config.ts",
"cypressConfig": "apps/modernjs-ssr/dynamic-remote/cypress.config.ts",
"testingType": "e2e",
"baseUrl": "http://localhost:4001",
"browser": "chrome"
Expand Down
2 changes: 1 addition & 1 deletion apps/modernjs-ssr/host/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-host",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/modernjs-ssr/modernjs-ssr-host/src",
"sourceRoot": "apps/modernjs-ssr/host/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["typescript"],
Expand Down
2 changes: 1 addition & 1 deletion apps/modernjs-ssr/nested-remote/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-nested-remote",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/modernjs-ssr/modernjs-ssr-nested-remote/src",
"sourceRoot": "apps/modernjs-ssr/nested-remote/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["typescript"],
Expand Down
4 changes: 2 additions & 2 deletions apps/modernjs-ssr/remote-new-version/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modernjs-ssr-remote-new-version",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/modernjs-ssr/modernjs-ssr-remote-new-version/src",
"sourceRoot": "apps/modernjs-ssr/remote-new-version/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["typescript"],
Expand Down Expand Up @@ -43,7 +43,7 @@
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/modernjs-ssr/modernjs-ssr-remote-new-version/cypress.config.ts",
"cypressConfig": "apps/modernjs-ssr/remote-new-version/cypress.config.ts",
"testingType": "e2e",
"baseUrl": "http://localhost:4001",
"browser": "chrome"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"prepare": "husky install",
"changeset": "changeset",
"build:packages": "npx nx affected -t build --parallel=10 --exclude='*,!tag:type:pkg'",
"changegen": "./changeset-gen.js --path ./packages/runtime && ./changeset-gen.js --path ./packages/runtime-core && ./changeset-gen.js --path ./packages/sdk &&./changeset-gen.js --path ./packages/cli --staged && ./changeset-gen.js --path ./packages/enhanced && ./changeset-gen.js --path ./packages/node && ./changeset-gen.js --path ./packages/data-prefetch && ./changeset-gen.js --path ./packages/nextjs-mf && ./changeset-gen.js --path ./packages/dts-plugin",
"changegen": "./changeset-gen.js --path ./packages/runtime && ./changeset-gen.js --path ./packages/runtime-core && ./changeset-gen.js --path ./packages/sdk &&./changeset-gen.js --path ./packages/cli --staged && ./changeset-gen.js --path ./packages/enhanced && ./changeset-gen.js --path ./packages/node && ./changeset-gen.js --path ./packages/data-prefetch && ./changeset-gen.js --path ./packages/nextjs-mf && ./changeset-gen.js --path ./packages/dts-plugin && ./changeset-gen.js --path ./packages/metro-core",
"commitgen:staged": "./commit-gen.js --path ./packages --staged",
"commitgen:main": "./commit-gen.js --path ./packages",
"changeset:status": "changeset status",
Expand Down
20 changes: 20 additions & 0 deletions packages/metro-core/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
]
}
},
{
"files": ["src/runtime/*.js"],
"globals": {
"__ENTRYPOINT_IMPORT__": "readonly",
"__PLUGINS__": "readonly",
"__REMOTES__": "readonly",
"__SHARED__": "readonly",
"__NAME__": "readonly",
"__SHARE_STRATEGY__": "readonly",
"__EARLY_REMOTES__": "readonly",
"__EARLY_SHARED__": "readonly",
"__EXPOSES_MAP__": "readonly",
"__DEV__": "readonly",
"__METRO_GLOBAL_PREFIX__": "readonly",
"__EARLY_MODULE_TEST__": "readonly",
"__MODULE_ID__": "readonly",
"globalThis": "readonly",
"plugins": "readonly"
}
},
{
"files": ["*.js", "*.jsx"]
}
Expand Down
9 changes: 8 additions & 1 deletion packages/metro-core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/metro-core/src",
"projectType": "library",
"tags": ["type:pkg"],
"tags": ["type:metro"],
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"cwd": "packages/metro-core",
"commands": ["pnpm build"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
Expand Down
1 change: 1 addition & 0 deletions packages/metro-core/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default defineConfig({
},
output: {
externals: ({ request }, callback) =>
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
callback(undefined, externalizeMetroImports(request!)),
},
shims: {
Expand Down
2 changes: 2 additions & 0 deletions packages/metro-core/src/babel/transformer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable no-undef */
const babelTransformer = require('__BABEL_TRANSFORMER_PATH__');
const babelPlugins = __BABEL_PLUGINS__;
/* eslint-enable no-undef */

function transform(config) {
return babelTransformer.transform({
Expand Down
5 changes: 5 additions & 0 deletions packages/metro-core/src/commands/bundle-host/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ import { saveBundleAndMap } from '../utils/save-bundle-and-map';
import type { BundleFederatedHostArgs } from './types';

declare global {
// eslint-disable-next-line no-var
var __METRO_FEDERATION_CONFIG: ModuleFederationConfigNormalized;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_ORIGINAL_ENTRY_PATH: string | undefined;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_HOST_ENTRY_PATH: string | undefined;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_REMOTE_ENTRY_PATH: string | undefined;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_MANIFEST_PATH: string | undefined;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/metro-core/src/commands/bundle-remote/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ import type { BundleFederatedRemoteArgs } from './types';
const DEFAULT_OUTPUT = 'dist';

declare global {
// eslint-disable-next-line no-var
var __METRO_FEDERATION_CONFIG: ModuleFederationConfigNormalized;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_ORIGINAL_ENTRY_PATH: string | undefined;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_REMOTE_ENTRY_PATH: string | undefined;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_MANIFEST_PATH: string | undefined;
}

Expand Down Expand Up @@ -173,6 +177,7 @@ async function bundleFederatedRemote(
// ending up in the bundles e.g. ../../node_modules/lodash.js -> shared/lodash.js
resolveRequest: (context, moduleName, platform) => {
// always defined since we define it in the MF plugin
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalResolveRequest = rawConfig.resolver!.resolveRequest!;
const res = originalResolveRequest(context, moduleName, platform);
return modulePathRemapper.remap(res);
Expand Down
5 changes: 5 additions & 0 deletions packages/metro-core/src/modules/asyncStartup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import type { Federation } from '@module-federation/runtime';
import React from 'react';

declare global {
// eslint-disable-next-line no-var
var __DEV__: boolean;
// eslint-disable-next-line no-var
var __METRO_GLOBAL_PREFIX__: string;
// eslint-disable-next-line no-var
var __FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__: boolean;
// eslint-disable-next-line no-var
var __loadBundleAsync: (entry: string) => Promise<void>;
// eslint-disable-next-line no-var
var __FEDERATION__: Federation;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/metro-core/src/modules/metroCorePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import type {
} from '@module-federation/runtime';

declare global {
// eslint-disable-next-line no-var
var __DEV__: boolean;
// eslint-disable-next-line no-var
var __METRO_GLOBAL_PREFIX__: string;
// eslint-disable-next-line no-var
var __FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__: boolean;
// eslint-disable-next-line no-var
var __loadBundleAsync: (entry: string) => Promise<void>;
// eslint-disable-next-line no-var
var __FEDERATION__: Federation;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/metro-core/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ import { getModuleFederationSerializer } from './serializer';
import { validateOptions } from './validate-options';

declare global {
// eslint-disable-next-line no-var
var __METRO_FEDERATION_CONFIG: ModuleFederationConfigNormalized;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_ORIGINAL_ENTRY_PATH: string | undefined;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_REMOTE_ENTRY_PATH: string | undefined;
// eslint-disable-next-line no-var
var __METRO_FEDERATION_MANIFEST_PATH: string | undefined;
}

Expand Down
Loading