Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - Get package with version closest to a provided timestamp or date #1047

Open
sickl8 opened this issue Jan 20, 2025 · 5 comments

Comments

@sickl8
Copy link

sickl8 commented Jan 20, 2025

I'm requesting this simple feature, the user provides a timestamp or date in the query params, and gets back the earliest version of that package according to that piece of information.

Examples:

// date example, format is yyyy[-mm[-dd]]
esm.sh/lodash?as_of=2025-01-15 -> [email protected]
esm.sh/lodash?as_of=2024-05 -> esm.sh/lodash?as_of=2024-05-01
esm.sh/lodash?as_of=2023 -> esm.sh/lodash?as_of=2023-01-01

// timestamp example, using Date.now(), format is <number><ms|s>
esm.sh/lodash?as_of=1737386576174ms -> esm.sh/lodash?as_of=1737386576s
esm.sh/lodash?as_of=1737386576s -> [email protected]

It removes the need to know exactly what version you're going to use, sort of like when doing npm install <package> without specifying a version, but you still get a fixed version in your package.json for the next time you npm install

@sickl8 sickl8 changed the title Feature request - Get package with version closest to a provided timestamp Feature request - Get package with version closest to a provided timestamp or date Jan 20, 2025
@ije
Copy link
Member

ije commented Jan 21, 2025

interesting idea! but how do we know the specified version by date? it there an API can do this? esm.sh fetches packages only when requested.

@sickl8
Copy link
Author

sickl8 commented Jan 21, 2025

@ije
for npm, you can use the time field in the json returned from https://registry.npmjs.org/lodash
for jsr (uses an npm compatibility layer), the same but from https://npm.jsr.io/@jsr/tlevi__lodash (note that tlevi__lodash|@tlevi/lodash is not the official package)

@sickl8
Copy link
Author

sickl8 commented Jan 21, 2025

Image

@ije
Copy link
Member

ije commented Jan 21, 2025

yeah, i like the idea! lets add it in v137

@ije ije mentioned this issue Jan 21, 2025
5 tasks
@sickl8
Copy link
Author

sickl8 commented Jan 22, 2025

@ije excellent! where can we discuss implementation details? I would like to implement it and so we need to agree on how the feature works exactly and what it does on the server.

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

No branches or pull requests

2 participants