Skip to content

Commit

Permalink
fix: code drift (umijs#12410)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinbao1001 authored May 22, 2024
1 parent 82910f9 commit f6abd77
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion contributors.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"qiguoq",
"AmJunh",
"MaxCDon",
"mysteryven"
"mysteryven",
"Jinbao1001"
]
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async function getRoutePathFilesMap(

export default (api: IApi) => {
let routeChunkFilesMap: IRouteChunkFilesMap;
let hashedPart = '.js';
let preloadJSFileExt = '.js';
api.describe({
enableBy: () =>
// enable when package name available
Expand Down Expand Up @@ -237,7 +237,7 @@ export default (api: IApi) => {
: // script mode
[
{
src: `${displayPublicPath}${PRELOAD_ROUTE_HELPER}${hashedPart}`,
src: `${displayPublicPath}${PRELOAD_ROUTE_HELPER}${preloadJSFileExt}`,
},
];
}
Expand Down Expand Up @@ -309,17 +309,20 @@ export default (api: IApi) => {
}"${api.config.publicPath}"`,
);
if (api.config.hash) {
hashedPart = `.${createHash('md5')
preloadJSFileExt = `.${createHash('md5')
.update(content)
.digest('hex')
.substring(0, 8)}.js`;
}

writeFileSync(
join(api.paths.absOutputPath, `${PRELOAD_ROUTE_HELPER}${hashedPart}`),
join(
api.paths.absOutputPath,
`${PRELOAD_ROUTE_HELPER}${preloadJSFileExt}`,
),
content,
),
'utf-8';
'utf-8',
);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface IPreloadRouteFile {
}

export const PRELOAD_ROUTE_MAP_SCP_TYPE = 'umi-route-chunk-files-map';
export const PRELOAD_ROUTE_HELPER = '_umi_route_preload_helper';
export const PRELOAD_ROUTE_HELPER = 'preload_helper';

export function getPreloadRouteFiles(
path: string,
Expand Down

0 comments on commit f6abd77

Please sign in to comment.