@@ -10,6 +10,16 @@ module.exports = function resolvePath(importPath, fromFile, options) {
1010 return resolveRelativePath ( pathWithExtension , fromFile , options ) ;
1111 } else if ( isLocalPath ( pathWithExtension , options ) ) {
1212 return resolveLocalPath ( pathWithExtension , fromFile , options ) ;
13+ } else if ( isLocalPathWithOldPackageNameRef ( pathWithExtension , options ) ) {
14+ const amendedPathWithExtension = pathWithExtension . replace ( options . parentName , options . ownerName ) ;
15+ options . ui . writeWarnLine (
16+ 'For addons that define a moduleName, you should reference any CSS Modules provided by that addon ' +
17+ 'using its moduleName instead of the package name.\n' +
18+ 'Current path: ' + importPath + '\n' +
19+ 'Replace with: ' + importPath . replace ( options . parentName , options . ownerName ) + '\n' +
20+ 'File: ' + fromFile
21+ ) ;
22+ return resolveLocalPath ( amendedPathWithExtension , fromFile , options ) ;
1323 } else {
1424 return resolveExternalPath ( pathWithExtension , importPath , fromFile , options ) ;
1525 }
@@ -23,6 +33,10 @@ function isLocalPath(importPath, options) {
2333 return importPath . indexOf ( options . ownerName + '/' ) === 0 ;
2434}
2535
36+ function isLocalPathWithOldPackageNameRef ( importPath , options ) {
37+ return ( options . ownerName !== options . parentName ) && importPath . indexOf ( options . parentName + '/' ) === 0 ;
38+ }
39+
2640function resolveRelativePath ( importPath , fromFile , options ) {
2741 let absolutePath = ensurePosixPath ( path . resolve ( path . dirname ( fromFile ) , importPath ) ) ;
2842 return internalDep ( absolutePath , options ) ;
@@ -49,7 +63,12 @@ function resolveLocalPath(importPath, fromFile, options) {
4963function resolveExternalPath ( importPath , originalPath , fromFile , options ) {
5064 let baseIndex = importPath [ 0 ] === '@' ? importPath . indexOf ( '/' ) + 1 : 0 ;
5165 let addonName = importPath . substring ( 0 , importPath . indexOf ( '/' , baseIndex ) ) ;
52- let addon = options . parent . addons . find ( addon => addon . name === addonName ) ;
66+ let addon = options . parent . addons . find ( ( addon ) => {
67+ if ( addon . moduleName ) {
68+ return addon . moduleName ( ) === addonName ;
69+ }
70+ return addon . name === addonName ;
71+ } ) ;
5372
5473 if ( ! addon ) {
5574 throw new Error (
0 commit comments