Skip to content

Commit

Permalink
fix: update preload type
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Feb 5, 2024
1 parent 0198667 commit d2070a3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
exports[`preload-remote inBrowser > 1 preload with default config 1`] = `
{
"links": [
{
"href": "http://localhost:1111/resources/preload/preload-resource/button.sync.js",
"rel": "preload",
"type": "script",
},
{
"href": "http://localhost:1111/resources/preload/preload-resource/sub1-button/button.sync.js",
"rel": "preload",
"type": "script",
},
{
"href": "http://localhost:1111/resources/preload/preload-resource/button.sync.css",
"rel": "preload",
"type": "style",
},
],
Expand All @@ -17,14 +28,6 @@ exports[`preload-remote inBrowser > 1 preload with default config 1`] = `
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub1-button/federation-remote-entry.js",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/button.sync.js",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub1-button/button.sync.js",
},
],
}
`;
Expand All @@ -33,78 +36,90 @@ exports[`preload-remote inBrowser > 2 preload with all config 1`] = `
{
"links": [
{
"href": "http://localhost:1111/resources/preload/preload-resource/sub2/button.async.css",
"type": "style",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2/button.async.js",
"rel": "preload",
"type": "script",
},
{
"href": "http://localhost:1111/resources/preload/preload-resource/sub2/button.sync.css",
"type": "style",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2/button.sync.js",
"rel": "preload",
"type": "script",
},
],
"scripts": [
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2/federation-remote-entry.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2-button/button.async.js",
"rel": "preload",
"type": "script",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2-button/federation-remote-entry.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2-button/button.sync.js",
"rel": "preload",
"type": "script",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2/button.async.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2-add/add.async.js",
"rel": "preload",
"type": "script",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2/button.sync.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2-add/add.sync.js",
"rel": "preload",
"type": "script",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2-button/button.async.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2/button.async.css",
"rel": "preload",
"type": "style",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2-button/button.sync.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub2/button.sync.css",
"rel": "preload",
"type": "style",
},
],
"scripts": [
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2-add/add.async.js",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2/federation-remote-entry.js",
},
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2-add/add.sync.js",
"src": "http://localhost:1111/resources/preload/preload-resource/sub2-button/federation-remote-entry.js",
},
],
}
`;

exports[`preload-remote inBrowser > 3 preload with expose config 1`] = `
{
"links": [],
"scripts": [
"links": [
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/federation-remote-entry.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub3/add.sync.js",
"rel": "preload",
"type": "script",
},
],
"scripts": [
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/add.sync.js",
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/federation-remote-entry.js",
},
],
}
`;

exports[`preload-remote inBrowser > 3 preload with expose config 2`] = `
{
"links": [],
"scripts": [
"links": [
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/federation-remote-entry.js",
"href": "http://localhost:1111/resources/preload/preload-resource/sub3/add.sync.js",
"rel": "preload",
"type": "script",
},
],
"scripts": [
{
"crossorigin": "",
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/add.sync.js",
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/federation-remote-entry.js",
},
],
}
Expand Down
1 change: 1 addition & 0 deletions packages/runtime/__tests__/preload-remote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function getLinkInfos(): Array<LinkInfo> {
const linkInfos: Array<LinkInfo> = [...links].map((link) => ({
type: link.getAttribute('as') || '',
href: link.getAttribute('href') || '',
rel: link.getAttribute('rel') || '',
}));
return linkInfos;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/utils/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function preloadAssets(
},
{
rel: 'preload',
as: 'style',
as: 'script',
},
(url: string) => {
const res = host.loaderHook.lifecycle.createLink.emit({
Expand Down

0 comments on commit d2070a3

Please sign in to comment.