mirror of
https://github.com/hanzoai/protobuf.js.git
synced 2026-09-24 17:02:08 +00:00
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
"use strict";
|
|
module.exports = static_module_target;
|
|
|
|
// - The default wrapper supports AMD, CommonJS and the global scope (as window.root), in this order.
|
|
// - You can specify a custom wrapper with the --wrap argument.
|
|
// - CommonJS modules depend on the minimal build for reduced package size with browserify.
|
|
// - AMD and global scope depend on the full library for now.
|
|
|
|
var util = require("../util"),
|
|
protobuf = require("protobufjs");
|
|
|
|
static_module_target.description = "Static code without reflection as a module";
|
|
|
|
static_module_target.getDependency = function getDependency(options) {
|
|
return options.dependency || (util.isEsmWrapper(options.wrap)
|
|
? "protobufjs/minimal.js"
|
|
: "protobufjs/minimal");
|
|
};
|
|
|
|
function static_module_target(root, options, callback) {
|
|
require("./static")(root, options, function(err, output) {
|
|
if (err) {
|
|
callback(err);
|
|
return;
|
|
}
|
|
try {
|
|
output = util.wrap(output, protobuf.util.merge({
|
|
dependency: static_module_target.getDependency(options)
|
|
}, options));
|
|
} catch (e) {
|
|
callback(e);
|
|
return;
|
|
}
|
|
callback(null, output);
|
|
});
|
|
}
|