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 2.0.0 to 2.0.1

dist/index-d3f0c5a5.js

191

dist/cli.js

@@ -29,6 +29,6 @@ #!/usr/bin/env node

var path__default = _interopDefault(path);
var index = require('./index-80983253.js');
var index$1 = require('./index-d3f0c5a5.js');
var events = _interopDefault(require('events'));
var dist = index.createCommonjsModule(function (module, exports) {
var dist = index$1.createCommonjsModule(function (module, exports) {

@@ -640,99 +640,118 @@ Object.defineProperty(exports, '__esModule', { value: true });

index.unwrapExports(dist);
var dist_1 = dist.cac;
var dist_2 = dist.CAC;
var dist_3 = dist.Command;
var index = /*@__PURE__*/index$1.unwrapExports(dist);
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;
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) {
if (error.loc) {
console.error(index.colorette.bold(index.colorette.red(`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`)));
}
if (error.frame) {
console.error(index.colorette.red(error.message));
console.error(index.colorette.dim(error.frame));
} else {
if (error instanceof PrettyError) {
console.error(index.colorette.red(error.message));
} else {
console.error(index.colorette.red(error.stack));
if (error.loc) {
console.error(index$1.colorette.bold(index$1.colorette.red(`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`)));
}
}
process.exitCode = 1;
if (error.frame) {
console.error(index$1.colorette.red(error.message));
console.error(index$1.colorette.dim(error.frame));
}
else {
if (error instanceof PrettyError) {
console.error(index$1.colorette.red(error.message));
}
else {
console.error(index$1.colorette.red(error.stack));
}
}
process.exitCode = 1;
}
var __assign = Object.assign;
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("--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();
await Promise.all(rollupConfigs.map(async (config) => {
var _a;
try {
const result = await rollup(config.inputConfig);
await result.write(config.outputConfig);
} catch (err) {
console.error(`Failed with following plugins used: ${(_a = config.inputConfig.plugins) == null ? void 0 : _a.map((p) => p.name).join(", ")}`);
throw err;
const cli = index.cac('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('--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`);
}
}));
printSizes();
const endTime = Date.now();
console.log(`Done in ${endTime - startTime}ms`);
}
});
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-85969e85.js'); });
const [rollupConfig] = await createRollupConfigs([file], {
define: options.define,
outDir: "dist",
format: "cjs"
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) => ({
...config.inputConfig,
output: config.outputConfig,
})));
watcher.on('event', (event) => {
console.log(event);
});
}
else {
const startTime = Date.now();
await Promise.all(rollupConfigs.map(async (config) => {
var _a;
try {
const result = await rollup(config.inputConfig);
await result.write(config.outputConfig);
}
catch (err) {
console.error(`Failed with following plugins used: ${(_a = config.inputConfig.plugins) === null || _a === void 0 ? void 0 : _a.map((p) => p.name).join(', ')}`);
throw err;
}
}));
printSizes();
const endTime = Date.now();
console.log(`Done in ${endTime - startTime}ms`);
}
});
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-e6893bf5.js'); });
const [rollupConfig] = await createRollupConfigs([file], {
define: options.define,
outDir: 'dist',
format: 'cjs',
});
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);
cli.parse(process.argv, {run: false});
await cli.runMatchedCommand();
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": "2.0.0",
"version": "2.0.1",
"main": "dist/index.js",

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

"ts-jest": "^26.1.1",
"tsup": "^1.5.1",
"tsup": "^2.0.0",
"typescript": "^3.9.6"
}
}

Sorry, the diff of this file is too big to display

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