diff --git a/apps/manifest-demo/webpack-host/webpack.config.js b/apps/manifest-demo/webpack-host/webpack.config.js index b9efd43734a..835a911b453 100644 --- a/apps/manifest-demo/webpack-host/webpack.config.js +++ b/apps/manifest-demo/webpack-host/webpack.config.js @@ -44,11 +44,10 @@ module.exports = composePlugins(withNx(), withReact(), (config, context) => { }, }, dataPrefetch: true, - // experiments: { federationRuntime: 'hoisted' }, runtimePlugins: [path.join(__dirname, './runtimePlugin.ts')], experiments: { provideExternalRuntime: true, - federationRuntime: 'hoisted', + asyncStartup: true, }, }), ); @@ -61,6 +60,7 @@ module.exports = composePlugins(withNx(), withReact(), (config, context) => { }); if (config.devServer) { config.devServer.client.overlay = false; + config.devServer.devMiddleware.writeToDisk = true; } config.entry = './src/index.tsx'; //Temporary workaround - https://github.com/nrwl/nx/issues/16983 diff --git a/apps/modernjs/modern.config.ts b/apps/modernjs/modern.config.ts index 9736d3dd2cc..6d4c62fc090 100644 --- a/apps/modernjs/modern.config.ts +++ b/apps/modernjs/modern.config.ts @@ -41,6 +41,9 @@ export default defineConfig({ './react-component': './src/components/react-component.tsx', }, runtimePlugins: ['./runtimePlugin.ts'], + experiments: { + asyncStartup: true, + }, filename: 'remoteEntry.js', shared: { 'react/': { @@ -60,9 +63,6 @@ export default defineConfig({ requiredVersion: '^18.3.1', }, }, - experiments: { - federationRuntime: 'hoisted', - }, dataPrefetch: true, }) as any, ]); diff --git a/apps/next-app-router-4000/.env b/apps/next-app-router-4000/.env new file mode 100644 index 00000000000..70b0efc2843 --- /dev/null +++ b/apps/next-app-router-4000/.env @@ -0,0 +1,2 @@ +NEXT_PRIVATE_LOCAL_WEBPACK=true +NODE_OPTIONS="--experimental-vm-modules" diff --git a/apps/next-app-router-4001/.env b/apps/next-app-router-4001/.env new file mode 100644 index 00000000000..70b0efc2843 --- /dev/null +++ b/apps/next-app-router-4001/.env @@ -0,0 +1,2 @@ +NEXT_PRIVATE_LOCAL_WEBPACK=true +NODE_OPTIONS="--experimental-vm-modules" diff --git a/apps/runtime-demo/3005-runtime-host/webpack.config.js b/apps/runtime-demo/3005-runtime-host/webpack.config.js index 55ea77ae395..05b99f7e4b7 100644 --- a/apps/runtime-demo/3005-runtime-host/webpack.config.js +++ b/apps/runtime-demo/3005-runtime-host/webpack.config.js @@ -16,7 +16,7 @@ module.exports = composePlugins(withNx(), withReact(), (config, context) => { config.plugins.push( new ModuleFederationPlugin({ name: 'runtime_host', - experiments: { federationRuntime: 'hoisted' }, + experiments: { asyncStartup: true }, remotes: { // remote2: 'runtime_remote2@http://localhost:3007/remoteEntry.js', remote1: 'runtime_remote1@http://127.0.0.1:3006/mf-manifest.json', diff --git a/apps/runtime-demo/3006-runtime-remote/webpack.config.js b/apps/runtime-demo/3006-runtime-remote/webpack.config.js index e710efebfd2..29cde381cb3 100644 --- a/apps/runtime-demo/3006-runtime-remote/webpack.config.js +++ b/apps/runtime-demo/3006-runtime-remote/webpack.config.js @@ -39,6 +39,9 @@ module.exports = composePlugins( './WebpackPng': './src/components/WebpackPng', }, shareStrategy: 'loaded-first', + experiments: { + asyncStartup: true, + }, shared: { lodash: { singleton: true, diff --git a/packages/enhanced/src/lib/container/ContainerEntryDependency.ts b/packages/enhanced/src/lib/container/ContainerEntryDependency.ts index 6552f89e5e5..9209aafc9df 100644 --- a/packages/enhanced/src/lib/container/ContainerEntryDependency.ts +++ b/packages/enhanced/src/lib/container/ContainerEntryDependency.ts @@ -20,8 +20,6 @@ class ContainerEntryDependency extends Dependency { public exposes: [string, ExposeOptions][]; public shareScope: string; public injectRuntimeEntry: string; - /** Additional experimental options for container plugin customization */ - public experiments: containerPlugin.ContainerPluginOptions['experiments']; public dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch']; /** @@ -29,7 +27,6 @@ class ContainerEntryDependency extends Dependency { * @param {[string, ExposeOptions][]} exposes list of exposed modules * @param {string} shareScope name of the share scope * @param {string[]} injectRuntimeEntry the path of injectRuntime file. - * @param {containerPlugin.ContainerPluginOptions['experiments']} experiments additional experiments options * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch */ constructor( @@ -37,7 +34,6 @@ class ContainerEntryDependency extends Dependency { exposes: [string, ExposeOptions][], shareScope: string, injectRuntimeEntry: string, - experiments: containerPlugin.ContainerPluginOptions['experiments'], dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'], ) { super(); @@ -45,7 +41,6 @@ class ContainerEntryDependency extends Dependency { this.exposes = exposes; this.shareScope = shareScope; this.injectRuntimeEntry = injectRuntimeEntry; - this.experiments = experiments; this.dataPrefetch = dataPrefetch; } diff --git a/packages/enhanced/src/lib/container/ContainerEntryModule.ts b/packages/enhanced/src/lib/container/ContainerEntryModule.ts index 58e2461b2c0..7bcd0cf139c 100644 --- a/packages/enhanced/src/lib/container/ContainerEntryModule.ts +++ b/packages/enhanced/src/lib/container/ContainerEntryModule.ts @@ -64,7 +64,6 @@ class ContainerEntryModule extends Module { private _exposes: [string, ExposeOptions][]; private _shareScope: string; private _injectRuntimeEntry: string; - private _experiments: containerPlugin.ContainerPluginOptions['experiments']; private _dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch']; /** @@ -72,7 +71,6 @@ class ContainerEntryModule extends Module { * @param {[string, ExposeOptions][]} exposes list of exposed modules * @param {string} shareScope name of the share scope * @param {string} injectRuntimeEntry the path of injectRuntime file. - * @param {containerPlugin.ContainerPluginOptions['experiments']} experiments additional experiments options * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch */ constructor( @@ -80,7 +78,6 @@ class ContainerEntryModule extends Module { exposes: [string, ExposeOptions][], shareScope: string, injectRuntimeEntry: string, - experiments: containerPlugin.ContainerPluginOptions['experiments'], dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'], ) { super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null); @@ -88,7 +85,6 @@ class ContainerEntryModule extends Module { this._exposes = exposes; this._shareScope = shareScope; this._injectRuntimeEntry = injectRuntimeEntry; - this._experiments = experiments; this._dataPrefetch = dataPrefetch; } @@ -104,7 +100,6 @@ class ContainerEntryModule extends Module { read(), read(), read(), - read(), ); obj.deserialize(context); return obj; @@ -122,7 +117,7 @@ class ContainerEntryModule extends Module { override identifier(): string { return `container entry (${this._shareScope}) ${JSON.stringify( this._exposes, - )} ${this._injectRuntimeEntry} ${JSON.stringify(this._experiments)} ${JSON.stringify(this._dataPrefetch)}`; + )} ${this._injectRuntimeEntry} ${JSON.stringify(this._dataPrefetch)}`; } /** * @param {RequestShortener} requestShortener the request shortener @@ -203,9 +198,8 @@ class ContainerEntryModule extends Module { ) as unknown as Dependency, ); - if (!this._experiments?.federationRuntime) { - this.addDependency(new EntryDependency(this._injectRuntimeEntry)); - } + this.addDependency(new EntryDependency(this._injectRuntimeEntry)); + callback(); } @@ -272,18 +266,6 @@ class ContainerEntryModule extends Module { )}`, ); } - const initRuntimeDep = this.dependencies[1]; - // no runtime module getter needed if runtime is hoisted - const initRuntimeModuleGetter = this._experiments?.federationRuntime - ? '' - : runtimeTemplate.moduleRaw({ - module: moduleGraph.getModule(initRuntimeDep), - chunkGraph, - // @ts-expect-error flaky type definition for Dependency - request: initRuntimeDep.userRequest, - weak: false, - runtimeRequirements, - }); const federationGlobal = getFederationGlobalScope( RuntimeGlobals || ({} as typeof RuntimeGlobals), ); @@ -326,7 +308,6 @@ class ContainerEntryModule extends Module { ], )};`, this._dataPrefetch ? PrefetchPlugin.setRemoteIdentifier() : '', - `${initRuntimeModuleGetter}`, this._dataPrefetch ? PrefetchPlugin.removeRemoteIdentifier() : '', '// This exports getters to disallow modifications', `${RuntimeGlobals.definePropertyGetters}(exports, {`, @@ -366,7 +347,6 @@ class ContainerEntryModule extends Module { write(this._exposes); write(this._shareScope); write(this._injectRuntimeEntry); - write(this._experiments); write(this._dataPrefetch); super.serialize(context); } diff --git a/packages/enhanced/src/lib/container/ContainerEntryModuleFactory.ts b/packages/enhanced/src/lib/container/ContainerEntryModuleFactory.ts index 56a33c33397..abb1c1bbb0f 100644 --- a/packages/enhanced/src/lib/container/ContainerEntryModuleFactory.ts +++ b/packages/enhanced/src/lib/container/ContainerEntryModuleFactory.ts @@ -38,7 +38,6 @@ export default class ContainerEntryModuleFactory extends ModuleFactory { dep.exposes, dep.shareScope, dep.injectRuntimeEntry, - dep.experiments, dep.dataPrefetch, ), }); diff --git a/packages/enhanced/src/lib/container/ContainerPlugin.ts b/packages/enhanced/src/lib/container/ContainerPlugin.ts index 0a5c5339445..25a3db206aa 100644 --- a/packages/enhanced/src/lib/container/ContainerPlugin.ts +++ b/packages/enhanced/src/lib/container/ContainerPlugin.ts @@ -68,7 +68,6 @@ class ContainerPlugin { }), ), runtimePlugins: options.runtimePlugins, - experiments: options.experiments, dataPrefetch: options.dataPrefetch, }; } @@ -205,7 +204,6 @@ class ContainerPlugin { exposes, shareScope, federationRuntimePluginInstance.entryFilePath, - this._options.experiments, this._options.dataPrefetch, ); dep.loc = { name }; @@ -284,7 +282,6 @@ class ContainerPlugin { exposes, shareScope, federationRuntimePluginInstance.entryFilePath, - this._options.experiments, this._options.dataPrefetch, ); diff --git a/packages/enhanced/src/lib/container/ModuleFederationPlugin.ts b/packages/enhanced/src/lib/container/ModuleFederationPlugin.ts index 3dd5dbb9e1d..53f69507ee8 100644 --- a/packages/enhanced/src/lib/container/ModuleFederationPlugin.ts +++ b/packages/enhanced/src/lib/container/ModuleFederationPlugin.ts @@ -93,8 +93,10 @@ class ModuleFederationPlugin implements WebpackPluginInstance { }).apply(compiler); } - if (options.experiments?.federationRuntime) { - new FederationModulesPlugin().apply(compiler); + // federation hooks + new FederationModulesPlugin().apply(compiler); + + if (options.experiments?.asyncStartup) { new StartupChunkDependenciesPlugin({ asyncChunkLoading: true, }).apply(compiler); @@ -158,7 +160,6 @@ class ModuleFederationPlugin implements WebpackPluginInstance { shareScope: options.shareScope, exposes: options.exposes!, runtimePlugins: options.runtimePlugins, - experiments: options.experiments, }).apply(compiler); } if ( diff --git a/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts b/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts index 6d9c6667b41..bd8bf6bd2d7 100644 --- a/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts +++ b/packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts @@ -167,6 +167,7 @@ class FederationRuntimePlugin { ); return path.join(TEMP_DIR, `entry.${hash}.js`); } + getFilePath(compiler: Compiler) { if (this.entryFilePath) { return this.entryFilePath; @@ -195,6 +196,7 @@ class FederationRuntimePlugin { } return this.entryFilePath; } + ensureFile(compiler: Compiler) { if (!this.options) { return; @@ -237,61 +239,38 @@ class FederationRuntimePlugin { this.ensureFile(compiler); } - //if using runtime experiment, use the new include method else patch entry - if (this.options?.experiments?.federationRuntime) { - compiler.hooks.thisCompilation.tap( - this.constructor.name, - (compilation: Compilation, { normalModuleFactory }) => { - compilation.dependencyFactories.set( - FederationRuntimeDependency, - normalModuleFactory, - ); - compilation.dependencyTemplates.set( - FederationRuntimeDependency, - new ModuleDependency.Template(), - ); - }, - ); - compiler.hooks.make.tapAsync( - this.constructor.name, - (compilation: Compilation, callback) => { - const federationRuntimeDependency = this.getDependency(compiler); - const hooks = - FederationModulesPlugin.getCompilationHooks(compilation); - compilation.addInclude( - compiler.context, - federationRuntimeDependency, - { name: undefined }, - (err, module) => { - if (err) { - return callback(err); - } - hooks.addFederationRuntimeModule.call( - federationRuntimeDependency, - ); - callback(); - }, - ); - }, - ); - } else { - const entryFilePath = this.getFilePath(compiler); - modifyEntry({ - compiler, - prependEntry: (entry: Record) => { - Object.keys(entry).forEach((entryName) => { - const entryItem = entry[entryName]; - if (!entryItem.import) { - // TODO: maybe set this variable as constant is better https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L176 - entryItem.import = ['./src']; - } - if (!entryItem.import.includes(entryFilePath)) { - entryItem.import.unshift(entryFilePath); + compiler.hooks.thisCompilation.tap( + this.constructor.name, + (compilation: Compilation, { normalModuleFactory }) => { + compilation.dependencyFactories.set( + FederationRuntimeDependency, + normalModuleFactory, + ); + compilation.dependencyTemplates.set( + FederationRuntimeDependency, + new ModuleDependency.Template(), + ); + }, + ); + compiler.hooks.make.tapAsync( + this.constructor.name, + (compilation: Compilation, callback) => { + const federationRuntimeDependency = this.getDependency(compiler); + const hooks = FederationModulesPlugin.getCompilationHooks(compilation); + compilation.addInclude( + compiler.context, + federationRuntimeDependency, + { name: undefined }, + (err, module) => { + if (err) { + return callback(err); } - }); - }, - }); - } + hooks.addFederationRuntimeModule.call(federationRuntimeDependency); + callback(); + }, + ); + }, + ); } injectRuntime(compiler: Compiler) { @@ -360,14 +339,12 @@ class FederationRuntimePlugin { setRuntimeAlias(compiler: Compiler) { const { experiments, implementation } = this.options || {}; - const isHoisted = experiments?.federationRuntime === 'hoisted'; - let runtimePath = isHoisted ? EmbeddedRuntimePath : RuntimePath; + let runtimePath = EmbeddedRuntimePath; if (implementation) { - runtimePath = require.resolve( - `@module-federation/runtime${isHoisted ? '/embedded' : ''}`, - { paths: [implementation] }, - ); + runtimePath = require.resolve(`@module-federation/runtime/embedded`, { + paths: [implementation], + }); } const alias: any = compiler.options.resolve.alias || {}; @@ -432,24 +409,22 @@ class FederationRuntimePlugin { ); } - if (this.options?.experiments?.federationRuntime === 'hoisted') { - new EmbedFederationRuntimePlugin().apply(compiler); + new EmbedFederationRuntimePlugin().apply(compiler); - new HoistContainerReferences().apply(compiler); + new HoistContainerReferences().apply(compiler); - new compiler.webpack.NormalModuleReplacementPlugin( - /@module-federation\/runtime/, - (resolveData) => { - if (/webpack-bundler-runtime/.test(resolveData.contextInfo.issuer)) { - resolveData.request = RuntimePath; + new compiler.webpack.NormalModuleReplacementPlugin( + /@module-federation\/runtime/, + (resolveData) => { + if (/webpack-bundler-runtime/.test(resolveData.contextInfo.issuer)) { + resolveData.request = RuntimePath; - if (resolveData.createData) { - resolveData.createData.request = resolveData.request; - } + if (resolveData.createData) { + resolveData.createData.request = resolveData.request; } - }, - ).apply(compiler); - } + } + }, + ).apply(compiler); // dont run multiple times on every apply() if (!onceForCompler.has(compiler)) { this.prependEntry(compiler); diff --git a/packages/enhanced/src/schemas/container/ContainerPlugin.check.ts b/packages/enhanced/src/schemas/container/ContainerPlugin.check.ts index c80302d72da..630147d788a 100644 --- a/packages/enhanced/src/schemas/container/ContainerPlugin.check.ts +++ b/packages/enhanced/src/schemas/container/ContainerPlugin.check.ts @@ -1,12 +1,6 @@ /* eslint-disable */ //@ts-nocheck -/* - * This file was automatically generated. - * DO NOT MODIFY BY HAND. - * Run `yarn special-lint-fix` to update - */ const r = /^(?:[A-Za-z]:[\\/]|\\\\|\/)/; - function t( r, { @@ -17,47 +11,20 @@ function t( } = {}, ) { if (!Array.isArray(r)) - return ( - (t.errors = [ - { - params: { - type: 'array', - }, - }, - ]), - !1 - ); + return (t.errors = [{ params: { type: 'array' } }]), !1; { const e = r.length; for (let n = 0; n < e; n++) { let e = r[n]; const s = 0; if ('string' != typeof e) - return ( - (t.errors = [ - { - params: { - type: 'string', - }, - }, - ]), - !1 - ); - if (e.length < 1) - return ( - (t.errors = [ - { - params: {}, - }, - ]), - !1 - ); + return (t.errors = [{ params: { type: 'string' } }]), !1; + if (e.length < 1) return (t.errors = [{ params: {} }]), !1; if (0 !== s) break; } } return (t.errors = null), !0; } - function e( r, { @@ -71,43 +38,16 @@ function e( l = 0; if (0 === l) { if (!r || 'object' != typeof r || Array.isArray(r)) - return ( - (e.errors = [ - { - params: { - type: 'object', - }, - }, - ]), - !1 - ); + return (e.errors = [{ params: { type: 'object' } }]), !1; { let s; if (void 0 === r.import && (s = 'import')) - return ( - (e.errors = [ - { - params: { - missingProperty: s, - }, - }, - ]), - !1 - ); + return (e.errors = [{ params: { missingProperty: s } }]), !1; { const s = l; for (const t in r) if ('import' !== t && 'name' !== t) - return ( - (e.errors = [ - { - params: { - additionalProperty: t, - }, - }, - ]), - !1 - ); + return (e.errors = [{ params: { additionalProperty: t } }]), !1; if (s === l) { if (void 0 !== r.import) { let s = r.import; @@ -118,17 +58,11 @@ function e( if (l == l) if ('string' == typeof s) { if (s.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === i ? (i = [r]) : i.push(r), l++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === i ? (i = [r]) : i.push(r), l++; } var p = m === l; @@ -146,9 +80,7 @@ function e( (c = c || p); } if (!c) { - const r = { - params: {}, - }; + const r = { params: {} }; return ( null === i ? (i = [r]) : i.push(r), l++, (e.errors = i), !1 ); @@ -160,16 +92,7 @@ function e( if (void 0 !== r.name) { const t = l; if ('string' != typeof r.name) - return ( - (e.errors = [ - { - params: { - type: 'string', - }, - }, - ]), - !1 - ); + return (e.errors = [{ params: { type: 'string' } }]), !1; f = t === l; } else f = !0; } @@ -178,7 +101,6 @@ function e( } return (e.errors = i), 0 === l; } - function n( r, { @@ -192,16 +114,7 @@ function n( p = 0; if (0 === p) { if (!r || 'object' != typeof r || Array.isArray(r)) - return ( - (n.errors = [ - { - params: { - type: 'object', - }, - }, - ]), - !1 - ); + return (n.errors = [{ params: { type: 'object' } }]), !1; for (const a in r) { let o = r[a]; const u = p, @@ -220,17 +133,11 @@ function n( if (p == p) if ('string' == typeof o) { if (o.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === l ? (l = [r]) : l.push(r), p++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === l ? (l = [r]) : l.push(r), p++; } if (((f = e === p), (m = m || f), !m)) { @@ -247,9 +154,7 @@ function n( } } if (!m) { - const r = { - params: {}, - }; + const r = { params: {} }; return null === l ? (l = [r]) : l.push(r), p++, (n.errors = l), !1; } if (((p = c), null !== l && (c ? (l.length = c) : (l = null)), u !== p)) @@ -258,7 +163,6 @@ function n( } return (n.errors = l), 0 === p; } - function s( r, { @@ -285,17 +189,11 @@ function s( if (l == l) if ('string' == typeof e) { if (e.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === i ? (i = [r]) : i.push(r), l++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === i ? (i = [r]) : i.push(r), l++; } var c = u === l; @@ -313,19 +211,13 @@ function s( } if (f) (l = p), null !== i && (p ? (i.length = p) : (i = null)); else { - const r = { - params: {}, - }; + const r = { params: {} }; null === i ? (i = [r]) : i.push(r), l++; } if (a !== l) break; } } else { - const r = { - params: { - type: 'array', - }, - }; + const r = { params: { type: 'array' } }; null === i ? (i = [r]) : i.push(r), l++; } var m = u === l; @@ -341,9 +233,7 @@ function s( (f = f || m); } if (!f) { - const r = { - params: {}, - }; + const r = { params: {} }; return null === i ? (i = [r]) : i.push(r), l++, (s.errors = i), !1; } return ( @@ -353,7 +243,6 @@ function s( 0 === l ); } - function a( r, { @@ -369,11 +258,7 @@ function a( let p = !1; const f = i; if ('string' != typeof r) { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === o ? (o = [r]) : o.push(r), i++; } var u = f === i; @@ -389,11 +274,7 @@ function a( 'commonjs2' !== t && 'root' !== t ) { - const r = { - params: { - additionalProperty: t, - }, - }; + const r = { params: { additionalProperty: t } }; null === o ? (o = [r]) : o.push(r), i++; break; } @@ -401,11 +282,7 @@ function a( if (void 0 !== r.amd) { const t = i; if ('string' != typeof r.amd) { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === o ? (o = [r]) : o.push(r), i++; } var c = t === i; @@ -414,11 +291,7 @@ function a( if (void 0 !== r.commonjs) { const t = i; if ('string' != typeof r.commonjs) { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === o ? (o = [r]) : o.push(r), i++; } c = t === i; @@ -427,11 +300,7 @@ function a( if (void 0 !== r.commonjs2) { const t = i; if ('string' != typeof r.commonjs2) { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === o ? (o = [r]) : o.push(r), i++; } c = t === i; @@ -440,11 +309,7 @@ function a( if (void 0 !== r.root) { const t = i; if ('string' != typeof r.root) { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === o ? (o = [r]) : o.push(r), i++; } c = t === i; @@ -453,19 +318,13 @@ function a( } } } else { - const r = { - params: { - type: 'object', - }, - }; + const r = { params: { type: 'object' } }; null === o ? (o = [r]) : o.push(r), i++; } (u = t === i), (p = p || u); } if (!p) { - const r = { - params: {}, - }; + const r = { params: {} }; return null === o ? (o = [r]) : o.push(r), i++, (a.errors = o), !1; } return ( @@ -475,7 +334,6 @@ function a( 0 === i ); } - function o( r, { @@ -493,11 +351,7 @@ function o( if (i === f) if (Array.isArray(r)) if (r.length < 1) { - const r = { - params: { - limit: 1, - }, - }; + const r = { params: { limit: 1 } }; null === a ? (a = [r]) : a.push(r), i++; } else { const t = r.length; @@ -507,28 +361,18 @@ function o( if (i === n) if ('string' == typeof t) { if (t.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === a ? (a = [r]) : a.push(r), i++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === a ? (a = [r]) : a.push(r), i++; } if (n !== i) break; } } else { - const r = { - params: { - type: 'array', - }, - }; + const r = { params: { type: 'array' } }; null === a ? (a = [r]) : a.push(r), i++; } var u = f === i; @@ -537,17 +381,11 @@ function o( if (i === t) if ('string' == typeof r) { if (r.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === a ? (a = [r]) : a.push(r), i++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === a ? (a = [r]) : a.push(r), i++; } if (((u = t === i), (p = p || u), !p)) { @@ -557,11 +395,7 @@ function o( const t = i; for (const t in r) if ('amd' !== t && 'commonjs' !== t && 'root' !== t) { - const r = { - params: { - additionalProperty: t, - }, - }; + const r = { params: { additionalProperty: t } }; null === a ? (a = [r]) : a.push(r), i++; break; } @@ -572,17 +406,11 @@ function o( if (i === e) if ('string' == typeof t) { if (t.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === a ? (a = [r]) : a.push(r), i++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === a ? (a = [r]) : a.push(r), i++; } var c = e === i; @@ -594,17 +422,11 @@ function o( if (i === e) if ('string' == typeof t) { if (t.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === a ? (a = [r]) : a.push(r), i++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === a ? (a = [r]) : a.push(r), i++; } c = e === i; @@ -625,27 +447,17 @@ function o( if (i === n) if ('string' == typeof r) { if (r.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === a ? (a = [r]) : a.push(r), i++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === a ? (a = [r]) : a.push(r), i++; } if (n !== i) break; } } else { - const r = { - params: { - type: 'array', - }, - }; + const r = { params: { type: 'array' } }; null === a ? (a = [r]) : a.push(r), i++; } var m = o === i; @@ -654,17 +466,11 @@ function o( if (i === r) if ('string' == typeof t) { if (t.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === a ? (a = [r]) : a.push(r), i++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === a ? (a = [r]) : a.push(r), i++; } (m = r === i), (s = s || m); @@ -672,9 +478,7 @@ function o( if (s) (i = n), null !== a && (n ? (a.length = n) : (a = null)); else { - const r = { - params: {}, - }; + const r = { params: {} }; null === a ? (a = [r]) : a.push(r), i++; } c = e === i; @@ -682,20 +486,14 @@ function o( } } } else { - const r = { - params: { - type: 'object', - }, - }; + const r = { params: { type: 'object' } }; null === a ? (a = [r]) : a.push(r), i++; } (u = t === i), (p = p || u); } } if (!p) { - const r = { - params: {}, - }; + const r = { params: {} }; return null === a ? (a = [r]) : a.push(r), i++, (o.errors = a), !1; } return ( @@ -705,7 +503,6 @@ function o( 0 === i ); } - function i( r, { @@ -719,29 +516,11 @@ function i( p = 0; if (0 === p) { if (!r || 'object' != typeof r || Array.isArray(r)) - return ( - (i.errors = [ - { - params: { - type: 'object', - }, - }, - ]), - !1 - ); + return (i.errors = [{ params: { type: 'object' } }]), !1; { let e; if (void 0 === r.type && (e = 'type')) - return ( - (i.errors = [ - { - params: { - missingProperty: e, - }, - }, - ]), - !1 - ); + return (i.errors = [{ params: { missingProperty: e } }]), !1; { const e = p; for (const t in r) @@ -753,41 +532,15 @@ function i( 'type' !== t && 'umdNamedDefine' !== t ) - return ( - (i.errors = [ - { - params: { - additionalProperty: t, - }, - }, - ]), - !1 - ); + return (i.errors = [{ params: { additionalProperty: t } }]), !1; if (e === p) { if (void 0 !== r.amdContainer) { let t = r.amdContainer; const e = p; if (p == p) { if ('string' != typeof t) - return ( - (i.errors = [ - { - params: { - type: 'string', - }, - }, - ]), - !1 - ); - if (t.length < 1) - return ( - (i.errors = [ - { - params: {}, - }, - ]), - !1 - ); + return (i.errors = [{ params: { type: 'string' } }]), !1; + if (t.length < 1) return (i.errors = [{ params: {} }]), !1; } var f = e === p; } else f = !0; @@ -820,27 +573,17 @@ function i( if (p === n) if ('string' == typeof r) { if (r.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === l ? (l = [r]) : l.push(r), p++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === l ? (l = [r]) : l.push(r), p++; } if (n !== p) break; } } else { - const r = { - params: { - type: 'array', - }, - }; + const r = { params: { type: 'array' } }; null === l ? (l = [r]) : l.push(r), p++; } var u = a === p; @@ -849,25 +592,17 @@ function i( if (p === r) if ('string' == typeof t) { if (t.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === l ? (l = [r]) : l.push(r), p++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === l ? (l = [r]) : l.push(r), p++; } (u = r === p), (s = s || u); } if (!s) { - const r = { - params: {}, - }; + const r = { params: {} }; return ( null === l ? (l = [r]) : l.push(r), p++, (i.errors = l), !1 ); @@ -916,28 +651,20 @@ function i( 'jsonp' !== t && 'system' !== t ) { - const r = { - params: {}, - }; + const r = { params: {} }; null === l ? (l = [r]) : l.push(r), p++; } var c = a === p; if (((s = s || c), !s)) { const r = p; if ('string' != typeof t) { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === l ? (l = [r]) : l.push(r), p++; } (c = r === p), (s = s || c); } if (!s) { - const r = { - params: {}, - }; + const r = { params: {} }; return ( null === l ? (l = [r]) : l.push(r), p++, @@ -954,14 +681,7 @@ function i( const t = p; if ('boolean' != typeof r.umdNamedDefine) return ( - (i.errors = [ - { - params: { - type: 'boolean', - }, - }, - ]), - !1 + (i.errors = [{ params: { type: 'boolean' } }]), !1 ); f = t === p; } else f = !0; @@ -975,7 +695,6 @@ function i( } return (i.errors = l), 0 === p; } - function l( t, { @@ -989,32 +708,14 @@ function l( f = 0; if (0 === f) { if (!t || 'object' != typeof t || Array.isArray(t)) - return ( - (l.errors = [ - { - params: { - type: 'object', - }, - }, - ]), - !1 - ); + return (l.errors = [{ params: { type: 'object' } }]), !1; { let n; if ( (void 0 === t.name && (n = 'name')) || (void 0 === t.exposes && (n = 'exposes')) ) - return ( - (l.errors = [ - { - params: { - missingProperty: n, - }, - }, - ]), - !1 - ); + return (l.errors = [{ params: { missingProperty: n } }]), !1; { const n = f; for (const r in t) @@ -1028,96 +729,50 @@ function l( 'runtimePlugins' !== r && 'shareScope' !== r ) - return ( - (l.errors = [ - { - params: { - additionalProperty: r, - }, - }, - ]), - !1 - ); + return (l.errors = [{ params: { additionalProperty: r } }]), !1; if (n === f) { if (void 0 !== t.experiments) { let r = t.experiments; const e = f; if (f === e) { if (!r || 'object' != typeof r || Array.isArray(r)) - return ( - (l.errors = [ - { - params: { - type: 'object', - }, - }, - ]), - !1 - ); + return (l.errors = [{ params: { type: 'object' } }]), !1; { const t = f; for (const t in r) - if ( - 'externalRuntime' !== t && - 'federationRuntime' !== t && - 'provideExternalRuntime' !== t - ) + if ('asyncStartup' !== t && 'externalRuntime' !== t) return ( - (l.errors = [ - { - params: { - additionalProperty: t, - }, - }, - ]), - !1 + (l.errors = [{ params: { additionalProperty: t } }]), !1 ); if (t === f) { - if (void 0 !== r.externalRuntime) { + if (void 0 !== r.asyncStartup) { const t = f; - if ('boolean' != typeof r.externalRuntime) - return ( - (l.errors = [ - { - params: { - type: 'boolean', - }, - }, - ]), - !1 - ); + if ('boolean' != typeof r.asyncStartup) + return (l.errors = [{ params: { type: 'boolean' } }]), !1; var u = t === f; } else u = !0; - if (u) { - if (void 0 !== r.federationRuntime) { - let t = r.federationRuntime; + if (u) + if (void 0 !== r.externalRuntime) { + let t = r.externalRuntime; const e = f, n = f; let s = !1; const a = f; - if ('hoisted' !== t) { - const r = { - params: {}, - }; + if ('provide' !== t) { + const r = { params: {} }; null === p ? (p = [r]) : p.push(r), f++; } var c = a === f; if (((s = s || c), !s)) { const r = f; if ('boolean' != typeof t) { - const r = { - params: { - type: 'boolean', - }, - }; + const r = { params: { type: 'boolean' } }; null === p ? (p = [r]) : p.push(r), f++; } (c = r === f), (s = s || c); } if (!s) { - const r = { - params: {}, - }; + const r = { params: {} }; return ( null === p ? (p = [r]) : p.push(r), f++, @@ -1129,23 +784,6 @@ function l( null !== p && (n ? (p.length = n) : (p = null)), (u = e === f); } else u = !0; - if (u) - if (void 0 !== r.provideExternalRuntime) { - const t = f; - if ('boolean' != typeof r.provideExternalRuntime) - return ( - (l.errors = [ - { - params: { - type: 'boolean', - }, - }, - ]), - !1 - ); - u = t === f; - } else u = !0; - } } } } @@ -1170,34 +808,10 @@ function l( const n = f; if (f === n) { if ('string' != typeof e) - return ( - (l.errors = [ - { - params: { - type: 'string', - }, - }, - ]), - !1 - ); + return (l.errors = [{ params: { type: 'string' } }]), !1; if (e.includes('!') || !1 !== r.test(e)) - return ( - (l.errors = [ - { - params: {}, - }, - ]), - !1 - ); - if (e.length < 1) - return ( - (l.errors = [ - { - params: {}, - }, - ]), - !1 - ); + return (l.errors = [{ params: {} }]), !1; + if (e.length < 1) return (l.errors = [{ params: {} }]), !1; } m = n === f; } else m = !0; @@ -1221,24 +835,10 @@ function l( if (f === e) { if ('string' != typeof r) return ( - (l.errors = [ - { - params: { - type: 'string', - }, - }, - ]), - !1 + (l.errors = [{ params: { type: 'string' } }]), !1 ); if (r.length < 1) - return ( - (l.errors = [ - { - params: {}, - }, - ]), - !1 - ); + return (l.errors = [{ params: {} }]), !1; } m = e === f; } else m = !0; @@ -1250,9 +850,7 @@ function l( let s = !1; const a = f; if (!1 !== r) { - const r = { - params: {}, - }; + const r = { params: {} }; null === p ? (p = [r]) : p.push(r), f++; } var y = a === f; @@ -1261,25 +859,17 @@ function l( if (f === t) if ('string' == typeof r) { if (r.length < 1) { - const r = { - params: {}, - }; + const r = { params: {} }; null === p ? (p = [r]) : p.push(r), f++; } } else { - const r = { - params: { - type: 'string', - }, - }; + const r = { params: { type: 'string' } }; null === p ? (p = [r]) : p.push(r), f++; } (y = t === f), (s = s || y); } if (!s) { - const r = { - params: {}, - }; + const r = { params: {} }; return ( null === p ? (p = [r]) : p.push(r), f++, @@ -1298,143 +888,18 @@ function l( if (f === e) { if (!Array.isArray(r)) return ( - (l.errors = [ - { - params: { - type: 'array', - }, - }, - ]), - !1 + (l.errors = [{ params: { type: 'array' } }]), !1 ); { const t = r.length; for (let e = 0; e < t; e++) { - let t = r[e]; - const n = f, - s = f; - let a = !1; - const o = f; - if (f === o) - if ('string' == typeof t) { - if (t.length < 1) { - const r = { - params: {}, - }; - null === p ? (p = [r]) : p.push(r), f++; - } - } else { - const r = { - params: { - type: 'string', - }, - }; - null === p ? (p = [r]) : p.push(r), f++; - } - var h = o === f; - if (((a = a || h), !a)) { - const r = f; - if (f === r) - if ( - t && - 'object' == typeof t && - !Array.isArray(t) - ) { - let r; - if ( - (void 0 === t.import && (r = 'import')) || - (void 0 === t.async && (r = 'async')) - ) { - const t = { - params: { - missingProperty: r, - }, - }; - null === p ? (p = [t]) : p.push(t), f++; - } else { - const r = f; - for (const r in t) - if ('async' !== r && 'import' !== r) { - const t = { - params: { - additionalProperty: r, - }, - }; - null === p ? (p = [t]) : p.push(t), - f++; - break; - } - if (r === f) { - if (void 0 !== t.async) { - const r = f; - if ('boolean' != typeof t.async) { - const r = { - params: { - type: 'boolean', - }, - }; - null === p ? (p = [r]) : p.push(r), - f++; - } - var g = r === f; - } else g = !0; - if (g) - if (void 0 !== t.import) { - let r = t.import; - const e = f; - if (f === e) - if ('string' == typeof r) { - if (r.length < 1) { - const r = { - params: {}, - }; - null === p - ? (p = [r]) - : p.push(r), - f++; - } - } else { - const r = { - params: { - type: 'string', - }, - }; - null === p - ? (p = [r]) - : p.push(r), - f++; - } - g = e === f; - } else g = !0; - } - } - } else { - const r = { - params: { - type: 'object', - }, - }; - null === p ? (p = [r]) : p.push(r), f++; - } - (h = r === f), (a = a || h); - } - if (!a) { - const r = { - params: {}, - }; + const t = f; + if ('string' != typeof r[e]) return ( - null === p ? (p = [r]) : p.push(r), - f++, - (l.errors = p), + (l.errors = [{ params: { type: 'string' } }]), !1 ); - } - if ( - ((f = s), - null !== p && (s ? (p.length = s) : (p = null)), - n !== f) - ) - break; + if (t !== f) break; } } } @@ -1447,24 +912,11 @@ function l( if (f === e) { if ('string' != typeof r) return ( - (l.errors = [ - { - params: { - type: 'string', - }, - }, - ]), + (l.errors = [{ params: { type: 'string' } }]), !1 ); if (r.length < 1) - return ( - (l.errors = [ - { - params: {}, - }, - ]), - !1 - ); + return (l.errors = [{ params: {} }]), !1; } m = e === f; } else m = !0; diff --git a/packages/enhanced/src/schemas/container/ContainerPlugin.ts b/packages/enhanced/src/schemas/container/ContainerPlugin.ts index 58747f5a66d..054903d8efc 100644 --- a/packages/enhanced/src/schemas/container/ContainerPlugin.ts +++ b/packages/enhanced/src/schemas/container/ContainerPlugin.ts @@ -1,31 +1,4 @@ //@ts-nocheck -const runtimePlugin = { - type: 'array', - items: { - anyOf: [ - { - type: 'string', - minLength: 1, - description: 'Runtime Plugin File Path.', - }, - { - type: 'object', - required: ['import', 'async'], - properties: { - import: { - type: 'string', - minLength: 1, - description: 'Runtime Plugin File Path.', - }, - async: { - type: 'boolean', - }, - }, - additionalProperties: false, - }, - ], - }, -}; export default { definitions: { @@ -330,7 +303,13 @@ export default { runtime: { $ref: '#/definitions/EntryRuntime', }, - runtimePlugins: runtimePlugin, + runtimePlugins: { + description: 'Runtime plugin file paths or package name.', + type: 'array', + items: { + type: 'string', + }, + }, shareScope: { description: "The name of the share scope which is shared with the host (defaults to 'default').", @@ -340,12 +319,12 @@ export default { experiments: { type: 'object', properties: { - federationRuntime: { - anyOf: [{ type: 'boolean' }, { enum: ['hoisted'] }], - }, externalRuntime: { anyOf: [{ type: 'boolean' }, { enum: ['provide'] }], }, + asyncStartup: { + type: 'boolean', + }, }, additionalProperties: false, }, diff --git a/packages/enhanced/src/schemas/container/ContainerReferencePlugin.check.ts b/packages/enhanced/src/schemas/container/ContainerReferencePlugin.check.ts index e0fb064b137..3da51974b41 100644 --- a/packages/enhanced/src/schemas/container/ContainerReferencePlugin.check.ts +++ b/packages/enhanced/src/schemas/container/ContainerReferencePlugin.check.ts @@ -1,10 +1,5 @@ /* eslint-disable */ //@ts-nocheck -/* - * This file was automatically generated. - * DO NOT MODIFY BY HAND. - * Run `yarn special-lint-fix` to update - */ const schema40 = { definitions: { diff --git a/packages/enhanced/src/schemas/container/ModuleFederationPlugin.check.d.ts b/packages/enhanced/src/schemas/container/ModuleFederationPlugin.check.d.ts index c278b27e3ce..2c7636fbc0b 100644 --- a/packages/enhanced/src/schemas/container/ModuleFederationPlugin.check.d.ts +++ b/packages/enhanced/src/schemas/container/ModuleFederationPlugin.check.d.ts @@ -1,8 +1,3 @@ -/* - * This file was automatically generated. - * DO NOT MODIFY BY HAND. - * Run `yarn special-lint-fix` to update - */ declare const check: ( options: import('@module-federation/sdk').moduleFederationPlugin.ModuleFederationPluginOptions, ) => boolean; diff --git a/packages/enhanced/test/ConfigTestCases.embedruntime.js b/packages/enhanced/test/ConfigTestCases.embedruntime.js index 0b1dbda4a91..05b3ab50f91 100644 --- a/packages/enhanced/test/ConfigTestCases.embedruntime.js +++ b/packages/enhanced/test/ConfigTestCases.embedruntime.js @@ -14,6 +14,6 @@ jest.resetModules(); describeCases({ name: 'ConfigTestCases', federation: { - federationRuntime: 'hoisted', + asyncStartup: true, }, }); diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts index 8aaa2e66f32..950cb70abe5 100644 --- a/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts @@ -20,7 +20,6 @@ import { validatePluginOptions, } from './validate-options'; import { - modifyEntry, applyServerPlugins, configureServerCompilerOptions, configureServerLibraryAndFilename, @@ -213,7 +212,7 @@ export class NextFederationPlugin { dts: this._options.dts ?? false, shareStrategy: this._options.shareStrategy ?? 'loaded-first', experiments: { - federationRuntime: 'hoisted', + asyncStartup: true, }, }; } diff --git a/packages/sdk/src/types/plugins/ContainerPlugin.ts b/packages/sdk/src/types/plugins/ContainerPlugin.ts index da350d51707..eb9ce04a980 100644 --- a/packages/sdk/src/types/plugins/ContainerPlugin.ts +++ b/packages/sdk/src/types/plugins/ContainerPlugin.ts @@ -99,9 +99,6 @@ export interface ContainerPluginOptions { */ runtimePlugins?: string[]; - experiments?: { - federationRuntime?: false | 'hoisted'; - }; dataPrefetch?: DataPrefetch; } /** diff --git a/packages/sdk/src/types/plugins/ModuleFederationPlugin.ts b/packages/sdk/src/types/plugins/ModuleFederationPlugin.ts index 70105e26ac5..8166d5e319b 100644 --- a/packages/sdk/src/types/plugins/ModuleFederationPlugin.ts +++ b/packages/sdk/src/types/plugins/ModuleFederationPlugin.ts @@ -236,9 +236,9 @@ export interface ModuleFederationPluginOptions { dataPrefetch?: DataPrefetch; virtualRuntimeEntry?: boolean; experiments?: { - federationRuntime?: false | 'hoisted'; externalRuntime?: boolean; provideExternalRuntime?: boolean; + asyncStartup?: boolean; }; bridge?: { /**