• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
pql

pql

importLatest

Unlisted
Like
1
importLatest
Home
Code
3
README.md
debug.ts
main.tsx
Connections
Environment variables
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
2/21/2026
Viewing readonly version of main branch: v28
View latest version
README.md

importLatest

Avoid stale dependencies in cache by following the esm.town/v/ redirect to the versioned URL, and importing that dynamically. Handy when enhancing/hotfixing a dependency, in parallel with feature development.

Be sure to switch back to static import * from * in production, to take advantage of performance/security/version pinning of lockfile caching.

behold

A dependency,

// in user/dependency/main.tsx
export foo = "old value"

Val in another project. All three below evaluate foo properly as "old value".

import {foo} from "user/dependency/main.tsx" 
const {foo} = await import("user/dependency/main.tsx");
const {foo} = await importLatest("user/dependency/main.tsx");

Then if the dependency changes

export foo = "new value"

Static and dynamic imports are stuck on the old, cached value, while importLatest fetches the new

import {foo} from "user/dependency/main.tsx" // foo === "old value"
const {foo} = await import("user/dependency/main.tsx"); // foo === "old value"
const {foo} = await importLatest("user/dependency/main.tsx"); // foo === "new value"

usage

importLatest(url:string): Promise<Record<string, unknown> | Response>

Be sure to invoke after all static imports, as those must come first.

import {staticImport} from ...
import importLatest from "https://esm.town/v/peterqliu/importLatest"

const {gimmeLatest} = await importLatest("https://esm.town/v/me/thisDependencyJustChanged");
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
AboutAlternativesPricingBlogNewsletterCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.