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

Cache imports #62

Open
MrMarble opened this issue May 3, 2023 · 2 comments
Open

Cache imports #62

MrMarble opened this issue May 3, 2023 · 2 comments

Comments

@MrMarble
Copy link

MrMarble commented May 3, 2023

Using denoPlugins with esbuild.server every reload of the page triggers a download of the imports.

Is there a way to cache the modules? I tried with https://github.com/dalcib/esbuild-plugin-cache but doesn't seem to work with the current version of esbuild.

Here is my bundle.ts file:

import * as esbuild from "https://deno.land/x/esbuild@v0.17.18/mod.js";
import { denoPlugins } from "https://deno.land/x/esbuild_deno_loader@0.7.0/mod.ts";

const ctx = await esbuild.context({
  entryPoints: ["./www/index.tsx"],
  outfile: "./www/dist/main.js",
  bundle: true,
  format: "esm",
  target: "es2020",
  platform: "browser",
  plugins: [
    {
      name: "json",
      setup: (build) =>
        build.onLoad({ filter: /\.json$/ }, () => ({ loader: "json" })),
    },
    ...denoPlugins(),
  ],
  publicPath: "./www/public",
});

await ctx.watch();

await ctx.serve({
  servedir: "./www",
  port: 3000,
});
@lucacasonato
Copy link
Owner

Are you running in Deno CLI or on Deno Deploy?

@lucacasonato
Copy link
Owner

Also, your plugin array is set up incorrectly. See https://github.com/lucacasonato/esbuild_deno_loader#using-with-other-plugins

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