Open KotlinIsland opened 3 years ago
What command do you use to update your lock file? The command to cache all of the entries there should be the same / similar.
deno run --lock-write --lock lock.json mod.ts
So then deno cache mod.ts
would cache everything in the lock file. What's the need for this feature?
deno cache mod.ts
only caches the static dependencies, not the dynamic dependencies.
deno run --lock-write mod.ts
locks static and dynamic dependencies.
Ah didn't see it said deno run
.
This isn't the correct way of locking dynamic dependencies, having to run the program is unreasonable for that. You should make a dummy module dynamic_imports.ts
which imports every dynamically imported script used by your project. You can then update the lock file by running deno cache --lock-write --lock lock.json mod.ts dynamic_imports.ts
, and cache with deno cache --lock lock.json mod.ts dynamic_imports.ts
.
Sure that could be a good solution, but in my case it's a dependency that has dynamic dependencies, so I would have to deno run lock mod
than copy paste the entries from the lock file into the dependencies.ts
file. That's a lot of manual effort and duplication when it seems straightforward what deno cache lock.json
would do.
I wrote this terrible kludge:
import lock from "./lock.json" assert { type: "json" };
const child = Deno.run({
cmd: [
"deno",
"cache",
// Assume we're run from the top-level directory.
"--lock=./lock.json",
"--",
...Object.keys(lock),
],
});
const status = await child.status();
if (!status.success) {
console.log(`error: exit code ${status.code}`);
Deno.exit(status.code);
}
I want to be able to pre-cache my dynamic dependencies, I have pre locked my dependencies but no way to cache them ahead of time.
deno cache lock.json
should cache all dependencies specified in the file.