Repository navigation
bundler(html): rewrite prefetch/modulepreload/preload link hrefs #36013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
d69df4e
d0bf2cd
7d9594d
443f7a3
2bd81d6
20de21f
5d17bb2
6e0a405
cd9d285
edc3f02
2d2add3
378ad58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6273,6 +6273,15 @@ | |
| && (import_record.loader.is_none() | ||
| || import_record.loader.unwrap() == Loader::Html) | ||
| { | ||
| if import_record | ||
| .flags | ||
| .contains(bun_ast::ImportRecordFlags::WAS_HTML_RESOURCE_HINT) | ||
| { | ||
| // <link rel="prefetch" href="./page2.html"> and similar | ||
| // hints are fetch-only; leave the href untouched. | ||
|
robobun marked this conversation as resolved.
Resolved
|
||
| import_record.path.is_disabled = true; | ||
| continue 'outer; | ||
| } | ||
|
robobun marked this conversation as resolved.
Resolved
|
||
| // This use case is currently not supported. This error | ||
| // blocks an assertion failure because the DevServer | ||
| // reserves the HTML file's spot in IncrementalGraph for the | ||
|
|
@@ -6356,10 +6365,13 @@ | |
| // Only do this for HTML sources — CSS url() imports should retain their original behavior. | ||
| if loader == Loader::Html | ||
| && import_record.kind == ImportKind::Url | ||
| && !resolved_loader.should_copy_for_bundling() | ||
| && !resolved_loader.is_javascript_like() | ||
| && !resolved_loader.is_css() | ||
| && resolved_loader != Loader::Html | ||
| && (resolved_loader != Loader::Html | ||
| || import_record | ||
| .flags | ||
| .contains(bun_ast::ImportRecordFlags::WAS_HTML_RESOURCE_HINT)) | ||
|
Check failure on line 6374 in src/bundler/bundle_v2.rs
|
||
|
Comment on lines
6368
to
+6374
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 The new Extended reasoning...What the bug isThe four new If a bundled JS module later does Why it's a regression introduced by this PRThe override at 6366-6377 itself is unchanged from The pre-existing Step-by-step proof<!-- index.html -->
<head>
<link rel="preload" as="fetch" href="./data.json" crossorigin>
</head>
<body><script type="module" src="./main.js"></script></body>// main.js
import data from "./data.json";
console.log(data.k);// data.json
{"k":1}
Why existing code doesn't prevent it
ImpactSilent behavioral change: a JSON/TOML/text import that returned a parsed value on How to fixEither exclude data loaders from the override the same way JS/CSS are excluded (but then a hint-only
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified. This is the JSON/TOML/text sibling of the first-wins loader-pinning interaction the PR already documents under Trade-off for JS targets, and it is triggered by the pre-existing
robobun marked this conversation as resolved.
Resolved
|
||
| { | ||
| break 'brk Loader::File; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.