ptsup
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

ptsup

npm version

tsup is similar but focuses more on packet processing, powered by esbuild.

what's the difference?

  • A more casual package directory
  • carry meta options
  • carry assets options(.png, .html,...more)
  • more universal

⚙️ Install

Install it locally in your project folder:

pnpm add ptsup --dev
# Or Yarn
yarn add ptsup --dev

You can also install it globally but it's not recommended.

📖 Usage

Bundle files

ptsup [...file]

Files are written into ./dist.

You can bundle multiple files in one go:

ptsup src/index.ts src/bin/bin.ts

This will output dist/index.cjs.js; dist/index.esm.js and dist/bin.cjs.js; dist/bin.esm.js.

Unlike tsup, ptsup is more suitable for a single independent entry file, ptsup does not preserve the directory structure

build directory

ptsup [...directory]

Files are written into ./dist.

You can build dir in one go:

src
 - bin
   index.ts
 index.ts
ptsup src

This will output:

dist
 - bin
   index.js
 index.js

You can build multiple directories at once, but it is recommended to use only one directory as filename duplicates will be overwritten

carry meta

use command --meta It works well on some monorepo (pnpm,yarn,npm) applications

  • carry package info (LICENSE, README.md, CHANGELOG.md)
  • handle package.publishConfig and carry package.json
  • create node_modules lnk file to output(default dist)

Using custom configuration

Like tsup, you can use the config file to configure

Supported file formats

  • ptsup.config.ts
  • ptsup.config.js
  • ptsup.config.cjs
  • ptsup.config.json

TypeScript / JavaScript

import { defineConfig } from 'ptsup'

export default defineConfig({
  entry: ['src/index.ts'],
  splitting: false,
  sourcemap: true,
  clean: true,
})

carry assets

You can carry static resources that your project depends on

use command --assets aaa.png,xxx.vue,assetsDir

defines it like this in defineConfig

import { defineConfig } from 'ptsup'

export default defineConfig({
  assets: [
    'aaa.png',
    'xxx.vue',
    'assetsDir'
  ]
})

command line options

Usage:
  $ ptsup [...files/directorys]

Commands:
  [...files/directorys]  Bundle files

For more info, run any command with the `--help` flag:
  $ ptsup --help

Options:
  --entry <directory|file>   Use a key-value pair as entry directory|files (default: ./)
  -r, --root <dir>           Root directory (default: .)
  -o, --outdir <outdir>      Output directory (default: dist)
  -f, --format <format>      Bundle format, "cjs", "iife", "esm" (default: cjs)
  --sourcemap [inline]       Generate external sourcemap, or inline source: --sourcemap inline
  --minify                   Minify bundles only for iife
  --target <target>          Bundle target, "es20XX" or "esnext" (default: esnext)
  --dts [entry]              Generate declaration file
                             If entry is not passed in, it will be created based on the compiled file by default
  --dts-only                 Emit declaration files only
  --global-name <name>       Global variable name for iife format (default: package.name in pascal-case)
  --clean                    Clean output directory
  --meta                     Helper and carry package.json/*.md
  --meta-only                Emit meta files only
  --metafile                 Emit esbuild metafile to use with Bundle Size Analyzer (default: false)
  --splitting                Enables esbuild "code splitting", enable cast to esm module
  --assets [files]           Carry some static resources
  --jsxFactory <jsxFactory>  Name of JSX factory function (default: React.createElement)
  --platform <node|browser>  Platform determines the format of the output (default: node)
                             platform->node:    cjs,esm
                             platform->browser: cjs,esm,iife
  -h, --help                 Display this message

Package Sidebar

Install

npm i ptsup

Weekly Downloads

6

Version

0.3.5

License

MIT

Unpacked Size

43.2 kB

Total Files

28

Last publish

Collaborators

  • tuimao