itsdouges / vite_plugin_deno_resolve

A plugin for Vite that resolves modules with Deno.
https://deno.land/x/vite_plugin_deno_resolve
16 stars 3 forks source link

Rollup URL Plugin will only remap single quoted import statements. #7

Open lukekaalim opened 1 year ago

lukekaalim commented 1 year ago

Expected behavior: Both single quoted import x from 'y'; and double-quoted import x from "y"; imports should be remapped to localhost.

Observed behaviour: Only single quoted import statements get remapped, double-quoted statements get ignored - often meaning that they reach out to esm.sh servers and download (so its hard to notice that its not actually served locally since the code still runs like normal).

Reproduction case:

// index.ts
import React from "https://esm.sh/react@18.2.0";
import React2 from 'https://esm.sh/react@18.2.0';

console.log(React);
console.log(React2);
// vite.config.mts
import { defineConfig } from 'npm:vite@3.2.4';
import denoResolve from 'https://deno.land/x/vite_plugin_deno_resolve/mod.ts';

export default defineConfig({
  plugins: [denoResolve()],
});

Here you can see Vite reaching out to both localhost & esm.sh to resolve React & React2.

Screenshot 2023-09-20 at 2 11 21 am
lukekaalim commented 1 year ago

Wait hang on - Dougall? I just checked your profile to see if you were active on github and I recognized your face! I'm pretty sure we worked together at 9now for exactly one week lol. How's hockey?

lukekaalim commented 1 year ago

Great plugin btw - I know this is like a year old but this really saved my ass when I was doing some deno-vite stuff

itsdouges commented 1 year ago

Haha mate I saw your profile and I was like wait a second I know this guy 😂

Yeah we did!! How's things? Where are you at now?

Hockey is great just slid into the grand final which is on in a few weeks 💪.

Will look at the PR soon, this whole lib was originally slated to handle npm specifiers but then Deno pivoted back to package.json so was mostly unneeded. But the Deno https specifiers still are needed at least.