andykais
andykais2y ago

what is import.meta.url on implicit version

I am in an awkward situation where I want to test retrieving the version from the url of my module when no version is specified (e.g. deno.land/x/sqlite_native). Unfortunately, it doesnt appear that there is a good way to test this. I have found the source file in ~/.cache/deno/deps/https/deno.land/, but editing it gives an error that the hash map doesnt match (which I suppose is there for safety). I also cannot test this locally since the import.meta.url will be the local file. I could publish a version to deno.land/x/ just to log out the import.meta.url, but I would like to avoid this. Essentially, I am wondering if deno will redirect the url to the latest version, and that version will appear in the import meta. Of course, if there is a better way to get the module version I am all ears. I am hoping to avoid adding a compile step to ci to edit tags to include a version number.
1 Reply
andykais
andykais2y ago
alrighty. It took some finagling, but I figured out that the hashes are sha256, so I just edited the correc file, found the hash with sha256sum and then edited deno.lock. It turns out that an implicit import does redirect to the latest and that latest does appear in the import.meta.url, so I can use this as a reliable way to find the version from deno.land thinking about it more...I will probably need a better solution long term, in case this code is imported from somewhere besides github or deno.land. For now at least, here is how I am managing binary releases https://github.com/andykais/sqlite-native/blob/main/src/binary_manager.ts#L52