How to use the @open-wc/building-utils/index-html/index.js.createIndexHTML 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 / es-dev-server / src / middleware / compatibility.js View on Github external
if (resources.inlineModules.length > 0) {
      throw new Error(
        `Compatibility cannot handle "inline" modules (modules without a src attribute). Place your js code in a separate file.`,
      );
    }

    if (!resources.jsModules || resources.jsModules.length === 0) {
      throw new Error(
        `Compatibility mode requires at least one 
github open-wc / open-wc / packages / es-dev-server / src / utils / transform-index-html.js View on Github external
const files = [
    ...resources.jsModules,
    ...[...inlineModules.keys()].map(e => `${e}?source=${encodeURIComponent(cfg.indexUrl)}`),
  ];

  if (files.length === 0) {
    return {
      indexHTML: cfg.indexHTMLString,
      inlineModules: new Map(),
      polyfills: [],
    };
  }

  // create a new index.html with injected polyfills and loader script
  const createResult = createIndexHTML(resources.indexHTML, {
    entries: {
      type: polyfillModules ? 'system' : 'module',
      polyfillDynamicImport: false,
      files,
    },
    polyfills: getPolyfills(cfg),
    minify: false,
    preload: false,
  });

  let { indexHTML } = createResult;
  if (polyfillModules) {
    indexHTML = addPolyfilledImportMaps(indexHTML, resources);
  }

  // inject systemjs resolver which appends a query param to trigger es5 compilation