Socket
Socket
Sign inDemoInstall

tsup

Package Overview
Dependencies
Maintainers
1
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsup - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

122

dist/cli.js

@@ -644,2 +644,13 @@ #!/usr/bin/env node

class PrettyError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = new Error(message).stack;
}
}
}
function handlError(error) {

@@ -653,3 +664,7 @@ if (error.loc) {

} else {
console.error(index.colorette.red(error.stack));
if (error instanceof PrettyError) {
console.error(index.colorette.red(error.message));
} else {
console.error(index.colorette.red(error.stack));
}
}

@@ -660,26 +675,29 @@ process.exitCode = 1;

let __assign = Object.assign;
const cli = dist_1("tsup");
cli.command("<...files>", "Bundle files").option("-d, --out-dir <dir>", "Output directory", {
default: "dist"
}).option("--format <format>", 'Bundle format, "cjs", "iife", "umd", "esm"', {
default: "cjs"
}).option("--minify", "Minify bundle").option("--target <target>", 'Bundle target, "es20XX" or "esnext"', {
default: "es2017"
}).option("--bundle", "Bundle node_modules").option("--dts", "Generate declaration file").option("--dts-bundle", "Bundle types from node_modules").option("--watch", "Watch mode").option("--define.* <value>", "Define compile-time constants").option("--external <name>", "Mark specific packages as external (use with --bundle)").option("--module-name <name>", "Module name (with with --format umd)").option("--jsxFactory <jsxFactory>", "Name of JSX factory function", {
default: "React.createElement"
}).option("--jsxFragment <jsxFragment>", "Name of JSX fragment function", {
default: "React.Fragment"
}).option("--inlineDynamicImports", "Create a single bundle that inlines dynamic imports").action(async (files, options) => {
const {rollup, watch} = await Promise.resolve().then(function () { return _interopNamespace(require('rollup')); });
const {createRollupConfigs, printSizes} = await Promise.resolve().then(function () { return require('./index.js'); });
const rollupConfigs = await createRollupConfigs(files, options);
if (options.watch) {
const watcher = watch(rollupConfigs.map((config) => __assign(__assign({}, config.inputConfig), {
output: config.outputConfig
})));
watcher.on("event", (event) => {
console.log(event);
});
} else {
try {
async function main() {
const cli = dist_1("tsup");
cli.command("[...files]", "Bundle files").option("-d, --out-dir <dir>", "Output directory", {
default: "dist"
}).option("--format <format>", 'Bundle format, "cjs", "iife", "umd", "esm"', {
default: "cjs"
}).option("--minify", "Minify bundle").option("--target <target>", 'Bundle target, "es20XX" or "esnext"', {
default: "es2017"
}).option("--bundle", "Bundle node_modules").option("--dts", "Generate declaration file").option("--dts-bundle", "Bundle types from node_modules").option("--watch", "Watch mode").option("--define.* <value>", "Define compile-time constants").option("--external <name>", "Mark specific packages as external (use with --bundle)").option("--module-name <name>", "Module name (with with --format umd)").option("--jsxFactory <jsxFactory>", "Name of JSX factory function", {
default: "React.createElement"
}).option("--jsxFragment <jsxFragment>", "Name of JSX fragment function", {
default: "React.Fragment"
}).option("--inlineDynamicImports", "Create a single bundle that inlines dynamic imports").action(async (files, options) => {
if (files.length === 0) {
throw new PrettyError(`Missing input files, e.g. tsup src/index.ts`);
}
const {rollup, watch} = await Promise.resolve().then(function () { return _interopNamespace(require('rollup')); });
const {createRollupConfigs, printSizes} = await Promise.resolve().then(function () { return require('./index.js'); });
const rollupConfigs = await createRollupConfigs(files, options);
if (options.watch) {
const watcher = watch(rollupConfigs.map((config) => __assign(__assign({}, config.inputConfig), {
output: config.outputConfig
})));
watcher.on("event", (event) => {
console.log(event);
});
} else {
const startTime = Date.now();

@@ -699,33 +717,31 @@ await Promise.all(rollupConfigs.map(async (config) => {

console.log(`Done in ${endTime - startTime}ms`);
} catch (error) {
handlError(error);
}
}
});
cli.command("run <file>", "Bundle and execute a file", {
allowUnknownOptions: true
}).option("--define.* <value>", "Define compile-time constants").action(async (file, options) => {
const extraArgs = process.argv.slice(process.argv.indexOf(file) + 1);
const {rollup} = await Promise.resolve().then(function () { return _interopNamespace(require('rollup')); });
const {createRollupConfigs} = await Promise.resolve().then(function () { return require('./index.js'); });
const {runCode} = await Promise.resolve().then(function () { return require('./run-464599b3.js'); });
const [rollupConfig] = await createRollupConfigs([file], {
define: options.define,
outDir: "dist",
format: "cjs",
target: "es2017"
});
const bundle = await rollup(rollupConfig.inputConfig);
const {output} = await bundle.write(rollupConfig.outputConfig);
runCode(path.join("dist", output[0].fileName), {
args: extraArgs
cli.command("run <file>", "Bundle and execute a file", {
allowUnknownOptions: true
}).option("--define.* <value>", "Define compile-time constants").action(async (file, options) => {
const extraArgs = process.argv.slice(process.argv.indexOf(file) + 1);
const {rollup} = await Promise.resolve().then(function () { return _interopNamespace(require('rollup')); });
const {createRollupConfigs} = await Promise.resolve().then(function () { return require('./index.js'); });
const {runCode} = await Promise.resolve().then(function () { return require('./run-464599b3.js'); });
const [rollupConfig] = await createRollupConfigs([file], {
define: options.define,
outDir: "dist",
format: "cjs",
target: "es2017"
});
const bundle = await rollup(rollupConfig.inputConfig);
const {output} = await bundle.write(rollupConfig.outputConfig);
runCode(path.join("dist", output[0].fileName), {
args: extraArgs
});
});
});
cli.help();
const pkgPath = path.join(__dirname, "../package.json");
cli.version(JSON.parse(fs.readFileSync(pkgPath, "utf8")).version);
try {
cli.parse();
} catch (error) {
handlError(error);
cli.help();
const pkgPath = path.join(__dirname, "../package.json");
cli.version(JSON.parse(fs.readFileSync(pkgPath, "utf8")).version);
cli.parse(process.argv, {
run: false
});
await cli.runMatchedCommand();
}
main().catch(handlError);
{
"name": "tsup",
"version": "1.5.0",
"version": "1.5.1",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "bin": "dist/cli.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc