Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .changeset/tender-falcons-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@module-federation/enhanced': patch
'@module-federation/managers': patch
'@module-federation/runtime': patch
'@module-federation/rspack': patch
---

chore: delete references to used shared to prevent memory leaks
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ jobs:
run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx nx run-many --target=e2e --projects=3008-webpack-host --parallel=1 && lsof -ti tcp:3008,3009,3010,3011,3012 | xargs kill

- name: E2E Node Federation
run: npx nx run-many --target=serve --projects=node-local-remote,node-remote --parallel=3 & echo "done" && sleep 25 && npx nx run-many --target=serve --projects=node-host & sleep 5 && npx wait-on tcp:3333 && npx nx run node-host-e2e:test:e2e
run: npx nx run-many --target=serve --projects=node-local-remote,node-remote,node-dynamic-remote-new-version,node-dynamic-remote --parallel=10 & echo "done" && sleep 25 && npx nx run-many --target=serve --projects=node-host & sleep 5 && npx wait-on tcp:3333 && npx nx run node-host-e2e:test:e2e
11 changes: 11 additions & 0 deletions apps/node-dynamic-remote-new-version/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
18 changes: 18 additions & 0 deletions apps/node-dynamic-remote-new-version/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
11 changes: 11 additions & 0 deletions apps/node-dynamic-remote-new-version/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'node-dynamic-remote-new-version',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/node-dynamic-remote-new-version',
};
8 changes: 8 additions & 0 deletions apps/node-dynamic-remote-new-version/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "node-dynamic-remote-new-version",
"private": true,
"dependencies": {
"@module-federation/node": "workspace:*",
"lodash": "4.17.21"
}
}
101 changes: 101 additions & 0 deletions apps/node-dynamic-remote-new-version/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"name": "node-dynamic-remote-new-version",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/node-dynamic-remote-new-version/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"compiler": "babel",
"outputPath": "apps/node-dynamic-remote-new-version/dist",
"index": "apps/node-dynamic-remote-new-version/src/index.html",
"baseHref": "/",
"main": "apps/node-dynamic-remote-new-version/src/main.tsx",
"tsConfig": "apps/node-dynamic-remote-new-version/tsconfig.app.json",
"assets": [],
"styles": [],
"scripts": [],
"webpackConfig": "apps/node-dynamic-remote-new-version/webpack.config.js"
},
"configurations": {
"development": {
"extractLicenses": false,
"optimization": false,
"sourceMap": true,
"vendorChunk": true
},
"production": {
"fileReplacements": [
{
"replace": "apps/node-dynamic-remote-new-version/src/environments/environment.ts",
"with": "apps/node-dynamic-remote-new-version/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false
}
},
"dependsOn": [
{
"target": "build",
"dependencies": true
}
]
},
"serve": {
"executor": "@nx/webpack:dev-server",
"dependsOn": [
{
"target": "build",
"dependencies": true
}
],
"defaultConfiguration": "development",
"options": {
"buildTarget": "node-dynamic-remote-new-version:build",
"hmr": true,
"port": 3007
},
"configurations": {
"development": {
"buildTarget": "node-dynamic-remote-new-version:build:development"
},
"production": {
"buildTarget": "node-dynamic-remote-new-version:build:production",
"hmr": false
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"apps/node-dynamic-remote-new-version/**/*.{ts,tsx,js,jsx}"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/node-dynamic-remote-new-version/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file can be replaced during build by using the `fileReplacements` array.
// When building for production, this file is replaced with `environment.prod.ts`.

export const environment = {
production: false,
};
4 changes: 4 additions & 0 deletions apps/node-dynamic-remote-new-version/src/expose-with-axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const axios = require('axios');
module.exports = function () {
return `new version :${Object.keys(axios)}`;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const lodash = require('lodash');
module.exports = function () {
return Object.keys(lodash);
};
1 change: 1 addition & 0 deletions apps/node-dynamic-remote-new-version/src/expose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'module from node-dynamic-remote-new-version';
14 changes: 14 additions & 0 deletions apps/node-dynamic-remote-new-version/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>NODE DYNAMIC REMOTE NEW VERSION</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<div id="root"></div>
</body>
</html>
1 change: 1 addition & 0 deletions apps/node-dynamic-remote-new-version/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('test');
24 changes: 24 additions & 0 deletions apps/node-dynamic-remote-new-version/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",

"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"exclude": [
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
20 changes: 20 additions & 0 deletions apps/node-dynamic-remote-new-version/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json"
}
21 changes: 21 additions & 0 deletions apps/node-dynamic-remote-new-version/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
],
"types": ["@nx/react/typings/cssmodule.d.ts", "@nx/react/typings/image.d.ts"]
}
36 changes: 36 additions & 0 deletions apps/node-dynamic-remote-new-version/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { registerPluginTSTranspiler } = require('nx/src/utils/nx-plugin.js');

registerPluginTSTranspiler();
const { composePlugins, withNx } = require('@nx/webpack');
const { UniversalFederationPlugin } = require('@module-federation/node');

// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
// config.output.publicPath = '/remotetest'; // this breaks because of import.meta
// config.output.publicPath = 'auto';
config.target = 'node';
config.devtool = false;
config.cache = false;
if (config.mode === 'development') {
config.devServer.devMiddleware.writeToDisk = true;
}

config.plugins.push(
new UniversalFederationPlugin({
isServer: true,
name: 'node_dynamic_remote',
library: { type: 'commonjs-module' },
filename: 'remoteEntry.js',
exposes: {
'./test': './src/expose.js',
'./test-with-axios': './src/expose-with-axios.js',
'./test-with-lodash': './src/expose-with-lodash.js',
},
shared: {
axios: { singleton: true },
lodash: { singleton: true },
},
}),
);
return config;
});
11 changes: 11 additions & 0 deletions apps/node-dynamic-remote/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
18 changes: 18 additions & 0 deletions apps/node-dynamic-remote/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
11 changes: 11 additions & 0 deletions apps/node-dynamic-remote/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'node-dynamic-remote',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/node-dynamic-remote',
};
8 changes: 8 additions & 0 deletions apps/node-dynamic-remote/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "node-dynamic-remote",
"private": true,
"dependencies": {
"@module-federation/node": "workspace:*",
"lodash": "4.17.21"
}
}
Loading