Best practice for publishing libraries that consume the Deno standard library #13073
Unanswered
jaredkrinke
asked this question in
Q&A
Replies: 1 comment
-
Note: the Standard library section of the manual recommends specifying a version to avoid breaking changes. This is obviously a good idea for scripts, but I don't see any mention of libraries. Edit: after reading this section again, I think the most important point is that the standard library hasn't stabilized yet, so "upgrading" any references to std is fraught with peril. Maybe this question will be more interesting once std has stabilized. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to publish a "library" module (i.e. one that is intended to be consumed by other modules), and my module depends on functionality in Deno's standard library (deno.land/std).
What's the best way to consume deno.land/std in a library?
(I didn't see any information about this scenario in Linking to external code)
Considerations:
Edit to add: this situation for Deno's standard library is unique in that the std version is updated often, all the modules are lumped into a single library (with one version), and the std versions are mapped to specific Deno versions (I assume mainly for unstable APIs... hopefully not much else!).
The two options I see are:
https://deno.land/std/testing/asserts.ts
)https://deno.land/std@0.117.0/testing/asserts.ts
)The first option is attractive, but it seems fragile (especially when Deno 2.0 arrives). The second option is probably best, but I don't like that it duplicates code unless consumers use an import map to align std versions.
Some notes follow:
Import without a version
Note: I haven't found a module that does this.
I see a number of benefits to this:
But there are significant drawbacks:
std
renamed tostd2
? :)Import with a version
Benefits:
Downsides:
Still, this seems like the most reliable option. Consumers that want to align std versions need to use an import map (and hope nothing breaks!), e.g. the following maps
@0.117.0
and@0.116.0
to@0.113.0
(I just made up the version numbers):Beta Was this translation helpful? Give feedback.
All reactions