diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/babel-loader/lib/transform.js | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/babel-loader/lib/transform.js')
| -rw-r--r-- | node_modules/babel-loader/lib/transform.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/node_modules/babel-loader/lib/transform.js b/node_modules/babel-loader/lib/transform.js new file mode 100644 index 00000000..bc5011e3 --- /dev/null +++ b/node_modules/babel-loader/lib/transform.js @@ -0,0 +1,48 @@ +"use strict"; + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function step(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 _next(value) { step("next", value); } function _throw(err) { step("throw", err); } _next(); }); }; } + +const babel = require("@babel/core"); + +const promisify = require("util.promisify"); + +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; + const { + code, + map, + metadata + } = result; + + if (map && (!map.sourcesContent || !map.sourcesContent.length)) { + map.sourcesContent = [source]; + } + + return { + code, + map, + metadata + }; + }); + + return function (_x, _x2) { + return _ref.apply(this, arguments); + }; +}(); + +module.exports.version = babel.version;
\ No newline at end of file |
