How to use @open-wc/building-utils - 10 common examples

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(',');
github riju / WebCamera / rollup.config.js View on Github external
},
          htmlMinifier: {
            collapseWhitespace: true,
            removeComments: true,
            caseSensitive: true,
            minifyCSS: customMinifyCss,
          },
        },
      ],
    ].filter(_ => !!_),

    presets: [
      [
        '@babel/preset-env',
        {
          targets: findSupportedBrowsers(),
          // preset-env compiles template literals for safari 12 due to a small bug which
          // doesn't affect most use cases. for example lit-html handles it: (https://github.com/Polymer/lit-html/issues/575)
          exclude: ['@babel/plugin-transform-template-literals'],
          useBuiltIns: false,
          modules: false,
        },
      ],
    ],
  }),

  // only minify if in production
  production && terser()
];

const outputOptions = [
  {
github open-wc / open-wc / packages / building-webpack / modern-config.js View on Github external
conservativeCollapse: true,
                      removeComments: true,
                      caseSensitive: true,
                      minifyCSS: customMinifyCSS,
                    },
                  },
                ],
                // webpack does not support import.meta.url yet, so we rewrite them in babel
                [require.resolve('babel-plugin-bundled-import-meta'), { importStyle: 'baseURI' }],
              ].filter(_ => !!_),

              presets: [
                [
                  require.resolve('@babel/preset-env'),
                  {
                    targets: findSupportedBrowsers(),
                    // preset-env compiles template literals for safari 12 due to a small bug which
                    // doesn't affect most use cases. for example lit-html handles it: (https://github.com/Polymer/lit-html/issues/575)
                    exclude: ['@babel/plugin-transform-template-literals'],
                    useBuiltIns: false,
                    modules: false,
                  },
                ],
              ],
            },
          },
        },
      ].filter(_ => !!_),
    },

    optimization: {
      minimizer: [
github open-wc / open-wc / packages / building-rollup / modern-and-legacy-config.js View on Github external
htmlMinifier: {
                  collapseWhitespace: true,
                  conservativeCollapse: true,
                  removeComments: true,
                  caseSensitive: true,
                  minifyCSS: customMinifyCss,
                },
              },
            ],
          ].filter(_ => !!_),

          presets: [
            [
              require.resolve('@babel/preset-env'),
              {
                targets: legacy ? ['ie 11'] : findSupportedBrowsers(),
                // preset-env compiles template literals for safari 12 due to a small bug which
                // doesn't affect most use cases. for example lit-html handles it: (https://github.com/Polymer/lit-html/issues/575)
                exclude: legacy ? undefined : ['@babel/plugin-transform-template-literals'],
                useBuiltIns: false,
                modules: false,
              },
            ],
          ],
        }),

      // only minify if in production
      production && terser(),

      production &&
        options.plugins.workbox &&
        !legacy &&
github open-wc / open-wc / packages / building-webpack / modern-and-legacy-config.js View on Github external
conservativeCollapse: true,
                      removeComments: true,
                      caseSensitive: true,
                      minifyCSS: customMinifyCSS,
                    },
                  },
                ],
                // webpack does not support import.meta.url yet, so we rewrite them in babel
                [require.resolve('babel-plugin-bundled-import-meta'), { importStyle: 'baseURI' }],
              ].filter(_ => !!_),

              presets: [
                [
                  require.resolve('@babel/preset-env'),
                  {
                    targets: legacy ? ['ie 11'] : findSupportedBrowsers(),
                    // preset-env compiles template literals for safari 12 due to a small bug which
                    // doesn't affect most use cases. for example lit-html handles it: (https://github.com/Polymer/lit-html/issues/575)
                    exclude: legacy ? undefined : ['@babel/plugin-transform-template-literals'],
                    useBuiltIns: false,
                    modules: false,
                  },
                ],
              ],
            },
          },
        },
      ].filter(_ => !!_),
    },

    optimization: {
      minimizer: [
github open-wc / open-wc / packages / es-dev-server / src / utils / babel-compiler.js View on Github external
require.resolve('@babel/plugin-syntax-dynamic-import'),
      require.resolve('@babel/plugin-syntax-import-meta'),
    ],
    sourceType: 'module',
    // only read the user's babelrc and config if explicitly enabled
    babelrc: readUserBabelConfig,
    configFile: readUserBabelConfig,
  };
}

const modernConfig = {
  presets: [
    [
      require.resolve('@babel/preset-env'),
      {
        targets: findSupportedBrowsers(),
        useBuiltIns: false,
        modules: false,
      },
    ],
  ],
};

const legacyConfig = {
  presets: [
    [
      require.resolve('@babel/preset-env'),
      {
        targets: ['ie 11'],
        useBuiltIns: false,
        modules: 'systemjs',
      },
github open-wc / open-wc / packages / es-dev-server / src / utils / babel-compiler.js View on Github external
require.resolve('@babel/plugin-syntax-dynamic-import'),
      require.resolve('@babel/plugin-syntax-import-meta'),
    ],
    sourceType: 'module',
    // only read the user's babelrc if explicitly enabled
    babelrc,
    sourceMap: 'inline',
  };
}

const modernConfig = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: findSupportedBrowsers(),
        useBuiltIns: false,
        modules: false,
      },
    ],
  ],
};

const legacyConfig = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: ['ie 11'],
        useBuiltIns: false,
        modules: 'systemjs',
      },
github open-wc / open-wc / packages / building-rollup / modern-config.js View on Github external
htmlMinifier: {
                  collapseWhitespace: true,
                  conservativeCollapse: true,
                  removeComments: true,
                  caseSensitive: true,
                  minifyCSS: customMinifyCss,
                },
              },
            ],
          ].filter(_ => !!_),

          presets: [
            [
              require.resolve('@babel/preset-env'),
              {
                targets: findSupportedBrowsers(),
                // preset-env compiles template literals for safari 12 due to a small bug which
                // doesn't affect most use cases. for example lit-html handles it: (https://github.com/Polymer/lit-html/issues/575)
                exclude: ['@babel/plugin-transform-template-literals'],
                useBuiltIns: false,
                modules: false,
              },
            ],
          ],
        }),

      // only minify if in production
      production && terser(),

      production && options.plugins.workbox && generateSW(getWorkboxConfig(options.outputDir)),
    ],
  };
github open-wc / open-wc / packages / rollup-plugin-index-html / rollup-plugin-index-html.js View on Github external
load(id) {
      const inlineEntryId = findInlineEntryId(id);
      // if this is an inline entry, take the inline module index from the import and return it's content
      if (typeof inlineEntryId === 'number') {
        return inlineModules[inlineEntryId];
      }

      // defer loading to other plugins / rollup
      return null;
    },
github open-wc / open-wc / packages / rollup-plugin-index-html / rollup-plugin-index-html.js View on Github external
resolveId(source, importer) {
      // if this is an inline entry keep it, load() will take ca,re of it
      if (typeof findInlineEntryId(source) === 'number') {
        return source;
      }

      if (Array.isArray(inlineImportMaps) && inlineImportMaps.length > 0) {
        // exclude entry points as they may get provided as `main.js` without a path
        // which would be considered bare module according to import map spec
        if (
          rollupOptions.input &&
          Array.isArray(rollupOptions.input) &&
          rollupOptions.input.includes(source)
        ) {
          return null;
        }
        const { rootDir = process.cwd() } = localPluginConfig;

        const basePath = importer ? importer.replace(rootDir, `${rootDir}::`) : `${rootDir}::`;