jest-next-dynamic
Advanced tools
Comparing version 0.1.1 to 0.2.0
15
index.js
@@ -1,9 +0,10 @@ | ||
const mockPromises = []; | ||
const mockInitializers = []; | ||
module.exports = function preloadAll() { | ||
if (mockPromises.length) { | ||
const promises = mockPromises.slice(); | ||
mockPromises.length = 0; | ||
// While loading the components in `mockPromises`, more components may have | ||
// been dynamically loaded, adding more promises we should wait for. | ||
if (mockInitializers.length) { | ||
const promises = mockInitializers.map(preload => preload()); | ||
mockInitializers.length = 0; | ||
// While loading the components in this round of initializers, more | ||
// components may have been dynamically loaded, adding more promises we | ||
// should wait for. | ||
return Promise.all(promises).then(preloadAll); | ||
@@ -20,3 +21,3 @@ } else { | ||
const LoadableComponent = dynamic(...args); | ||
mockPromises.push(LoadableComponent.preload()); | ||
mockInitializers.push(() => LoadableComponent.preload()); | ||
return LoadableComponent; | ||
@@ -23,0 +24,0 @@ }; |
{ | ||
"name": "jest-next-dynamic", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -30,3 +30,3 @@ # jest-next-dynamic | ||
{ | ||
"plugins": ["babel-plugin-dynamic-import-node]"] | ||
"plugins": ["babel-plugin-dynamic-import-node"] | ||
} | ||
@@ -33,0 +33,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3012
22