Skip to content

Commit e40f692

Browse files
Merge pull request #240 from QwikDev/remove-dev-preload-extended
Remove dev preload
2 parents 11ef8d7 + f324719 commit e40f692

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@qwikdev/astro": patch
3+
---
4+
5+
remove dev preloader

libs/qwikdev-astro/server.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export async function renderToStaticMarkup(
7272
}
7373

7474
let html = "";
75-
const devUrls = new Set<string>();
7675

7776
const renderToStreamOpts: RenderToStreamOptions = {
7877
containerAttributes: {
@@ -83,17 +82,7 @@ export async function renderToStaticMarkup(
8382
...(isDev
8483
? {
8584
manifest: {} as QwikManifest,
86-
symbolMapper: (symbolName, mapper, parent) => {
87-
const requestUrl = new URL(this.result.request.url);
88-
const origin = requestUrl.origin;
89-
const devUrl = origin + parent + "_" + symbolName + ".js";
90-
devUrls.add(devUrl);
91-
92-
// this determines if the container is the last one
93-
renderToStreamOpts.containerAttributes!["q-astro-marker"] = "last";
94-
95-
return globalThis.symbolMapperFn(symbolName, mapper, parent);
96-
}
85+
symbolMapper: globalThis.symbolMapperFn
9786
}
9887
: {
9988
manifest: globalThis.qManifest
@@ -182,32 +171,6 @@ export async function renderToStaticMarkup(
182171

183172
await renderToStream(qwikComponentJSX, renderToStreamOpts);
184173

185-
// we only want to add the preloader script if the container is the last one
186-
if (isDev && devUrls.size > 0) {
187-
const preloaderScript = `<script q-astro-dev-preloader>
188-
window.addEventListener("load",()=>{
189-
const symbols = ${JSON.stringify(Array.from(devUrls))};
190-
symbols.forEach(symbol => {
191-
const link = document.createElement('link');
192-
link.rel = 'modulepreload';
193-
link.href = symbol;
194-
link.fetchPriority = 'low';
195-
document.head.appendChild(link);
196-
});
197-
});
198-
</script>`;
199-
200-
// if there is one container, add the preloader script to the first one
201-
if (html.includes('q-astro-marker="first"')) {
202-
html += preloaderScript;
203-
}
204-
205-
// if there is more than one container, add the preloader script to the last one
206-
if (html.includes('q-astro-marker="last"')) {
207-
html += preloaderScript;
208-
}
209-
}
210-
211174
const isClientRouter = Array.from(this.result._metadata.renderedScripts).some(
212175
(path) => path.includes("ClientRouter.astro")
213176
);

0 commit comments

Comments
 (0)