保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 26a09f08cf1ed43c640879f23fdad56c5c9282f7
PAMapp/node_modules/@jest/transform/build/ScriptTransformer.js
@@ -3,8 +3,8 @@
Object.defineProperty(exports, '__esModule', {
  value: true
});
exports.createTranspilingRequire = createTranspilingRequire;
exports.createScriptTransformer = createScriptTransformer;
exports.createTranspilingRequire = createTranspilingRequire;
function _crypto() {
  const data = require('crypto');
@@ -130,6 +130,8 @@
  require('./enhanceUnexpectedTokenMessage')
);
var _runtimeErrorsAndWarnings = require('./runtimeErrorsAndWarnings');
var _shouldInstrument = _interopRequireDefault(require('./shouldInstrument'));
function _interopRequireDefault(obj) {
@@ -212,15 +214,14 @@
class ScriptTransformer {
  constructor(_config, _cacheFS) {
    this._config = _config;
    this._cacheFS = _cacheFS;
    _defineProperty(this, '_cache', void 0);
    _defineProperty(this, '_transformCache', new Map());
    _defineProperty(this, '_transformsAreLoaded', false);
    this._config = _config;
    this._cacheFS = _cacheFS;
    const configString = (0, _fastJsonStableStringify().default)(this._config);
    let projectCache = projectCaches.get(configString);
@@ -383,7 +384,11 @@
          );
          if (!transformer) {
            throw new TypeError('Jest: a transform must export something.');
            throw new Error(
              (0, _runtimeErrorsAndWarnings.makeInvalidTransformerError)(
                transformPath
              )
            );
          }
          if (typeof transformer.createTransformer === 'function') {
@@ -394,8 +399,10 @@
            typeof transformer.process !== 'function' &&
            typeof transformer.processAsync !== 'function'
          ) {
            throw new TypeError(
              'Jest: a transform must export a `process` or `processAsync` function.'
            throw new Error(
              (0, _runtimeErrorsAndWarnings.makeInvalidTransformerError)(
                transformPath
              )
            );
          }
@@ -499,10 +506,8 @@
      } else if (processed != null && typeof processed.code === 'string') {
        transformed = processed;
      } else {
        throw new TypeError(
          "Jest: a transform's `process` function must return a string, " +
            'or an object with `code` key containing this string. ' +
            "It's `processAsync` function must return a Promise resolving to it."
        throw new Error(
          (0, _runtimeErrorsAndWarnings.makeInvalidReturnValueError)()
        );
      }
    }
@@ -521,10 +526,12 @@
      } catch {
        const transformPath = this._getTransformPath(filename);
        invariant(transformPath);
        console.warn(
          `jest-transform: The source map produced for the file ${filename} ` +
            `by ${transformPath} was invalid. Proceeding without source ` +
            'mapping for that file.'
          (0, _runtimeErrorsAndWarnings.makeInvalidSourceMapWarning)(
            filename,
            transformPath
          )
        );
      }
    } // That means that the transform has a custom instrumentation
@@ -977,10 +984,10 @@
    return null;
  }
  const code = content.substr(33);
  const code = content.substring(33);
  const checksum = (0, _crypto().createHash)('md5').update(code).digest('hex');
  if (checksum === content.substr(0, 32)) {
  if (checksum === content.substring(0, 32)) {
    return code;
  }
@@ -1097,7 +1104,7 @@
  invariant(name);
  invariant(
    typeof transformer.process === 'function',
    `Jest: synchronous transformer ${name} must export a "process" function.`
    (0, _runtimeErrorsAndWarnings.makeInvalidSyncTransformerError)(name)
  );
}