Subscribe on changes!

fix: resolve node_modules

avatar
Apr 27th 2020
  • fix resolving scoped modules, eg: @scope/package
    • instead of using / to determine the case of deep imports, use path.extname instead (not sure it's the best way) to know it is importing a package or a file
  • 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
avatar
Apr 27th 2020

Cool! This is neat, it also gets rid of the need for the source map part, which is essentially dealing with relative imports inside modules.