Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createTestLoaderBrowserScript(compatibilityMode, polyfills, importMap) {
const loadPolyfillsWithFeatureDetectionScript = createPolyfillsLoaderScript(
polyfills,
defaultPolyfillsConfig,
'loadPolyfillsWithFeatureDetection',
);
// polyfills without a test don't require feature detection and are not included in the generic loader scriptˆ
const polyfillsWithoutFeatureDetection = polyfills.filter(p => !p.test);
// load core-js separately so that we can use Promise in the loader
const indexOfCoreJs = polyfillsWithoutFeatureDetection.findIndex(p => p.name === 'core-js');
const coreJs =
indexOfCoreJs === -1 ? null : polyfillsWithoutFeatureDetection.splice(indexOfCoreJs, 1)[0];
const polyfillsWithoutFeatureDetectionString = polyfillsWithoutFeatureDetection
.map(p => `{ tagName: 'script', props: { src: '/polyfills/${p.name}.${p.hash}.js', noModule: ${Boolean(p.nomodule)} } }`)
.join(',');