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

pql

importLatest

Unlisted
Like
1
importLatest
Home
Code
4
README.md
debug.ts
H
frontendTest.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
README.md

importLatest

importLatest resolves a module's latest version at runtime, and imports it dynamically to bypass the importer's lockfile cache. This greatly improves the experience of iterating on both a feature and its dependencies simultaneously.

Note: Remember back to static import statements for production, to reap benefits from lockfile caching, version pinning, and security.

usage

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

Returns: A promise that resolves to the module's exports.

Throws: If the HEAD request fails, returns a non-OK status, or the resolved URL cannot be imported.

note that importLatest must be called after all static import statements, as static imports are hoisted and must be resolved first.

import { staticImport } from "..."; import importLatest from "https://esm.town/v/peterqliu/importLatest"; const { gimmeLatest } = await importLatest( "https://esm.town/v/me/thisDependencyJustChanged", );

why

ValTown updates all lockfile dependencies within the same project, but not across projects. To illustrate:

Given a dependency,

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

and importing it from outside the project, all three of these initially evaluate foo 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");

But if the dependency changes,

export const foo = "new value";

Static and dynamic imports remain stuck on the cached value, while importLatest fetches the latest:

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"
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.