Skip to content

🐛 Take glob-to-regexp from npm so its types stop drifting - #75

Merged
taras merged 2 commits into
v1from
fix/glob-to-regexp-types
Sep 30, 2026
Merged

taras merged 2 commits into
v1from
fix/glob-to-regexp-types

Conversation

@taras

@taras taras commented Sep 30, 2026

Copy link
Copy Markdown
Member

Motivation

Verify fails on every pull request to this repo, and has since at least
2026-03-03 — the runs on Deploy To Netlify (#72) and on the merge of #73 fail
with the same error:

TS2305 [ERROR]: Module '"https://esm.sh/v132/@types/glob-to-regexp@0.4.4/index.d.ts"'
has no exported member 'default'.

export { default as globToRegExp } from "https://esm.sh/glob-to-regexp@0.4.1?pin=v132";
    at src/deps.ts:5:10

?pin=v132 pins the runtime package at 0.4.1, but esm.sh resolves the type
declarations separately and now serves @types/glob-to-regexp@0.4.4, which is
CommonJS-shaped:

export as namespace GlobToRegExp;
export = GlobToRegExp;

There is no default to re-export. TypeScript's synthetic-default interop lets
you import from a module like that, but it does not invent a default
binding for export { default as … } from, so the check is right to fail. The
pin covered the code and not the types, and the types moved out from under it.

Approach

- export { default as globToRegExp } from "https://esm.sh/glob-to-regexp@0.4.1?pin=v132";
+ export { default as globToRegExp } from "npm:glob-to-regexp@0.4.1";

Deno does the CommonJS interop itself for an npm: specifier, and takes the
types from the package rather than from a separately-resolved URL, so there is
nothing left to drift.

It is also the direction this repo already took, in
✨ convert inline URL imports to bare specifiers.

I tried keeping the esm.sh url and splitting the re-export into an import
followed by an export; it fails the same way, so the specifier itself has to
change.

hash.js on the next line has the same shape, but esm.sh serves no @types
for it, so there is nothing there to drift. Left alone.

Tests

All three steps the Verify workflow runs now pass locally, where deno task test previously failed on the type check:

deno fmt --check   Checked 32 files
deno lint          Checked 25 files
deno task test     ok | 10 passed (82 steps) | 0 failed

I also confirmed the replacement works at runtime, not only in the type
checker — globToRegExp("*.ts") returns /^.*\.ts$/.

deno.lock gains the npm entry, and along with it the @std/assert and
@std/internal entries the lockfile had been missing since the bare-specifier
conversion.

Note

Unrelated to #74, which touches only deno.json and a route template. That PR
is failing on this same pre-existing error and should go green once this lands.

`deno task test` has failed on every pull request since at least March:

    TS2305 Module '.../@types/glob-to-regexp@0.4.4/index.d.ts'
           has no exported member 'default'

`?pin=v132` pins the runtime package at 0.4.1, but esm.sh resolves the types
separately and now serves `@types/glob-to-regexp@0.4.4`, which declares
`export = GlobToRegExp` and so has no default to re-export. The pin covered
the code and not the types, so the types moved out from under it.

Deno does the interop itself for an `npm:` specifier, which is also the
direction this repo already took in "convert inline URL imports to bare
specifiers".

`hash.js` on the next line has the same shape but esm.sh serves no types for
it, so there is nothing there to drift.
`deploy-preview` never started the Fresh server:

    Integrity check failed for remote specifier.
      Specifier: https://esm.sh/prismjs@1.27.0/components/prism-diff.js?no-check
      Actual:   2f4bb643…
      Expected: 39fc9d5a…

esm.sh re-serves that url with different bytes than when the lock was
written, so every run failed the check and timed out after five minutes.
`--reload` does not help: deno still validates against the recorded hash.

The lockfile is rebuilt. Regenerating it also moved `@libs/xml` from 7 to 8,
because `sitemap.xml.ts` imported it with no version at all, so the import
is pinned and the lock keeps the 7 the site is running. 8 renders the
sitemap correctly too — worth taking deliberately rather than as a side
effect of a lockfile rebuild.
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

🚀 Deploy Preview Ready!

Docs intro
Docs intro

@taras
taras merged commit 8dca7d3 into v1 Sep 30, 2026
4 checks passed
@taras
taras deleted the fix/glob-to-regexp-types branch September 30, 2026 11:48

This branch was successfully deployed

1 active deployment
Preview — da70ccce Deployed Sep 30, 2026 by taras via deploy-preview #15
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