Right now, if a component file includes the name of its containing addon, the old logic would find that appOrAddonDirIndex would not be -1, when in reality it should be.
EX: addon name is special-button
/* special-button/addon/components/special-button.css */
.special-button {
composes: special from 'special-button/components/base-specialness';
}
With parameters like this (this is how it looks in our embroider build):
let appOrAddonDirIndex = fromFile.indexOf(options.ownerName, options.root.length)
// where
options.root.length === 59;
// so it's searching this string: 'components/special-button.css' for 'special-button' and the result is:
appOrAddonDirIndex === 70;
// then we get to the line:
let prefix = fromFile.substring(0, appOrAddonDirIndex);
prefix === 'special-button.css'
// and the line
let absolutePath = ensurePosixPath(path.resolve(prefix, importPath));
// is trying to resolve
'special-button.css/special-button/components/base-specialness';
// which obviously won't exist
the new code follows more closely with the intent of what was being done here:
// we want to check that after the root ( plus one char for '/'), the fromFile starts with the ownerName
// const fromFileStartsWithOwner = fromFile.substring(options.root.length + 1).startsWith(options.ownerName);
const fromFileStartsWithOwner = 'components/special-button.css'.startsWith('special-button')
// so
fromFileStartsWithOwner === false
// because the portion of fromFile after the owner.root does not start with ownerName, we need to remove the ownerName (plus a '/') from the importPath
importPath = importPath.substring(options.ownerName.length+1);
importPath === 'components/base-specialness';
// now, rather than needing a prefix, we can always use the root, and the new importPath
// so we can try to resolve:
'/tmp/broccoli-4392qIAomevRxZbJ/out-03-module_source_funnel/components/base-specialness.css';
// which should actually exist if that file exists in the addon.
Right now, if a component file includes the name of its containing addon, the old logic would find that
appOrAddonDirIndex
would not be-1
, when in reality it should be.EX: addon name is
special-button
With parameters like this (this is how it looks in our embroider build):
In the old logic, we would get something like:
the new code follows more closely with the intent of what was being done here: