first commit
This commit is contained in:
153
build/node_modules/prepack/lib/prepack-node.js
generated
vendored
Normal file
153
build/node_modules/prepack/lib/prepack-node.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _prepackNodeEnvironment = require("./prepack-node-environment");
|
||||
|
||||
Object.keys(_prepackNodeEnvironment).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _prepackNodeEnvironment[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _prepackStandalone = require("./prepack-standalone");
|
||||
|
||||
Object.keys(_prepackStandalone).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _prepackStandalone[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
exports.prepackStdin = prepackStdin;
|
||||
exports.prepackFile = prepackFile;
|
||||
exports.prepackFileSync = prepackFileSync;
|
||||
|
||||
var _options = require("./options");
|
||||
|
||||
var _prepackOptions = require("./prepack-options");
|
||||
|
||||
var _prepackNodeEnvironment2 = require("./prepack-node-environment.js");
|
||||
|
||||
var _prepackStandalone2 = require("./prepack-standalone.js");
|
||||
|
||||
require("./types.js");
|
||||
|
||||
var _DebugChannel = require("./debugger/server/channel/DebugChannel.js");
|
||||
|
||||
var _FileIOWrapper = require("./debugger/common/channel/FileIOWrapper.js");
|
||||
|
||||
var _fs = require("fs");
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function prepackStdin() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _options.defaultOptions;
|
||||
var callback = arguments[1];
|
||||
|
||||
var sourceMapFilename = options.inputSourceMapFilename || "";
|
||||
process.stdin.setEncoding("utf8");
|
||||
process.stdin.resume();
|
||||
process.stdin.on("data", function (code) {
|
||||
_fs2.default.readFile(sourceMapFilename, "utf8", function (mapErr, sourceMap) {
|
||||
if (mapErr) {
|
||||
//if no sourcemap was provided we silently ignore
|
||||
if (sourceMapFilename !== "") console.warn("No sourcemap found at " + sourceMapFilename + ".");
|
||||
sourceMap = "";
|
||||
}
|
||||
var filename = "no-filename-specified";
|
||||
var serialized = void 0;
|
||||
try {
|
||||
serialized = (0, _prepackStandalone2.prepackSources)([{ filePath: filename, fileContents: code, sourceMapContents: sourceMap }], options);
|
||||
} catch (err) {
|
||||
callback(err, null);
|
||||
return;
|
||||
}
|
||||
callback(null, serialized);
|
||||
});
|
||||
});
|
||||
} /**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/*
|
||||
Prepack API functions that require Node as the execution environment for Prepack.
|
||||
*/
|
||||
|
||||
function prepackFile(filename) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _options.defaultOptions;
|
||||
var callback = arguments[2];
|
||||
var fileErrorHandler = arguments[3];
|
||||
|
||||
if (options.compatibility === "node-cli") {
|
||||
(0, _prepackNodeEnvironment2.prepackNodeCLI)(filename, options, callback);
|
||||
return;
|
||||
}
|
||||
var sourceMapFilename = options.inputSourceMapFilename || filename + ".map";
|
||||
_fs2.default.readFile(filename, "utf8", function (fileErr, code) {
|
||||
if (fileErr) {
|
||||
if (fileErrorHandler) fileErrorHandler(fileErr);
|
||||
return;
|
||||
}
|
||||
_fs2.default.readFile(sourceMapFilename, "utf8", function (mapErr, sourceMap) {
|
||||
if (mapErr) {
|
||||
console.warn("No sourcemap found at " + sourceMapFilename + ".");
|
||||
sourceMap = "";
|
||||
}
|
||||
var serialized = void 0;
|
||||
try {
|
||||
serialized = (0, _prepackStandalone2.prepackSources)([{ filePath: filename, fileContents: code, sourceMapContents: sourceMap }], options);
|
||||
} catch (err) {
|
||||
callback(err, null);
|
||||
return;
|
||||
}
|
||||
callback(null, serialized);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function prepackFileSync(filenames) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _options.defaultOptions;
|
||||
|
||||
if (options.compatibility === "node-cli") {
|
||||
if (filenames.length !== 1) {
|
||||
console.error("Does not support multiple file prepack in node-cli mode.");
|
||||
process.exit(1);
|
||||
}
|
||||
return (0, _prepackNodeEnvironment2.prepackNodeCLISync)(filenames[0], options);
|
||||
}
|
||||
var sourceFiles = filenames.map(function (filename) {
|
||||
var code = _fs2.default.readFileSync(filename, "utf8");
|
||||
var sourceMap = "";
|
||||
var sourceMapFilename = options.inputSourceMapFilename || filename + ".map";
|
||||
try {
|
||||
sourceMap = _fs2.default.readFileSync(sourceMapFilename, "utf8");
|
||||
} catch (_e) {
|
||||
if (options.inputSourceMapFilename) console.warn("No sourcemap found at " + sourceMapFilename + ".");
|
||||
}
|
||||
return { filePath: filename, fileContents: code, sourceMapContents: sourceMap };
|
||||
});
|
||||
var debugChannel = void 0;
|
||||
if (options.debugInFilePath && options.debugOutFilePath) {
|
||||
var debugOptions = (0, _prepackOptions.getDebuggerOptions)(options);
|
||||
var ioWrapper = new _FileIOWrapper.FileIOWrapper(false, debugOptions.inFilePath, debugOptions.outFilePath);
|
||||
debugChannel = new _DebugChannel.DebugChannel(ioWrapper);
|
||||
}
|
||||
return (0, _prepackStandalone2.prepackSources)(sourceFiles, options, debugChannel);
|
||||
}
|
||||
//# sourceMappingURL=prepack-node.js.map
|
||||
Reference in New Issue
Block a user