Skip to content

Commit 1d8c3c0

Browse files
authored
fix(mfsu): fix a cache failure caused by the getCacheDependency content containing a function (#10166)
* fix(mfsu): fix a cache failure caused by the getCacheDependency content containing a function * fix(mfsu): fix a cache failure caused by the getCacheDependency content containing a function * fix(bundler-webpack): fix a cache failure caused by the getCacheDependency content containing a function * chore: ensureSafeValue rename ensureSerializableValue
1 parent 4d28388 commit 1d8c3c0

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

  • packages/bundler-webpack/src

packages/bundler-webpack/src/dev.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,19 @@ type IOpts = {
3636
onBeforeMiddleware?: Function;
3737
} & Pick<IConfigOpts, 'cache' | 'pkg'>;
3838

39-
export function stripUndefined(obj: any) {
40-
Object.keys(obj).forEach((key) => {
41-
if (obj[key] === undefined) {
42-
delete obj[key];
43-
}
44-
});
45-
return obj;
39+
export function ensureSerializableValue(obj: any) {
40+
return JSON.parse(
41+
JSON.stringify(
42+
obj,
43+
(_key, value) => {
44+
if (typeof value === 'function') {
45+
return value.toString();
46+
}
47+
return value;
48+
},
49+
2,
50+
),
51+
);
4652
}
4753

4854
export async function dev(opts: IOpts) {
@@ -79,7 +85,7 @@ export async function dev(opts: IOpts) {
7985
remoteAliases: opts.config.mfsu?.remoteAliases,
8086
remoteName: opts.config.mfsu?.remoteName,
8187
getCacheDependency() {
82-
return stripUndefined({
88+
return ensureSerializableValue({
8389
version: require('../package.json').version,
8490
mfsu: opts.config.mfsu,
8591
alias: opts.config.alias,

0 commit comments

Comments
 (0)