Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Cache result with KV #12

Open
ayoreis opened this issue Dec 12, 2022 · 1 comment
Open

Cache result with KV #12

ayoreis opened this issue Dec 12, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@ayoreis
Copy link
Owner

ayoreis commented Dec 12, 2022

https://deno.land/[email protected]/runtime/kv

@ayoreis ayoreis changed the title Cache... Cache result with KV Aug 9, 2023
@ayoreis ayoreis added the enhancement New feature or request label Aug 9, 2023
@7flash
Copy link

7flash commented Nov 12, 2023

I understand that cache should be applied here

import/mod.ts

Line 144 in 7c0d89e

const buildResult = await esbuild.build(

Alternatively, I consider doing it on my side and wonder whether it's possible to store sealedExports instead of buildResult?

Currently I am using following code

      const { default: fn } = await importString(rawCode, {
        parameters: {
          dynamicImport: (moduleName) => dynamicImport(moduleName, {
            force: true,
          }),
        }
      });

Do you think its possible to modify my code like this and it will work?

    const cache = {};
      const { default: fn } = await importString(rawCode, {
        parameters: {
          dynamicImport: async (moduleName) => {
              if (cache[moduleName]) return cache[moduleName];
              const module = await dynamicImport(moduleName, {
            force: true,
          });
          cache[moduleName] = module;
          return module;
          },
        }
      });

7flash added a commit to galaxydo/import that referenced this issue Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants