From befedb518dee9ec27db6004369e207934caac822 Mon Sep 17 00:00:00 2001 From: David Castro Date: Fri, 15 Nov 2024 00:40:32 -0700 Subject: [PATCH] remove old dynamic-remote-nodes project and replace with the new one --- dynamic-remotes-node/README.md | 7 ----- dynamic-remotes-node/app1/index.js | 23 --------------- dynamic-remotes-node/app1/noop.js | 0 dynamic-remotes-node/app1/rspack.config.js | 19 ------------ dynamic-remotes-node/app1/webpack.config.js | 20 ------------- dynamic-remotes-node/app2/expose-sample.js | 1 - dynamic-remotes-node/app2/index.js | 0 dynamic-remotes-node/app2/rspack.config.js | 22 -------------- dynamic-remotes-node/app2/webpack.config.js | 22 -------------- .../.gitignore | 0 .../dynamic-remotes-node-javascript}/.nvmrc | 0 .../README.md | 0 .../host/package-lock.json | 0 .../host/package.json | 0 .../host/src/index.js | 0 .../host/src/noop.js | 0 .../host/webpack.config.js | 0 .../package-lock.json | 0 .../package.json | 0 .../pnpm-lock.yaml | 0 .../remote/src/expose-class.js | 0 .../remote/src/expose-string.js | 0 .../remote/src/index.js | 0 .../remote/webpack.config.js | 0 dynamic-remotes-node/package.json | 29 ------------------- dynamic-remotes-node/pure-server.js | 7 ----- .../runtime-container/expose-sample.js | 1 - .../runtime-container/index.js | 3 -- .../runtime-container/rspack.config.js | 26 ----------------- .../runtime-container/webpack.config.js | 25 ---------------- 30 files changed, 205 deletions(-) delete mode 100644 dynamic-remotes-node/README.md delete mode 100644 dynamic-remotes-node/app1/index.js delete mode 100644 dynamic-remotes-node/app1/noop.js delete mode 100644 dynamic-remotes-node/app1/rspack.config.js delete mode 100644 dynamic-remotes-node/app1/webpack.config.js delete mode 100644 dynamic-remotes-node/app2/expose-sample.js delete mode 100644 dynamic-remotes-node/app2/index.js delete mode 100644 dynamic-remotes-node/app2/rspack.config.js delete mode 100644 dynamic-remotes-node/app2/webpack.config.js rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/.gitignore (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/.nvmrc (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/README.md (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/host/package-lock.json (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/host/package.json (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/host/src/index.js (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/host/src/noop.js (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/host/webpack.config.js (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/package-lock.json (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/package.json (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/pnpm-lock.yaml (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/remote/src/expose-class.js (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/remote/src/expose-string.js (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/remote/src/index.js (100%) rename {dynamic-remotes-node-javascript => dynamic-remotes-node/dynamic-remotes-node-javascript}/remote/webpack.config.js (100%) delete mode 100644 dynamic-remotes-node/package.json delete mode 100644 dynamic-remotes-node/pure-server.js delete mode 100644 dynamic-remotes-node/runtime-container/expose-sample.js delete mode 100644 dynamic-remotes-node/runtime-container/index.js delete mode 100644 dynamic-remotes-node/runtime-container/rspack.config.js delete mode 100644 dynamic-remotes-node/runtime-container/webpack.config.js diff --git a/dynamic-remotes-node/README.md b/dynamic-remotes-node/README.md deleted file mode 100644 index c943e3d586a..00000000000 --- a/dynamic-remotes-node/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Dynamic Remotes on Node - -Similar to browser side dynamic remotes. - -This allows you to dynamically load remote containers on the server. - -`pnpm run start` will initiate a build and http server, then node will execute a simple test. diff --git a/dynamic-remotes-node/app1/index.js b/dynamic-remotes-node/app1/index.js deleted file mode 100644 index fa0e4a4fd27..00000000000 --- a/dynamic-remotes-node/app1/index.js +++ /dev/null @@ -1,23 +0,0 @@ -const { loadRemote, init } = require('@module-federation/runtime'); -console.log('hello from host app1'); - -init({ - name: 'app1', - remotes: [ - { - name: 'app2', - entry: 'http://localhost:3002/remoteEntry.js', - }, - ], -}); - -loadRemote('app2/sample').then(sample => { - if (process.env.TEST) { - if (sample === 'dynamically consumed from app2') { - process.exit(0); - } else { - process.exit(1); - } - } - console.log(sample); -}); diff --git a/dynamic-remotes-node/app1/noop.js b/dynamic-remotes-node/app1/noop.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/dynamic-remotes-node/app1/rspack.config.js b/dynamic-remotes-node/app1/rspack.config.js deleted file mode 100644 index 4e3a857ac03..00000000000 --- a/dynamic-remotes-node/app1/rspack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -const { ModuleFederationPlugin } = require('@module-federation/enhanced/rspack'); -module.exports = { - entry: './index.js', - mode: 'development', - output: { - library: { type: 'commonjs-module' }, - }, - target: 'async-node', - plugins: [ - new ModuleFederationPlugin({ - remoteType: 'script', - name: 'app1', - runtimePlugins: [require.resolve('@module-federation/node/runtimePlugin')], - exposes: { - './noop': './noop.js', - }, - }), - ], -}; diff --git a/dynamic-remotes-node/app1/webpack.config.js b/dynamic-remotes-node/app1/webpack.config.js deleted file mode 100644 index bbf96600827..00000000000 --- a/dynamic-remotes-node/app1/webpack.config.js +++ /dev/null @@ -1,20 +0,0 @@ -const { UniversalFederationPlugin } = require('@module-federation/node'); -module.exports = { - entry: './index.js', - mode: 'development', - output: { - library: { type: 'commonjs-module' }, - }, - target: false, - plugins: [ - new UniversalFederationPlugin({ - remoteType: 'script', - isServer: true, - name: 'app1', - useRuntimePlugin: true, - exposes: { - './noop': './noop.js', - }, - }), - ], -}; diff --git a/dynamic-remotes-node/app2/expose-sample.js b/dynamic-remotes-node/app2/expose-sample.js deleted file mode 100644 index 1cdc3d1cf5d..00000000000 --- a/dynamic-remotes-node/app2/expose-sample.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'dynamically consumed from app2'; diff --git a/dynamic-remotes-node/app2/index.js b/dynamic-remotes-node/app2/index.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/dynamic-remotes-node/app2/rspack.config.js b/dynamic-remotes-node/app2/rspack.config.js deleted file mode 100644 index 02abd0a5e2e..00000000000 --- a/dynamic-remotes-node/app2/rspack.config.js +++ /dev/null @@ -1,22 +0,0 @@ -const { ModuleFederationPlugin } = require('@module-federation/enhanced/rspack'); -module.exports = { - entry: './index.js', - mode: 'development', - target: 'async-node', - output: { - library: { type: 'commonjs-module' }, - }, - plugins: [ - new ModuleFederationPlugin({ - remoteType: 'script', - isServer: true, - name: 'app2', - library: { type: 'commonjs-module' }, - runtimePlugins: [require.resolve('@module-federation/node/runtimePlugin')], - filename: 'remoteEntry.js', - exposes: { - './sample': './expose-sample.js', - }, - }), - ], -}; diff --git a/dynamic-remotes-node/app2/webpack.config.js b/dynamic-remotes-node/app2/webpack.config.js deleted file mode 100644 index a113ceea1e3..00000000000 --- a/dynamic-remotes-node/app2/webpack.config.js +++ /dev/null @@ -1,22 +0,0 @@ -const { UniversalFederationPlugin } = require('@module-federation/node'); -module.exports = { - entry: './index.js', - mode: 'development', - target: false, - output: { - library: { type: 'commonjs-module' }, - }, - plugins: [ - new UniversalFederationPlugin({ - remoteType: 'script', - isServer: true, - name: 'app2', - useRuntimePlugin: true, - library: { type: 'commonjs-module' }, - filename: 'remoteEntry.js', - exposes: { - './sample': './expose-sample.js', - }, - }), - ], -}; diff --git a/dynamic-remotes-node-javascript/.gitignore b/dynamic-remotes-node/dynamic-remotes-node-javascript/.gitignore similarity index 100% rename from dynamic-remotes-node-javascript/.gitignore rename to dynamic-remotes-node/dynamic-remotes-node-javascript/.gitignore diff --git a/dynamic-remotes-node-javascript/.nvmrc b/dynamic-remotes-node/dynamic-remotes-node-javascript/.nvmrc similarity index 100% rename from dynamic-remotes-node-javascript/.nvmrc rename to dynamic-remotes-node/dynamic-remotes-node-javascript/.nvmrc diff --git a/dynamic-remotes-node-javascript/README.md b/dynamic-remotes-node/dynamic-remotes-node-javascript/README.md similarity index 100% rename from dynamic-remotes-node-javascript/README.md rename to dynamic-remotes-node/dynamic-remotes-node-javascript/README.md diff --git a/dynamic-remotes-node-javascript/host/package-lock.json b/dynamic-remotes-node/dynamic-remotes-node-javascript/host/package-lock.json similarity index 100% rename from dynamic-remotes-node-javascript/host/package-lock.json rename to dynamic-remotes-node/dynamic-remotes-node-javascript/host/package-lock.json diff --git a/dynamic-remotes-node-javascript/host/package.json b/dynamic-remotes-node/dynamic-remotes-node-javascript/host/package.json similarity index 100% rename from dynamic-remotes-node-javascript/host/package.json rename to dynamic-remotes-node/dynamic-remotes-node-javascript/host/package.json diff --git a/dynamic-remotes-node-javascript/host/src/index.js b/dynamic-remotes-node/dynamic-remotes-node-javascript/host/src/index.js similarity index 100% rename from dynamic-remotes-node-javascript/host/src/index.js rename to dynamic-remotes-node/dynamic-remotes-node-javascript/host/src/index.js diff --git a/dynamic-remotes-node-javascript/host/src/noop.js b/dynamic-remotes-node/dynamic-remotes-node-javascript/host/src/noop.js similarity index 100% rename from dynamic-remotes-node-javascript/host/src/noop.js rename to dynamic-remotes-node/dynamic-remotes-node-javascript/host/src/noop.js diff --git a/dynamic-remotes-node-javascript/host/webpack.config.js b/dynamic-remotes-node/dynamic-remotes-node-javascript/host/webpack.config.js similarity index 100% rename from dynamic-remotes-node-javascript/host/webpack.config.js rename to dynamic-remotes-node/dynamic-remotes-node-javascript/host/webpack.config.js diff --git a/dynamic-remotes-node-javascript/package-lock.json b/dynamic-remotes-node/dynamic-remotes-node-javascript/package-lock.json similarity index 100% rename from dynamic-remotes-node-javascript/package-lock.json rename to dynamic-remotes-node/dynamic-remotes-node-javascript/package-lock.json diff --git a/dynamic-remotes-node-javascript/package.json b/dynamic-remotes-node/dynamic-remotes-node-javascript/package.json similarity index 100% rename from dynamic-remotes-node-javascript/package.json rename to dynamic-remotes-node/dynamic-remotes-node-javascript/package.json diff --git a/dynamic-remotes-node-javascript/pnpm-lock.yaml b/dynamic-remotes-node/dynamic-remotes-node-javascript/pnpm-lock.yaml similarity index 100% rename from dynamic-remotes-node-javascript/pnpm-lock.yaml rename to dynamic-remotes-node/dynamic-remotes-node-javascript/pnpm-lock.yaml diff --git a/dynamic-remotes-node-javascript/remote/src/expose-class.js b/dynamic-remotes-node/dynamic-remotes-node-javascript/remote/src/expose-class.js similarity index 100% rename from dynamic-remotes-node-javascript/remote/src/expose-class.js rename to dynamic-remotes-node/dynamic-remotes-node-javascript/remote/src/expose-class.js diff --git a/dynamic-remotes-node-javascript/remote/src/expose-string.js b/dynamic-remotes-node/dynamic-remotes-node-javascript/remote/src/expose-string.js similarity index 100% rename from dynamic-remotes-node-javascript/remote/src/expose-string.js rename to dynamic-remotes-node/dynamic-remotes-node-javascript/remote/src/expose-string.js diff --git a/dynamic-remotes-node-javascript/remote/src/index.js b/dynamic-remotes-node/dynamic-remotes-node-javascript/remote/src/index.js similarity index 100% rename from dynamic-remotes-node-javascript/remote/src/index.js rename to dynamic-remotes-node/dynamic-remotes-node-javascript/remote/src/index.js diff --git a/dynamic-remotes-node-javascript/remote/webpack.config.js b/dynamic-remotes-node/dynamic-remotes-node-javascript/remote/webpack.config.js similarity index 100% rename from dynamic-remotes-node-javascript/remote/webpack.config.js rename to dynamic-remotes-node/dynamic-remotes-node-javascript/remote/webpack.config.js diff --git a/dynamic-remotes-node/package.json b/dynamic-remotes-node/package.json deleted file mode 100644 index 782a6bfd4a6..00000000000 --- a/dynamic-remotes-node/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "dynamic-remotes-node", - "description": "Dynamic Remotes on server side with Node Federation", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "scripts": { - "serve": "concurrently 'serve -s app1/dist -l 3001' 'serve -s app2/dist -l 3002'", - "build:legacy": "rimraf dist/server && concurrently 'cd app1; webpack --config ./webpack.config.js' 'cd runtime-container; webpack --config ./webpack.config.js' 'cd app2; webpack --config ./webpack.config.js'", - "build": "rimraf dist/server && concurrently 'cd app1; rspack --config ./rspack.config.js' 'cd runtime-container; rspack --config ./rspack.config.js' 'cd app2; rspack --config ./rspack.config.js'", - "start:legacy": "pnpm build:legacy && concurrently 'pnpm serve' 'sleep 5 && node app1/dist/main.js'", - "start": "pnpm build && concurrently 'TEST=true pnpm serve' 'sleep 5 && node app1/dist/main.js'" - }, - "dependencies": { - "@module-federation/enhanced": "0.7.3", - "@module-federation/node": "2.6.8", - "@module-federation/runtime": "0.7.3", - "@rspack/cli": "1.1.1", - "@rspack/core": "1.1.1", - "@rspack/dev-server": "1.0.9", - "concurrently": "^8.0.1", - "rimraf": "^5.0.5", - "webpack": "5.96.1", - "webpack-cli": "^5.1.4" - }, - "devDependencies": { - "kill-port": "2.0.1" - } -} \ No newline at end of file diff --git a/dynamic-remotes-node/pure-server.js b/dynamic-remotes-node/pure-server.js deleted file mode 100644 index a77e13ef1f2..00000000000 --- a/dynamic-remotes-node/pure-server.js +++ /dev/null @@ -1,7 +0,0 @@ -// sometimes you need to access webpack internals outside of webpack itself, like in express server -const __webpack_require__ = require('./runtime-container/dist/runtime.js'); -// this gives you webpack require, you can use my utils which depend on webpack_require.l -const runtimeApiReExport = require('./runtime-container/dist/main.js'); -// this just re-exports the injectScript runtime api which uses webpack_require.l, you can use it directly outside of webpack -console.log(__webpack_require__); -console.log(runtimeApiReExport); diff --git a/dynamic-remotes-node/runtime-container/expose-sample.js b/dynamic-remotes-node/runtime-container/expose-sample.js deleted file mode 100644 index 1cdc3d1cf5d..00000000000 --- a/dynamic-remotes-node/runtime-container/expose-sample.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'dynamically consumed from app2'; diff --git a/dynamic-remotes-node/runtime-container/index.js b/dynamic-remotes-node/runtime-container/index.js deleted file mode 100644 index 205b02aa136..00000000000 --- a/dynamic-remotes-node/runtime-container/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { loadRemote } from '@module-federation/runtime'; - -export default loadRemote(); diff --git a/dynamic-remotes-node/runtime-container/rspack.config.js b/dynamic-remotes-node/runtime-container/rspack.config.js deleted file mode 100644 index 7a731d63cf5..00000000000 --- a/dynamic-remotes-node/runtime-container/rspack.config.js +++ /dev/null @@ -1,26 +0,0 @@ -const { ModuleFederationPlugin } = require('@module-federation/enhanced/rspack'); - -module.exports = { - entry: './index.js', - mode: 'development', - target: 'async-node', - output: { - library: { type: 'commonjs-module' }, - }, - optimization: { - runtimeChunk: 'single', - }, - plugins: [ - new ModuleFederationPlugin({ - remoteType: 'script', - isServer: true, - name: 'app2', - library: { type: 'commonjs-module' }, - runtimePlugins: [require.resolve('@module-federation/node/runtimePlugin')], - filename: 'remoteEntry.js', - exposes: { - './sample': './expose-sample.js', - }, - }), - ], -}; diff --git a/dynamic-remotes-node/runtime-container/webpack.config.js b/dynamic-remotes-node/runtime-container/webpack.config.js deleted file mode 100644 index 91b8aff90cd..00000000000 --- a/dynamic-remotes-node/runtime-container/webpack.config.js +++ /dev/null @@ -1,25 +0,0 @@ -const { UniversalFederationPlugin } = require('@module-federation/node'); -module.exports = { - entry: './index.js', - mode: 'development', - target: false, - output: { - library: { type: 'commonjs-module' }, - }, - optimization: { - runtimeChunk: 'single', - }, - plugins: [ - new UniversalFederationPlugin({ - remoteType: 'script', - isServer: true, - name: 'app2', - useRuntimePlugin: true, - library: { type: 'commonjs-module' }, - filename: 'remoteEntry.js', - exposes: { - './sample': './expose-sample.js', - }, - }), - ], -};