Skip to content

Commit

Permalink
chore: add license info
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy committed Oct 31, 2024
1 parent 0931fc5 commit fd07cb1
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 18 deletions.
4 changes: 4 additions & 0 deletions packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Zackary Jackson @ScriptedAlchemy
*/
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
import { moduleFederationPlugin } from '@module-federation/sdk';
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class ModuleFederationPlugin implements WebpackPluginInstance {
) {
compiler.options.output.enabledLibraryTypes?.push(library.type);
}

compiler.hooks.afterPlugins.tap('ModuleFederationPlugin', () => {
if (useContainerPlugin) {
new ContainerPlugin({
Expand Down
4 changes: 4 additions & 0 deletions packages/enhanced/src/lib/container/constant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Zackary Jackson @ScriptedAlchemy
*/
import path from 'path';
import { TEMP_DIR as BasicTempDir } from '@module-federation/sdk';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Zackary Jackson @ScriptedAlchemy
*/

// This stores the previous child compilation based solution
// it is not currently used

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Zackary Jackson @ScriptedAlchemy
*/
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
import ContainerEntryDependency from '../ContainerEntryDependency';

Expand All @@ -12,6 +16,7 @@ class EmbedFederationRuntimeModule extends RuntimeModule {
private containerEntrySet: Set<
ContainerEntryDependency | FederationRuntimeDependency
>;

constructor(
containerEntrySet: Set<
ContainerEntryDependency | FederationRuntimeDependency
Expand All @@ -20,9 +25,11 @@ class EmbedFederationRuntimeModule extends RuntimeModule {
super('embed federation', RuntimeModule.STAGE_ATTACH);
this.containerEntrySet = containerEntrySet;
}

override identifier() {
return 'webpack/runtime/embed/federation';
}

override generate(): string | null {
const { compilation, chunk, chunkGraph } = this;
if (!chunk || !chunkGraph || !compilation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import ContainerEntryDependency from '../ContainerEntryDependency';
import FederationRuntimeDependency from './FederationRuntimeDependency';

/** @type {WeakMap<import("webpack").Compilation, CompilationHooks>} */
const compilationHooksMap = new WeakMap<
import('webpack').Compilation,
CompilationHooks
>();
const compilationHooksMap = new WeakMap<CompilationType, CompilationHooks>();

const PLUGIN_NAME = 'FederationModulesPlugin';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import fs from 'fs';
import path from 'path';
import pBtoa from 'btoa';
import type {
Compiler,
WebpackPluginInstance,
Compilation,
Chunk,
} from 'webpack';
import type { EntryDescription } from 'webpack/lib/Entrypoint';
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
import { PrefetchPlugin } from '@module-federation/data-prefetch/cli';
import { moduleFederationPlugin } from '@module-federation/sdk';
Expand All @@ -15,13 +19,10 @@ import {
createHash,
normalizeToPosixPath,
} from './utils';
import fs from 'fs';
import path from 'path';
import { TEMP_DIR } from '../constant';
import EmbedFederationRuntimePlugin from './EmbedFederationRuntimePlugin';
import FederationModulesPlugin from './FederationModulesPlugin';
import HoistContainerReferences from '../HoistContainerReferencesPlugin';
import pBtoa from 'btoa';
import FederationRuntimeDependency from './FederationRuntimeDependency';

const ModuleDependency = require(
Expand Down Expand Up @@ -55,7 +56,7 @@ const EmbeddedRuntimePath = require.resolve(

const federationGlobal = getFederationGlobalScope(RuntimeGlobals);

const onceForCompler = new WeakSet();
const onceForCompler = new WeakSet<Compiler>();

class FederationRuntimePlugin {
options?: moduleFederationPlugin.ModuleFederationPluginOptions;
Expand Down Expand Up @@ -277,7 +278,7 @@ class FederationRuntimePlugin {
const entryFilePath = this.getFilePath(compiler);
modifyEntry({
compiler,
prependEntry: (entry) => {
prependEntry: (entry: Record<string, EntryDescription>) => {
Object.keys(entry).forEach((entryName) => {
const entryItem = entry[entryName];
if (!entryItem.import) {
Expand Down Expand Up @@ -397,7 +398,6 @@ class FederationRuntimePlugin {
);

if (useModuleFederationPlugin && !this.options) {
// @ts-ignore
this.options = useModuleFederationPlugin._options;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/enhanced/src/lib/container/runtime/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Zackary Jackson @ScriptedAlchemy
*/
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
import upath from 'upath';
import path from 'path';
Expand Down
1 change: 1 addition & 0 deletions packages/enhanced/src/lib/startup/StartupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const generateESMEntryStartup = (
passive: boolean,
): string => {
const { chunkHasJs, getChunkFilenameTemplate } =
compilation.compiler.webpack?.javascript?.JavascriptModulesPlugin ||
compilation.compiler.webpack.JavascriptModulesPlugin;
const { ConcatSource } = compilation.compiler.webpack.sources;
const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class InvertedContainerRuntimeModule extends RuntimeModule {
this.options = options;
}

private findEntryModuleOfContainer(): Module | undefined {
if (!this.chunk || !this.chunkGraph) return undefined;
const modules = this.chunkGraph.getChunkModules(this.chunk);
return Array.from(modules).find(
(module) => module instanceof container.ContainerEntryModule,
);
}

override generate(): string {
const { compilation, chunk, chunkGraph } = this;
if (!compilation || !chunk || !chunkGraph) {
Expand All @@ -46,6 +38,12 @@ class InvertedContainerRuntimeModule extends RuntimeModule {

if (!containerEntryModule) return '';

if (
compilation.chunkGraph.isEntryModuleInChunk(containerEntryModule, chunk)
) {
// dont apply to remote entry itself
return '';
}
const initRuntimeModuleGetter = compilation.runtimeTemplate.moduleRaw({
module: containerEntryModule,
chunkGraph,
Expand Down

0 comments on commit fd07cb1

Please sign in to comment.