Closed lonnywong closed 2 years ago
I can not find problem at first glance, but take a look at https://github.com/lvgl/lv_font_conv/blob/master/lib/cli.js, may be that can help.
@puzrin Thanks.
It must be a rollup
issue.
var argparse = {exports: {}};
(function (module) {
// Copyright (C) 2010-2020 Python Software Foundation.
// Copyright (C) 2020 argparse.js authors
/////////// The argparse.js source ///////////
// end
}(argparse));
var BufferSizeParser = /** @class */ (function (_super) {
__extends(BufferSizeParser, _super);
function BufferSizeParser(options) {
var _this = this;
var minSize = options.min_size;
var maxSize = options.max_size;
delete options.min_size;
delete options.max_size;
if (typeof options["default"] === "string") {
options["default"] = BufferSizeParser.parseSize(options["default"]);
}
_this = _super.call(this, options) || this;
_this.minSize = minSize;
_this.maxSize = maxSize;
return _this;
}
BufferSizeParser.parseSize = function (value) {
var _a;
var match = /^(\d+)(k|m|g|kb|mb|gb)?$/i.exec(value);
if (!match) {
throw new TypeError("invalid size");
}
var sizeValue = parseInt(match[1]);
var unitSuffix = (_a = match[2]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
if (!unitSuffix) {
return sizeValue;
}
if (unitSuffix == "k" || unitSuffix == "kb") {
return sizeValue * 1024;
}
if (unitSuffix == "m" || unitSuffix == "mb") {
return sizeValue * 1024 * 1024;
}
if (unitSuffix == "g" || unitSuffix == "gb") {
return sizeValue * 1024 * 1024 * 1024;
}
return undefined;
};
BufferSizeParser.prototype.call = function (parser, namespace, values /* , option_string = undefined */) {
var bufSize = BufferSizeParser.parseSize(values);
if (this.minSize && bufSize < BufferSizeParser.parseSize(this.minSize)) {
throw new TypeError("less than ".concat(this.minSize));
}
if (this.maxSize && bufSize > BufferSizeParser.parseSize(this.maxSize)) {
throw new TypeError("greater than ".concat(this.maxSize));
}
// @ts-ignore
namespace[this.dest] = bufSize;
};
return BufferSizeParser;
}(argparse.exports.Action));
var parser = new argparse.exports.ArgumentParser({
description: "Argparse example",
formatter_class: argparse.exports.RawTextHelpFormatter
});
parser.add_argument("-B", "--bufsize", {
min_size: "1K",
max_size: "100M",
"default": "1M",
action: BufferSizeParser,
metavar: "N",
help: "buffer chunk size ( 1K <= N <= 100M ). (default: 1M)"
});
console.dir(parser.parse_args());
Closing?
Is there something incompatible with rollup
?
import typescript from "@rollup/plugin-typescript";
import commonjs from "@rollup/plugin-commonjs";
export default [ { input: "src/trz.ts", output: { file: "lib/trz.js", format: "cjs", sourcemap: true, }, plugins: [typescript(), commonjs()], }, ];
I change TypeScript to CommonJS, and it works.
How to make a custom Action?
The error: