fix: resolve node_modules
- fix resolving scoped modules, eg:
@scope/package
- instead of using
/
to determine the case of deep imports, usepath.extname
instead (not sure it's the best way) to know it is importing a package or a file
- instead of using
- fix relative imports within
node_modules/
.- eg:
some_package/src/index.js
imports'./foo.js'
, - because
./foo.js
is a relative import, it wasnt rewritten. - and if we return
some_package/src/index.js
when browser requested for'/@modules/some_package'
, browser will get'./foo.js'
relative to it, which is'/@modules/foo.js'
which is not found. - to fix, 302 redirect '/@modules/some_package' to '/@modules/some_package/src/index.js' when resolving, this will help browser to resolve relative files within
node_modules
- eg: