lucacasonato / esbuild_deno_loader

Deno module resolution for `esbuild`
https://jsr.io/@luca/esbuild-deno-loader
MIT License
176 stars 46 forks source link

Wrong path normalization #155

Open devingfx opened 1 week ago

devingfx commented 1 week ago

I had a weird error where a folder wasn't the good one with relative imports:

✘ [ERROR] Module not found "file:///home/dig/dev/vanill.es/apps/actions/svg/Action.js". [plugin deno-loader]

    ../vanill.es/apps/actions/svg/viewport/ViewportScaleAction.js:5:19:
      5 │ import Action from '../../Action.js'
        ╵                    ~~~~~~~~~~~~~

As you can see ../../Action.js from actions/svg/viewport should leads to action/Action.js and not actions/svg/Action.js

I was stuck figure out why until I try to resolve a fake ./ module to kinda see what's the current folder:

✘ [ERROR] Module not found "file:///home/dig/dev/vanill.es/apps/actions/svg//viewport/Action.js". [plugin deno-loader]

    ../vanill.es/apps/actions/svg/viewport/ViewportScaleAction.js:5:19:
      5 │ import Action from './Action.js'
        ╵                    ~~~~~~~~~~~~~

Then I could figure out a double slash typo in the module hierarchy (in fact a bad copy/paste) so it end's up trying to use this import specifier actions/svg//viewport/Action.js with a typo, path which should be normalized to actions/svg/viewport/Action.js to avoid taking the empty string between the double slash to be a folder to take account when resolving parent folders.