Skip to content

Commit 4dc319a

Browse files
authored
Merge pull request #197 from salsify/fix-3-12-local-imports
Ensure local imports work with CLI 3.12
2 parents 00465f6 + 1008eab commit 4dc319a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/ember-css-modules/lib/resolve-path.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ function resolveRelativePath(importPath, fromFile, options) {
3131
// Resolve absolute paths pointing to the same app/addon as the importer
3232
function resolveLocalPath(importPath, fromFile, options) {
3333
let appOrAddonDirIndex = fromFile.indexOf(options.ownerName, options.root.length);
34+
35+
// Depending on the exact version of Ember CLI and/or Embroider in play, the
36+
// app/addon name may or may not be included in `fromFile`'s path. If not, we
37+
// need to strip that prefix from the import path.
38+
if (appOrAddonDirIndex === -1) {
39+
appOrAddonDirIndex = options.root.length;
40+
importPath = ensurePosixPath(importPath).replace(new RegExp('^' + options.ownerName + '/?'), '');
41+
}
42+
3443
let prefix = fromFile.substring(0, appOrAddonDirIndex);
3544
let absolutePath = ensurePosixPath(path.resolve(prefix, importPath));
3645
return internalDep(absolutePath, options);

0 commit comments

Comments
 (0)