module-federation / external-remotes-plugin

Dynamically set remote origins at runtime within hosts
MIT License
52 stars 9 forks source link

webpack5 cache create failed #4

Open OckhamRazor opened 3 years ago

OckhamRazor commented 3 years ago

Problem: When I set it up, I get an error.

cache: {
 type: 'filesystem'
}

Error log:

 -> RawSource
    [webpack.cache.PackFileCacheStrategy] Error: No serializer registered for RawSource

Thinking 🤔: I think it's because a new source has been replaced afterafterCodeGeneration. so can I modify it directly on the original source?

sourceMap.set(
    'javascript',
    new RawSource(rawSource.source().replace(`"${urlTemplate}"`, urlExpression))
);
frost555 commented 3 years ago

+1 persistent cache is broken that way. I worked around by using static URL in development.

luisxiaomai commented 2 years ago

@OckhamRazor @frost555 is there any workaround to leverage persistent cache with module-federation in production mode? Thanks.

AboyL commented 2 years ago

I also encountered this problem, have you solved it?

major2017 commented 1 year ago

@AboyL Is there already a solution?

Fernando-Espinosa commented 1 year ago

I'm also having this issue. When we deploy, remoteEntry.js is cached and will reference to federated modules that don't exist, giving a CORS error. I've tried Cache busting like suggested in this stackoverflow post, but that makes remoteEntry.js to return 404 not found.

sourcegiegie commented 1 year ago

synchronizing the webpack source version is sufficient to ensure consistency with the version used in the root directory webpack and avoid serialization cache not being able to correspond

AboyL commented 1 year ago

sourcegiegie

You can look at the following comments, the root cause is because webpack-sources use different objects caused by the specific solution needs to be solved according to the actual situation. We use umi system and have rewritten this plug-in, which may not be applicable to you