Skip to content

Commit

Permalink
feat(providence): allow to resolve outside node_modules as well
Browse files Browse the repository at this point in the history
  • Loading branch information
tlouisse committed Nov 30, 2023
1 parent 292dcfc commit 244bdf7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]';
}
Expand All @@ -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 =
Expand Down

0 comments on commit 244bdf7

Please sign in to comment.