GithubHelp home page GithubHelp logo

Comments (3)

bartlomieju avatar bartlomieju commented on June 11, 2024 8

@codesculpture, @itsdouges and I are looking into this problem

from esbuild_deno_loader.

Ciantic avatar Ciantic commented on June 11, 2024 2

I made a plugin to rewrite npm:... to esm.sh before deno plugin like this:

await esbuild.build({
    plugins: [
        // ESBuild plugin to rewrite import starting "npm:" to "esm.sh" for https plugin
        {
            name: "the-npm-plugin",
            setup(build: any) {
                build.onResolve({ filter: /^npm:/ }, (args: any) => {
                    return {
                        path: args.path.replace(/^npm:/, "//esm.sh/"),
                        namespace: "https",
                    };
                });
            },
        },
        denoPlugin() as any,
    ],

However it doesn't utilize the cache, it seems to be downloading all of the files I rewrite like that on each build.

Also it seems to be that tree shaking doesn't work for those imports (currently I use it to just date-fns) which is a bummer.

But it works for the time being.


Edit I also noticed I can get it to work like this:

import_map.json

{
    "imports": {
        "npm:date-fns": "https://esm.sh/date-fns"
    }
}
denoPlugin({
    importMapURL: new URL("./import_map.json", import.meta.url),
}) as any,

Problem with this approach is the same as with my plugin above, the esbuild command re-downloads the URLs each time. In my example it re-downloads https://esm.sh/date-fns on each build and it makes it slow.

from esbuild_deno_loader.

mitchwadair avatar mitchwadair commented on June 11, 2024

Is there any work being done on this at the moment?

from esbuild_deno_loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.