Skip to content

can use cache when use external-remotes-plugin #2449

Closed
@AboyL

Description

@AboyL

When I use the persistent cache while using the external-remotes-plugin plugin, the persistent cache cannot be generated correctly。

example

    new ModuleFederationPlugin({
      name: 'test',
      filename: 'remoteEntry.js',
      remotes: {
        antd: `antd@[window.antdUrl]/remoteEntry.js`,
      },
      shared: {
        react: {
          singleton: true, // only a single version of the shared module is allowed
        },
        "react-dom": {
          requiredVersion: deps["react-dom"],
          singleton: true, // only a single version of the shared module is allowed
        },
      },
    }),
    // Caching cannot be generated using this plugin
    new ExternalTemplateRemotesPlugin(),

node_modules.cache\webpack\default-development can`t generate。
If I comment this line of code, then it generates。
i have a example in
https://github.com/AboyL/demo/tree/main/dynamic-remotes

you can implement

yarn && yarn start
reproduce this bug。

The reason for this bug is because there is no No serializer registered for RawSource。

you can open dynamic-remotes\node_modules\webpack\lib\serialization\ObjectMiddleware.js and add change

			write(value, key) {
				try {
					process(value);
				} catch (e) {
					if (e !== NOT_SERIALIZABLE) {
						if (hasDebugInfoAttached === undefined)
							hasDebugInfoAttached = new WeakSet();
						if (!hasDebugInfoAttached.has(e)) {
							e.message += `\nwhile serializing ${stackToString(value)}`;
							hasDebugInfoAttached.add(e);
						}
					}
					throw e;
				}
			},

to

			write(value, key) {
				try {
					process(value);
				} catch (e) {
                                         console.error('err',err);
					if (e !== NOT_SERIALIZABLE) {
						if (hasDebugInfoAttached === undefined)
							hasDebugInfoAttached = new WeakSet();
						if (!hasDebugInfoAttached.has(e)) {
							e.message += `\nwhile serializing ${stackToString(value)}`;
							hasDebugInfoAttached.add(e);
						}
					}
					throw e;
				}
			},

find this error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions