5.0.0 • Published 24 days ago

@strapi/pack-up v5.0.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
24 days ago

pack-up is a set of simple tools for creating interoperable CJS & ESM packages.

Setting up a new interoperable project is as easy as doing:

npx @strapi/pack-up@latest init my-package

cd my-package

npm run build

Just a small bit about us:

  • Vite: We support vite as a JS bundler, no need to install it though as it's preprepared with helpful defaults ready to tackle all projects.
  • Concise: It's all based off your package.json so you know the interoperable aspect is correctly set up and there's no requirement for another config!
  • Flexible: Need more customisation or to bundle a package not declared in your exports? Use the config file to dictate separate bundles & options.

Getting Started

If you're setting up a brand new package we recommend you use the init command to get started:

npx @strapi/pack-up@latest init my-package

But if you're adding this to an existing project then just install like every other dependency:

npm install @strapi/pack-up@latest --save-dev

And to help you ensure your package is set up correctly run the check command:

npm run pack-up check

Run pack-up -h for more information on CLI usage.

Commands

init [path]

Creates a new package at the given path, by default uses the inbuilt template sensible options for your package to choose from.

  • --template [path] – path to a custom template of type TemplateOrTemplateResolver.

build

Builds your current package based on the configuration in your package.json and package.config.ts (if applicable).

  • --minify – minifies the output (default false).
  • --sourcemap – generates sourcemaps for the output (default true).

check

Checks your current package to ensure it's interoperable in the real world. In short, validates the files in your dist have been produced as we expect & then esbuild can actually build, using your exported code.

watch

Watches your current package for changes and rebuilds when necessary.

Configuration

@strapi/pack-up by default reads its configuration from your package.json. But sometimes you need more flexibility, to do this you can create a package.config.ts file in the root of your package.

// package.config.ts
import { defineConfig } from '@strapi/pack-up';

export default defineConfig({
  minify: true,
  sourcemap: false,
  externals: ['path', 'fs'],
});

Options

bundles

  • Type: ConfigBundle[]

An array of entry points to bundle. This is useful if you want to bundle something that should not be exported by the package, e.g. CLI scripts or Node.js workers.

dist

  • Type: string

The path to the directory to which the bundled files should be written.

externals

  • Type: string[]

An array of modules that should not be bundled but instead be resolved at runtime, this is by default the dependencies listed in your package.json (excluding devDeps).

minify

  • Type: boolean

Whether to minify the output or not.

sourcemap

  • Type: boolean

Whether to generate sourcemaps for the output or not.

runtime

  • Type: Runtime

The transpilation target of the bundle. This is useful if you're bundling many different CLIs or Node.js workers and you want them to be transpiled for the node environment.

5.0.0-beta.3

28 days ago

5.0.0

28 days ago

4.23.0

29 days ago

4.22.1

1 month ago

5.0.0-beta.2

1 month ago

4.22.0

1 month ago

5.0.0-beta.1

1 month ago

5.0.0-alpha.7

1 month ago

5.0.0-alpha.6

1 month ago

5.0.0-alpha.8

1 month ago

4.21.1

1 month ago

5.0.0-beta.0

2 months ago

5.0.0-alpha.5

2 months ago

5.0.0-alpha.4

2 months ago

5.0.0-alpha.3

2 months ago

4.21.0

2 months ago

5.0.0-alpha.2

2 months ago

5.0.0-alpha.1

2 months ago

5.0.0-alpha.0

2 months ago

4.20.5

2 months ago

4.20.4

2 months ago

4.20.3

2 months ago

4.20.2

3 months ago

4.20.1

3 months ago

4.20.0

3 months ago

4.19.1

3 months ago

4.19.0

4 months ago

4.17.1

4 months ago

4.18.0

4 months ago

4.18.1-beta.0

4 months ago

4.18.1-beta.1

4 months ago

4.17.0

4 months ago

4.16.1

5 months ago

4.16.2

5 months ago

4.16.0

5 months ago

4.15.5

5 months ago

4.15.5-alpha.6

5 months ago

4.15.5-alpha.5

6 months ago

4.15.5-alpha.4

6 months ago

4.15.5-alpha.3

6 months ago

4.15.5-alpha.2

6 months ago

4.15.5-alpha.1

6 months ago

4.15.5-alpha.0

6 months ago

4.15.4

6 months ago

4.15.3

6 months ago

4.15.3-alpha.3

6 months ago

4.15.3-alpha.2

6 months ago

4.15.3-alpha.1

6 months ago

4.15.3-alpha.0

6 months ago

4.15.2

6 months ago

4.14.6

6 months ago

4.15.1

6 months ago

4.15.0

7 months ago

4.14.5

7 months ago

4.14.4

7 months ago

4.15.0-alpha.0

7 months ago