0.3.4 • Published 11 months ago

ptsup v0.3.4

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

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
0.3.4

11 months ago

0.3.3

11 months ago

0.3.2

1 year ago

0.3.0

1 year ago

0.2.3

1 year ago

0.3.1

1 year ago

0.2.2

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6-beta.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.1

2 years ago