Sha256: 10ea069ff102ce3964ad1db1a8507994faed9b7c0cc7eace9079763d411ccf03

Contents?: true

Size: 1.86 KB

Versions: 11

Compression:

Stored size: 1.86 KB

Contents

"use strict";

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

const babel = require("@babel/core");

const {
  promisify
} = require("util");

const LoaderError = require("./Error");

const transform = promisify(babel.transform);

module.exports = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator(function* (source, options) {
    let result;

    try {
      result = yield transform(source, options);
    } catch (err) {
      throw err.message && err.codeFrame ? new LoaderError(err) : err;
    }

    if (!result) return null; // We don't return the full result here because some entries are not
    // really serializable. For a full list of properties see here:
    // https://github.com/babel/babel/blob/main/packages/babel-core/src/transformation/index.js
    // For discussion on this topic see here:
    // https://github.com/babel/babel-loader/pull/629

    const {
      ast,
      code,
      map,
      metadata,
      sourceType
    } = result;

    if (map && (!map.sourcesContent || !map.sourcesContent.length)) {
      map.sourcesContent = [source];
    }

    return {
      ast,
      code,
      map,
      metadata,
      sourceType
    };
  });

  return function (_x, _x2) {
    return _ref.apply(this, arguments);
  };
}();

module.exports.version = babel.version;

Version data entries

11 entries across 10 versions & 3 rubygems

Version Path
disco_app-0.16.1 test/dummy/node_modules/babel-loader/lib/transform.js
disco_app-0.15.2 test/dummy/node_modules/babel-loader/lib/transform.js
disco_app-0.18.4 test/dummy/node_modules/babel-loader/lib/transform.js
disco_app-0.18.1 test/dummy/node_modules/babel-loader/lib/transform.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/babel-loader/lib/transform.js
disco_app-0.14.0 test/dummy/node_modules/babel-loader/lib/transform.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/babel-loader/lib/transform.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/babel-loader/lib/transform.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/babel-loader/lib/transform.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/babel-loader/lib/transform.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/babel-loader/lib/transform.js