external-remotes-plugin icon indicating copy to clipboard operation
external-remotes-plugin copied to clipboard

webpack5 cache create failed

Open OckhamRazor opened this issue 4 years ago • 7 comments

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))
);

OckhamRazor avatar Aug 12 '21 10:08 OckhamRazor

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

frost555 avatar Oct 11 '21 19:10 frost555

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

luisxiaomai avatar Jul 18 '22 10:07 luisxiaomai

I also encountered this problem, have you solved it?

AboyL avatar Nov 22 '22 11:11 AboyL

@AboyL Is there already a solution?

major2017 avatar Feb 23 '23 21:02 major2017

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.

Fernando-Espinosa avatar Mar 01 '23 16:03 Fernando-Espinosa

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

sourcegiegie avatar Aug 16 '23 02:08 sourcegiegie

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

AboyL avatar Aug 16 '23 02:08 AboyL