-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(js): locate npm nodes correctly for aliased packages
- Loading branch information
1 parent
dd84dab
commit 1962ae5
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,14 @@ describe('TargetProjectLocator', () => { | |
name: '@proj/proj123-base', | ||
version: '1.0.0', | ||
}), | ||
'./node_modules/lodash/package.json': JSON.stringify({ | ||
name: 'lodash', | ||
version: '3.0.0', | ||
}), | ||
'./node_modules/lodash-4/package.json': JSON.stringify({ | ||
name: 'lodash', | ||
version: '4.0.0', | ||
}), | ||
}; | ||
vol.fromJSON(fsJson, '/root'); | ||
projects = { | ||
|
@@ -263,6 +271,22 @@ describe('TargetProjectLocator', () => { | |
packageName: '@proj/proj123-base', | ||
}, | ||
}, | ||
'npm:lodash': { | ||
name: 'npm:lodash', | ||
type: 'npm', | ||
data: { | ||
version: '3.0.0', | ||
packageName: 'lodash', | ||
}, | ||
}, | ||
'npm:lodash-4': { | ||
name: 'npm:lodash-4', | ||
type: 'npm', | ||
data: { | ||
packageName: 'lodash-4', | ||
version: 'npm:[email protected]', | ||
}, | ||
}, | ||
}; | ||
|
||
targetProjectLocator = new TargetProjectLocator(projects, npmProjects); | ||
|
@@ -454,6 +478,20 @@ describe('TargetProjectLocator', () => { | |
); | ||
expect(proj5).toEqual('proj5'); | ||
}); | ||
|
||
it('should be able to resolve packages alises', () => { | ||
const lodash = targetProjectLocator.findProjectFromImport( | ||
'lodash', | ||
'libs/proj/index.ts' | ||
); | ||
expect(lodash).toEqual('npm:lodash'); | ||
|
||
const lodash4 = targetProjectLocator.findProjectFromImport( | ||
'lodash-4', | ||
'libs/proj/index.ts' | ||
); | ||
expect(lodash4).toEqual('npm:lodash-4'); | ||
}); | ||
}); | ||
|
||
describe('findTargetProjectWithImport (without tsconfig.json)', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters