diff options
Diffstat (limited to 'lib/internal/modules/esm/resolve.js')
-rw-r--r-- | lib/internal/modules/esm/resolve.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index 7ea59f30c6..7cf3552948 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -51,7 +51,8 @@ const { const { Module: CJSModule } = require('internal/modules/cjs/loader'); const packageJsonReader = require('internal/modules/package_json_reader'); -const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import']); +const userConditions = getOptionValue('--conditions'); +const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import', ...userConditions]); const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS); @@ -359,12 +360,9 @@ function isArrayIndex(key) { function resolvePackageTarget( packageJSONUrl, target, subpath, packageSubpath, base, internal, conditions) { if (typeof target === 'string') { - const resolved = resolvePackageTargetString( + return finalizeResolution(resolvePackageTargetString( target, subpath, packageSubpath, packageJSONUrl, base, internal, - conditions); - if (resolved === null) - return null; - return finalizeResolution(resolved, base); + conditions), base); } else if (ArrayIsArray(target)) { if (target.length === 0) return null; |