Skip to content

Tech detection: three.js loaded through an import map or an inline module import is not detected #1539

Closed

Description

@nc9

Found in the v0.0.140 vs v0.0.159 corpus check for #1420 and #1422 (stored Product Hunt crawls, offline re-detect).

What happens

three.js loaded through an import map or an inline module import is not detected. v0.0.140 found it, but only by accident: on a page without attached script bodies it matched script URL patterns against the whole HTML. v0.0.150 rightly stopped doing that (it also dropped CSP, link and prose matches), and the real uses went with it.

32 sites lost threejs at that boundary. All 5 sampled are real uses, loaded in one of two ways:

  • an import map: <script type="importmap">{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@<v>/build/three.module.js","three/addons/":"..."}}</script> (4 of 5; the CDN varies: jsdelivr, unpkg, cdnjs, or a self-hosted ./vendor/three/build/three.module.js)
  • an inline module: <script type="module">import * as THREE from 'https://cdn.jsdelivr.net/npm/three@<v>/build/three.module.js'; ...</script> (1 of 5)

Neither is a <script src>, so the script-url detectors never see the URL. The same gap probably affects every library that ships as an ES module from a CDN (for example vue, react or lit through esm.sh or jsdelivr +esm).

amended 2026-11-02: of the 5 sampled sites, 4 use an import map (0.1 to 0.2 KB) and 1 an inline module of about 465 KB. Import maps are covered by #1542; the large inline module is the same question as #1540 (inline scripts over 16 KB are not read).

Expected

A URL that a page actually loads as a module counts as a script URL for detection: an imports value in a type="importmap" script, and the specifier of a static import ... from '<url>' or import('<url>') in an inline type="module" script. A URL in prose, a CSP, a link or a JSON data block still does not count.

Acceptance Criteria

nik

Activity

  1. added
    bug
    size: S
    rules
    on Nov 2, 2026
  2. added theissue type on Nov 2, 2026
  3. nc9 commented on Nov 2, 2026

    @nc9
    ContributorAuthor

    Amended criterion 3 (original text kept visible) to the behaviour the import-map fix in #1542 ships: map values are matched as written, not resolved against the page URL; only http(s), protocol-relative and /, ./, ../ paths are read, a bare name is not; keys are never read. Checked on the PR's final head: ./vendor/three/build/three.module.js, /static/three.module.js and a jsdelivr URL detect threejs; three.module.js and three/x.js are not read. No box is ticked yet: the fix is in review and not on main.

    nik

  4. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Acceptance check against main 7c31d5b. The import map fix shipped in v0.0.160 (c23c8e1, hardened by 8b97ba8, fab4d37 and 7aabe2b), all in v0.0.161.

    # Criterion Result Evidence
    1 An import map that maps three to a three.module.js URL detects threejs PASS packages/tech-detect/tests/importmap-1539.test.ts "three.js through jsdelivr, unpkg, cdnjs and a self-hosted path" (also scopes, uppercase type, several maps)
    2 An inline module under 16 KB that imports a three.module.js URL detects threejs PASS same file, "an inline module that imports a URL" (static, namespace and dynamic import())
    3 Map values matched as amended: ./, ../, /, http(s) and protocol-relative are read; a bare name, keys, data:, javascript:, blob: and unsafe characters are not PASS "three.js through ... a self-hosted path" covers ./vendor/three/build/three.module.js and /static/js/three/three.module.js; "an import map's keys, a malformed map ..." covers a vendor URL as a key with a local value; "a bare name (no scheme, no leading slash) is rejected; a path with a slash is kept". I also checked by hand on main: key-only vendor URL gives no threejs, "three": "three.module.js" gives none, ./vendor/three/build/three.module.js gives threejs.
    4 The #1437 and #1430 negatives still hold PASS script-url-inline-1430.test.ts (11 pass), script-url-wrappers-1435.test.ts (11 pass), flight-script-narrow-1437.test.ts (58 pass); importmap-1539.test.ts "what is still not a script URL" covers a CSP meta, an anchor, JSON-LD, a JSON data script, a Next data script, speculation rules and prose.
    5 On the PH corpus re-detect, threejs sites rise with no new detections from prose UNVERIFIED No corpus result is recorded on the issue or in the shipped change; the PR description left the corpus A/B for a separate run. A maintainer needs to run the re-detect and post the count and a checked sample.

    Ran on main: importmap-1539.test.ts (42 pass) and the three negative files above.

    One observation, not part of these criteria and the same on v0.0.159: a <link> of any rel (even rel="canonical") whose href is a vendor script URL still counts as a script URL for that vendor, because link hrefs are read as resources. Box 4 is ticked on the #1430 and #1437 tests, which cover anchors, meta text, JSON-LD and data blocks.

    Ticked 1 to 4; left open for 5.

    nik

  5. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Re-check against main 8d22fa2. Criteria 1 to 3 stay ticked (packages/tech-detect/tests/importmap-1539.test.ts: 42 pass, nothing in packages/tech-detect changed since the previous check). I have unticked criterion 4 and left 5 open.

    # Criterion Result Evidence
    4 A vendor URL only in a CSP meta, a <link>, JSON-LD, a JSON data script or prose is not detected FAIL (gap) JSON-LD, JSON data scripts, a CSP meta, an anchor and prose are pinned and hold (script-url-wrappers-1435.test.ts, script-url-inline-1430.test.ts, importmap-1539.test.ts "what is still not a script URL"). But the "link" in those tests is an anchor (<a href>), not a <link> element. Run on main with detectTechnologies: a page whose only vendor reference is <link rel="canonical" href="https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js"> detects threejs; so does rel="modulepreload", while an anchor and prose with the same URL do not. An existing test asserts a <link rel="preload" href> counts as a loaded resource, so this is deliberate for preload-style rels but it is not true of every <link>. Same on v0.0.159, so not a regression of the import map change.
    5 PH corpus re-detect: threejs sites rise, no new detections from prose UNVERIFIED No corpus result recorded; needs a re-detect job with a checked sample.

    To close criterion 4: either amend it to say an anchor (not a <link>) and keep the pins, or make <link> count only for resource rels (stylesheet, preload, modulepreload, prefetch, and so on) with a test that a canonical or alternate link does not. Criterion 5 needs the corpus run.

    nik

  6. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Acceptance check against main d7e9b44 (v0.0.167). Criteria 1 to 3 stay ticked.

    # Criterion Result Evidence
    4 A vendor URL only in a CSP <meta>, a <link>, JSON-LD, a JSON data script or prose is not detected NOT TICKED Fixed for describing links in v0.0.166 (7a111f6, e046df1): packages/tech-detect/tests/link-rel-1539.test.ts pins that canonical, alternate, author, license, help, next, prev, icon, manifest and a missing rel detect nothing (101 pass across this file and three others on main). But a <link> with a loading rel (stylesheet, preload, modulepreload, prefetch, prerender, preconnect, dns-prefetch) still counts as vendor evidence on purpose. The criterion says "a <link>" without that limit.
    5 PH corpus re-detect: threejs sites rise, no new detections from prose PASS Offline re-detect over stored pages of 37,248 sites: threejs 149 (v0.0.140), 194 (v0.0.164), 193 (v0.0.165). All 50 gains against v0.0.140 were checked by evidence region: 36 import-map only, 14 modulepreload or preload links or inline script loaders, 0 from prose. v0.0.165 to the v0.0.167 tip: no threejs change on a 2,795-site slice.

    Gap on criterion 4: either amend it to "a <link> whose rel does not load its resource (canonical, alternate, and the like)" and keep the pins, or decide that loading-rel links must not count (that would remove 14 of the 50 gains above). I recommend the amendment; it is the maintainer's call, so the box stays unticked.

    One observation outside the criteria: between v0.0.165 and the v0.0.167 tip the same corpus run shows 2 supabase pairs and 1 vue pair lost. The vue evidence is a link or prose (the intended change here). For the 2 supabase pairs the cause is unresolved: both were detected in v0.0.165 by the tag-attr href rule on a collected tag and are not in the v0.0.167 tip, with the same bundles attached. Worth a look by whoever owns the link-rel change.

    Ticked 5; left open for 4.

    nik

  7. nc9 commented on Nov 5, 2026

    @nc9
    ContributorAuthor

    Acceptance check against main 7e8416b (v0.0.169). Criteria 1 to 3 and 5 stay ticked. Criterion 4 stays unticked, and it needs a maintainer decision on its wording.

    # Criterion Result Evidence
    4 A vendor URL only in a CSP <meta>, a <link>, JSON-LD, a JSON data script or prose is not detected NOT TICKED (wording) Holds for every <link> that only describes or relates a URL: packages/tech-detect/tests/link-rel-1539.test.ts "canonical, alternate, author, license, help, next, prev, icon and manifest" and "a missing rel, an unquoted rel and a rel with other tokens around the describing one" assert nothing is detected (shipped in v0.0.166, 7a111f6, a8387a9, e046df1). Still true by design: a <link> with a loading rel (stylesheet, preload, modulepreload, prefetch, prerender, preconnect, dns-prefetch) counts as vendor evidence (same file, "stylesheet, preload, modulepreload, prefetch, prerender, preconnect and dns-prefetch ..."; docs/cloud/technologies.mdx says so). The criterion says "a <link>" without that limit, so it is not true as written.

    Proposed amendment for criterion 4 (maintainer's call, original text to stay visible):

    A vendor URL only in a CSP <meta>, a <link> whose rel does not load or connect to its target (canonical, alternate, author, license, help, next, prev, me, icon, manifest, search, or no rel), JSON-LD, a JSON data script or prose is not detected. A <link> with a loading rel (stylesheet, preload, modulepreload, prefetch, prerender, preconnect, dns-prefetch) still counts.

    With that wording criterion 4 is met on the evidence above, and the issue can close. The alternative (loading-rel links must not count either) would remove 14 of the 50 threejs gains checked under criterion 5, so I do not recommend it.

    Follow-up on the link-rel change: the supabase pairs lost between v0.0.165 and v0.0.167 on the corpus slice were root-caused and fixed in v0.0.168.

    • A <link rel="preconnect"> or dns-prefetch to a bare supabase project origin is real use, and the detector asked for a /rest/v1-style path, so it missed it once alternate links stopped counting. d23f6bd added a bare-origin detector and 856dc70 made it match only when the origin is the whole href (a list that only contains it does not count; an alternate, canonical link or an anchor does not). Pinned in supabase-preconnect-1539.test.ts (preconnect and dns-prefetch detect; "an alternate or canonical link to a bare origin", "an anchor to the bare origin" and "the origin must be the whole href" do not). Corpus re-run on the v0.0.169 tree (2,795-site slice): both lost supabase sites detected again, 7 more sites with only a preconnect or dns-prefetch to a project origin newly detected (all 7 read by evidence region: connection hints to a project origin), and no supabase change between the v0.0.168 and v0.0.169 trees.
    • The vue pair lost in the same window was a correct removal: its only evidence was the title of a <link rel="alternate"> feed link (a false positive, the intended effect of this issue).

    importmap-1539.test.ts, link-rel-1539.test.ts and supabase-preconnect-1539.test.ts pass on main (together with two more files, 193 pass).

    nik

  8. nc9 commented on Nov 9, 2026

    @nc9
    ContributorAuthor

    The last box holds on main at 486cd13: packages/rules/tests/importmap-1539.test.ts ('what is still not a script URL') rejects a CSP meta, an anchor, JSON-LD, a JSON data script and prose, and all 44 tests in the file pass. Import map and small inline module loaders already detect threejs; the large inline module case is #1540.

    nik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrulessize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions