-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Refs: nodejs#31625 Refs: nodejs#32107 Refs: babel/babel#11216
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1145,25 +1145,27 @@ Maybe<URL> PackageMainResolve(Environment* env, | |
|
||
if (!pcfg.exports.IsEmpty()) { | ||
Local<Value> exports = pcfg.exports.Get(isolate); | ||
Maybe<bool> isConditionalExportsMainSugar = | ||
IsConditionalExportsMainSugar(env, exports, pjson_url, base); | ||
if (isConditionalExportsMainSugar.IsNothing()) | ||
return Nothing<URL>(); | ||
if (isConditionalExportsMainSugar.FromJust()) { | ||
return ResolveExportsTarget(env, pjson_url, exports, "", "", base); | ||
} else if (exports->IsObject()) { | ||
Local<Object> exports_obj = exports.As<Object>(); | ||
if (exports_obj->HasOwnProperty(env->context(), env->dot_string()) | ||
.FromJust()) { | ||
Local<Value> target = | ||
exports_obj->Get(env->context(), env->dot_string()) | ||
.ToLocalChecked(); | ||
return ResolveExportsTarget(env, pjson_url, target, "", "", base); | ||
if (!exports->IsFalse()) { | ||
This comment has been minimized.
Sorry, something went wrong.
MylesBorins
Author
Owner
|
||
Maybe<bool> isConditionalExportsMainSugar = | ||
IsConditionalExportsMainSugar(env, exports, pjson_url, base); | ||
if (isConditionalExportsMainSugar.IsNothing()) | ||
return Nothing<URL>(); | ||
if (isConditionalExportsMainSugar.FromJust()) { | ||
return ResolveExportsTarget(env, pjson_url, exports, "", "", base); | ||
} else if (exports->IsObject()) { | ||
Local<Object> exports_obj = exports.As<Object>(); | ||
if (exports_obj->HasOwnProperty(env->context(), env->dot_string()) | ||
.FromJust()) { | ||
Local<Value> target = | ||
exports_obj->Get(env->context(), env->dot_string()) | ||
.ToLocalChecked(); | ||
return ResolveExportsTarget(env, pjson_url, target, "", "", base); | ||
} | ||
} | ||
std::string msg = "No \"exports\" main resolved in " + | ||
pjson_url.ToFilePath(); | ||
node::THROW_ERR_PACKAGE_PATH_NOT_EXPORTED(env, msg.c_str()); | ||
} | ||
std::string msg = "No \"exports\" main resolved in " + | ||
pjson_url.ToFilePath(); | ||
node::THROW_ERR_PACKAGE_PATH_NOT_EXPORTED(env, msg.c_str()); | ||
} | ||
if (pcfg.has_main == HasMain::Yes) { | ||
URL resolved(pcfg.main, pjson_url); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,14 @@ import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; | |
{ default: 'self-cjs' } : { default: 'self-mjs' }], | ||
// Resolve self sugar | ||
['pkgexports-sugar', { default: 'main' }], | ||
// Resolve exports false | ||
isRequire ? [ | ||
This comment has been minimized.
Sorry, something went wrong.
MylesBorins
Author
Owner
|
||
'pkgexports-false-cjs', | ||
{ default: 'false-exports-cjs' | ||
}] : [ | ||
'pkgexports-false-mjs', | ||
{ default: 'false-exports-mjs' | ||
}], | ||
]); | ||
|
||
for (const [validSpecifier, expected] of validSpecifiers) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This is wrong and should be ignored, but it is where the CJS codepath for the error is coming from