PHP 7.4.33
Preview: babelSyntax.js Size: 1.01 KB
/var/www/podio.norlys.foo/httpdocs/node_modules/friendly-errors-webpack-plugin/src/transformers/babelSyntax.js
'use strict';

/**
 * This will be removed in next versions as it is not handled in the babel-loader
 * See: https://github.com/geowarin/friendly-errors-webpack-plugin/issues/2
 */
function cleanStackTrace(message) {
  return message
    .replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, ''); // at ... ...:x:y
}

function cleanMessage(message) {
  return message
  // match until the last semicolon followed by a space
  // this should match
  // linux => "(SyntaxError: )Unexpected token (5:11)"
  // windows => "(SyntaxError: C:/projects/index.js: )Unexpected token (5:11)"
    .replace(/^Module build failed.*:\s/, 'Syntax Error: ');
}

function isBabelSyntaxError(e) {
  return e.name === 'ModuleBuildError' &&
    e.message.indexOf('SyntaxError') >= 0;
}

function transform(error) {
  if (isBabelSyntaxError(error)) {
    return Object.assign({}, error, {
      message: cleanStackTrace(cleanMessage(error.message) + '\n'),
      severity: 1000,
      name: 'Syntax Error',
    });
  }

  return error;
}

module.exports = transform;

Directory Contents

Dirs: 0 × Files: 3
Name Size Perms Modified Actions
1.01 KB lrw-r--r-- 2018-12-28 06:37:32
Edit Download
378 B lrw-r--r-- 2018-12-28 06:37:32
Edit Download
698 B lrw-r--r-- 2018-12-28 06:37:32
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).