fix: _interopRequireWildcard should only cache objects (#10574)

* fix: [#10561] _interopRequireWildcard should cache object only

* fix: narrow down cache restriction to object/function type

* test: add interop require null module case
This commit is contained in:
samuel kwok
2019-10-19 18:01:38 +08:00
committed by Nicolò Ribaudo
parent 78cd63d9cf
commit fe258dec04
11 changed files with 32 additions and 4 deletions

View File

@@ -620,6 +620,10 @@ helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
return obj;
}
if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
return { default: obj }
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);