Revert "fix(core): prioritize local projects over npm when sharing names"
This reverts commit f10ba2f42e218e2e79470ac3928c40b589460f83.
This commit is contained in:
parent
38889cfcd3
commit
19c5f53ebf
@ -37,7 +37,6 @@ describe('findTargetProjectWithImport', () => {
|
||||
'@proj/proj123': ['libs/proj123/index.ts'],
|
||||
'@proj/proj1234': ['libs/proj1234/index.ts'],
|
||||
'@proj/proj1234-child': ['libs/proj1234-child/index.ts'],
|
||||
express: ['libs/express/index.ts'],
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -55,7 +54,6 @@ describe('findTargetProjectWithImport', () => {
|
||||
'./libs/proj123/index.ts': 'export const a = 5',
|
||||
'./libs/proj1234/index.ts': 'export const a = 6',
|
||||
'./libs/proj1234-child/index.ts': 'export const a = 7',
|
||||
'./libs/express/index.ts': 'export const a = 8',
|
||||
};
|
||||
vol.fromJSON(fsJson, '/root');
|
||||
|
||||
@ -204,22 +202,6 @@ describe('findTargetProjectWithImport', () => {
|
||||
files: [],
|
||||
},
|
||||
},
|
||||
express: {
|
||||
name: 'express',
|
||||
type: 'lib',
|
||||
data: {
|
||||
root: 'libs/express',
|
||||
files: [],
|
||||
},
|
||||
},
|
||||
'npm:express': {
|
||||
name: 'npm:express',
|
||||
type: 'npm',
|
||||
data: {
|
||||
files: [],
|
||||
packageName: 'express',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
targetProjectLocator = new TargetProjectLocator(projects);
|
||||
@ -269,7 +251,7 @@ describe('findTargetProjectWithImport', () => {
|
||||
expect(proj3a).toEqual('proj3a');
|
||||
});
|
||||
|
||||
it('should be able to resolve npm dependencies', () => {
|
||||
it('should be able to npm dependencies', () => {
|
||||
const result1 = targetProjectLocator.findProjectWithImport(
|
||||
'@ng/core',
|
||||
'libs/proj1/index.ts',
|
||||
@ -285,16 +267,6 @@ describe('findTargetProjectWithImport', () => {
|
||||
expect(result2).toEqual('npm:npm-package');
|
||||
});
|
||||
|
||||
it('should be able to prioritize local projects over dependencies', () => {
|
||||
const result = targetProjectLocator.findProjectWithImport(
|
||||
'express',
|
||||
'libs/proj1/index.ts',
|
||||
ctx.nxJson.npmScope
|
||||
);
|
||||
|
||||
expect(result).toEqual('express');
|
||||
});
|
||||
|
||||
it('should be able to resolve a module using a normalized path', () => {
|
||||
const proj4ab = targetProjectLocator.findProjectWithImport(
|
||||
'@proj/proj4ab',
|
||||
|
||||
@ -64,6 +64,11 @@ export class TargetProjectLocator {
|
||||
return this.findProjectOfResolvedModule(resolvedModule);
|
||||
}
|
||||
|
||||
const npmProject = this.findNpmPackage(importExpr);
|
||||
if (npmProject) {
|
||||
return npmProject;
|
||||
}
|
||||
|
||||
if (this.paths && this.paths[normalizedImportExpr]) {
|
||||
for (let p of this.paths[normalizedImportExpr]) {
|
||||
const maybeResolvedProject = this.findProjectOfResolvedModule(p);
|
||||
@ -92,11 +97,6 @@ export class TargetProjectLocator {
|
||||
}
|
||||
}
|
||||
|
||||
const npmProject = this.findNpmPackage(importExpr);
|
||||
if (npmProject) {
|
||||
return npmProject;
|
||||
}
|
||||
|
||||
const importedProject = this.sortedWorkspaceProjects.find((p) => {
|
||||
const projectImport = `@${npmScope}/${p.data.normalizedRoot}`;
|
||||
return normalizedImportExpr.startsWith(projectImport);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user