How to use the @bundle-stats/utils.extractDataFromWebpackStats function in @bundle-stats/utils

To help you get started, we’ve selected a few @bundle-stats/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 relative-ci / bundle-stats / packages / bundle-stats / bin / run.js View on Github external
task: async (ctx, task) => {
        const baselineFilepath = path.relative(process.cwd(), getBaselineStatsFilepath());
        // eslint-disable-next-line no-param-reassign
        task.title = `${task.title} (${baselineFilepath})`;

        ctx.artifacts = ctx.artifacts.concat([{
          webpack: {
            stats: extractDataFromWebpackStats(ctx.baselineStats),
          },
        }]);
      },
      skip: async (ctx) => {
github relative-ci / bundle-stats / packages / bundle-stats / src / webpack-plugin.js View on Github external
const getOnEmit = (options) => async (compilation, callback) => {
  const {
    compare,
    baseline,
    html,
    json,
    outDir,
    stats: statsOptions,
  } = options;

  const data = extractDataFromWebpackStats(
    compilation.getStats().toJson(statsOptions),
  );

  // Webpack builtAt is not available yet
  if (!data.builtAt) {
    data.builtAt = Date.now();
  }

  const outputPath = get(compilation, 'options.output.path');

  const logger = compilation.getInfrastructureLogger
    ? compilation.getInfrastructureLogger('BundleStats')
    : console;

  const baselineFilepath = getBaselineStatsFilepath(outputPath);
  let baselineStats = null;
github relative-ci / bundle-stats / packages / bundle-stats / bin / run.js View on Github external
task: (ctx, task) => {
        const stats = get(ctx, 'artifacts.0.webpack.stats');
        const extractedWebpackStats = extractDataFromWebpackStats(stats);
        const baselineFilepath = path.relative(process.cwd(), getBaselineStatsFilepath());

        return writeBaseline(extractedWebpackStats).then(() => {
          // eslint-disable-next-line no-param-reassign
          task.title = `${task.title} (${baselineFilepath})`;
        });
      },
      skip: () => !baseline && TEXT.CLI_NO_BASELINE,
github relative-ci / bundle-stats / packages / bundle-stats / src / webpack-plugin.js View on Github external
data.builtAt = Date.now();
  }

  const outputPath = get(compilation, 'options.output.path');

  const logger = compilation.getInfrastructureLogger
    ? compilation.getInfrastructureLogger('BundleStats')
    : console;

  const baselineFilepath = getBaselineStatsFilepath(outputPath);
  let baselineStats = null;

  try {
    if (compare) {
      baselineStats = await readBaseline();
      baselineStats = extractDataFromWebpackStats(baselineStats);
      logger.info(`Read baseline from ${baselineFilepath}`);
    }
  } catch (err) {
    logger.warn(TEXT.PLUGIN_BASELINE_MISSING_WARN);
  }

  const artifacts = createJobs([
    { webpack: { stats: data } },
    ...compare ? [{ webpack: { stats: baselineStats } }] : [],
  ]);

  let reports = [];

  try {
    reports = await createReports(artifacts, { html, json });
github relative-ci / bundle-stats / packages / bundle-stats / bin / run.js View on Github external
ctx.artifacts = artifacts.map((stats) => ({
          webpack: {
            stats: extractDataFromWebpackStats(stats),
          },
        }));
      }),