Skip to content

fixes resolve-path logic for finding local paths that include an addon's name #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/ember-css-modules/lib/resolve-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ function resolveRelativePath(importPath, fromFile, options) {

// Resolve absolute paths pointing to the same app/addon as the importer
function resolveLocalPath(importPath, fromFile, options) {
let appOrAddonDirIndex = fromFile.indexOf(options.ownerName, options.root.length);
const fromFileStartsWithOwnerName = fromFile.substring(options.root.length + 1).startsWith(options.ownerName);

// Depending on the exact version of Ember CLI and/or Embroider in play, the
// app/addon name may or may not be included in `fromFile`'s path. If not, we
// need to strip that prefix from the import path.
if (appOrAddonDirIndex === -1) {
appOrAddonDirIndex = options.root.length;
importPath = ensurePosixPath(importPath).replace(new RegExp('^' + options.ownerName + '/?'), '');
if (!fromFileStartsWithOwnerName) {
importPath = importPath.substring(options.ownerName.length + 1);
}

let prefix = fromFile.substring(0, appOrAddonDirIndex);
let absolutePath = ensurePosixPath(path.resolve(prefix, importPath));
let absolutePath = ensurePosixPath(path.resolve(options.root, importPath));
return internalDep(absolutePath, options);
}

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6621,7 +6621,7 @@ ember-compatibility-helpers@^1.0.2, ember-compatibility-helpers@^1.1.1, ember-co
semver "^5.4.1"

"ember-css-modules@link:packages/ember-css-modules":
version "1.4.0"
version "1.5.0"
dependencies:
broccoli-bridge "^1.0.0"
broccoli-concat "^3.2.2"
Expand Down