How to use the @open-wc/building-utils/index-html/loader-script.js.createPolyfillsLoaderScript function in @open-wc/building-utils

To help you get started, we’ve selected a few @open-wc/building-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-wc / open-wc / packages / karma-esm / src / test-loader-browser-script.js View on Github external
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(',');