feat(providence): allow to resolve outside node_modules as well
This commit is contained in:
parent
292dcfc855
commit
244bdf7f53
2 changed files with 8 additions and 4 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import path from 'path';
|
||||
import { isRelativeSourcePath } from '../../utils/relative-source-path.js';
|
||||
import { LogService } from '../../core/LogService.js';
|
||||
import { resolveImportPath } from '../../utils/resolve-import-path.js';
|
||||
|
|
@ -35,7 +36,10 @@ export async function fromImportToExportPerspective({ importee, importer, import
|
|||
return null;
|
||||
}
|
||||
|
||||
const absolutePath = await resolveImportPath(importee, importer);
|
||||
const absolutePath = await resolveImportPath(importee, importer, {
|
||||
modulePaths: [path.resolve(importeeProjectPath, '..')],
|
||||
});
|
||||
|
||||
if (!absolutePath) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ const fakePluginContext = {
|
|||
* name without an extension.
|
||||
* @param {SpecifierSource} importee source like '@lion/core' or '../helpers/index.js'
|
||||
* @param {PathFromSystemRoot} importer importing file, like '/my/project/importing-file.js'
|
||||
* @param {{customResolveOptions?: {preserveSymlinks:boolean}}} [opts] nodeResolve options
|
||||
* @param {{customResolveOptions?: {preserveSymlinks:boolean}; modulePaths?: string[]}} [opts] nodeResolve options
|
||||
* @returns {Promise<PathFromSystemRoot|null|'[node-builtin]'>} the resolved file system path, like '/my/project/node_modules/@lion/core/index.js'
|
||||
*/
|
||||
async function resolveImportPathFn(importee, importer, opts) {
|
||||
async function resolveImportPathFn(importee, importer, opts = {}) {
|
||||
if (isBuiltin(importee)) {
|
||||
return '[node-builtin]';
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ async function resolveImportPathFn(importee, importer, opts) {
|
|||
// allow resolving polyfills for nodejs libs
|
||||
preferBuiltins: false,
|
||||
// extensions: ['.mjs', '.js', '.json', '.node'],
|
||||
...(opts || {}),
|
||||
...opts,
|
||||
});
|
||||
|
||||
const preserveSymlinks =
|
||||
|
|
|
|||
Loading…
Reference in a new issue