@@ -28,13 +28,21 @@ function importsToResolve(request) {
2828 const basename = path . basename ( request ) ;
2929 const dirname = path . dirname ( request ) ;
3030 const startsWithUnderscore = basename . charAt ( 0 ) === "_" ;
31- // a module import is an identifier like 'bootstrap-sass'
32- // Firstly check whether we importing scoped npm package (i.e. "@org/pkg")
33- // We also need to check for dirname since it might also be a deep import like 'bootstrap-sass/something'
34- const isModuleImport = dirname . charAt ( 0 ) === "@" && dirname . length > 1 ? true : request . charAt ( 0 ) !== "." && dirname === "." ;
3531 const hasCssExt = ext === ".css" ;
3632 const hasSassExt = ext === ".scss" || ext === ".sass" ;
3733
34+ // a module import is an identifier like 'bootstrap-sass'
35+ // We also need to check for dirname since it might also be a deep import like 'bootstrap-sass/something'
36+ let isModuleImport = request . charAt ( 0 ) !== "." && dirname === "." ;
37+
38+ if ( dirname . charAt ( 0 ) === "@" ) {
39+ // Check whether it is a deep import from scoped npm package
40+ // (i.e. @pkg/foo/file), if so, process import as file import;
41+ // otherwise, if we import from root npm scoped package (i.e. @pkg/foo)
42+ // process import as a module import.
43+ isModuleImport = ! ( dirname . indexOf ( "/" ) > - 1 ) ;
44+ }
45+
3846 return ( isModuleImport && [ request ] ) || // Do not modify module imports
3947 ( hasCssExt && [ ] ) || // Do not import css files
4048 ( hasSassExt && [ request ] ) || // Do not modify imports with explicit extensions
0 commit comments