Skip to content
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

adjust moved-package-target for namespaced packages #1663

Merged
merged 1 commit into from
Nov 14, 2023
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
7 changes: 6 additions & 1 deletion packages/compat/src/standalone-addon-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ ${summarizePeerDepViolations(violations)}
});

let fakeTargets = Object.values(index.packages).map(dir => {
return writeFile(join(dir, '..', 'moved-package-target.js'), '');
let segments = dir.split('/');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ef4 is it ok for this to not split on sep ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually tried that first and it breaks, because the index of moved packages here is always assembled in unix format.

while (segments[segments.length - 1] && segments[segments.length - 1] !== 'node_modules') {
segments.pop();
}
segments.push('moved-package-target.js');
return writeFile(join(...segments), '');
});

return broccoliMergeTrees([
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,11 @@ export class Resolver {
}

private resolveWithinMovedPackage<R extends ModuleRequest>(request: R, pkg: Package): R {
return request.rehome(resolve(pkg.root, '..', 'moved-package-target.js')).withMeta({
let levels = ['..'];
if (pkg.name.startsWith('@')) {
levels.push('..');
}
return request.rehome(resolve(pkg.root, ...levels, 'moved-package-target.js')).withMeta({
resolvedWithinPackage: pkg.root,
});
}
Expand Down