Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

The modulePreloadLinkRE regex only matched self-closing <link rel="modulepreload" /> tags, failing on valid HTML without the trailing slash:

<link rel="modulepreload" crossorigin href="/assets/vendor-BAJkae7J.js">

This broke importmap ordering validation in production builds where bundlers often emit non-self-closing tags.

Changes

  • Regex pattern: Changed [\s\S]*?\/> to [^>]*> to match both <link ...> and <link ... /> formats
  • Test coverage: Updated playground/html/importmapOrder.html to include a non-self-closing modulepreload link for testing the regex fix
  • Test improvements: Updated the importmap test to verify the importmap actually works by checking module execution, rather than checking for a warning that no longer appears

The fix also resolves the regexp/optimal-quantifier-concatenation ESLint warning by removing the redundant \/? quantifier.

Original prompt

Fix this regex:

const modulePreloadLinkRE =
/[ \t]*<link[^>]*rel\s*=\s*(?:"modulepreload"|'modulepreload'|modulepreload)[\s\S]*?\/>/i

This should match <link rel="modulepreload" crossorigin href="/assets/vendor-BAJkae7J.js"> but it doesn't.
Make sure to add a test case in playground/html


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix regex to match modulepreload link tags Fix modulePreloadLinkRE to match non-self-closing link tags Dec 18, 2025
Copilot AI requested a review from sapphi-red December 18, 2025 02:22
@sapphi-red
Copy link
Member

@copilot use playground/html/importmapOrder.html for the test. Also change the test case to actually use the import map as the An import map is added after module script load was triggered. warning doesn't seem to happen anymore.

Copy link
Contributor Author

Copilot AI commented Dec 18, 2025

@copilot use playground/html/importmapOrder.html for the test. Also change the test case to actually use the import map as the An import map is added after module script load was triggered. warnin...

Done! I've updated the test to use importmapOrder.html instead of creating a new file. The test now:

  • Uses the existing importmap with a working module resolution (some-pkg/shared.js)
  • Includes a non-self-closing modulepreload link to test the regex fix
  • Verifies the importmap works by checking that /main.js executes successfully

Changes in commit 789ad73.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • vite.dev
    • Triggering command: /home/REDACTED/.cache/playwright-bin/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/playwright-bin/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AvoidUnnecessaryBeforeUnloadCheckSync,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate,AutoDeElevate,RenderD (dns block)
    • Triggering command: /home/REDACTED/.cache/playwright-bin/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/playwright-bin/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AvoidUnnecessaryBeforeUnloadCheckSync,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate,AutoDeElevate,RenderD password=$GITHUB- (dns block)
    • Triggering command: /home/REDACTED/.cache/playwright-bin/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/playwright-bin/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AvoidUnnecessaryBeforeUnloadCheckSync,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate,AutoDeElevate,RenderD 0/x64/bin/node (dns block)
  • workers.cloudflare.com
    • Triggering command: /opt/hostedtoolcache/node/24.12.0/x64/bin/node /opt/hostedtoolcache/node/24.12.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/vite/vite/node_modules/.pnpm/[email protected]_@types&#43;[email protected]/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/vite/vite/node_modules/.pnpm/[email protected]_@types&#43;[email protected]/node_modules/vitest/dist/workers/forks.js (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.12.0/x64/bin/node /opt/hostedtoolcache/node/24.12.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/vite/vite/node_modules/.pnpm/[email protected]_@types&#43;[email protected]/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/vite/vite/node_modules/.pnpm/[email protected]_@types&#43;[email protected]/node_modules/vitest/dist/workers/forks.js --require /home/REDACTED/work/vite/vite/node_modules/.pnpm/[email protected]_@types&#43;[email protected] uname (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants