ignoreExportKeys

Array of export keys to ignore during entry inference

ignoreExportKeys

Array of export keys to ignore during entry inference. Useful for excluding exports that only contain images or other non-JavaScript assets.

Type

ignoreExportKeys?: string[]

Default

undefined (no exports are ignored)

Description

When packem processes your package.json exports, it tries to find corresponding source files for each export. However, some exports may only contain non-JavaScript assets (like images, CSS files, etc.) that don't have corresponding source files to build.

By default, packem will generate warnings for exports where it can't find source files. Use ignoreExportKeys to tell packem to skip these exports entirely.

Examples

Basic Usage

// packem.config.ts
import type { BuildConfig } from "@visulima/packem";

const config: BuildConfig = {
  ignoreExportKeys: ["images", "assets", "styles"],
};

export default config;

With package.json exports

{
  "exports": {
    ".": "./dist/index.mjs",
    "./images": "./dist/images/icon.png",
    "./assets": "./dist/assets/logo.svg",
    "./styles": "./dist/styles.css"
  }
}

With ignoreExportKeys: ["images", "assets", "styles"], only the main export (".") will be processed as a build entry.

With wildcard patterns

{
  "exports": {
    ".": "./dist/index.mjs",
    "./icons/*": "./dist/icons/*",
    "./assets/*": "./dist/assets/*"
  }
}

With ignoreExportKeys: ["icons", "assets"], both "./icons/*" and "./assets/*" wildcard patterns will be ignored, and only the main export (".") will be processed as a build entry.

CLI Usage

packem build --ignore-export-keys=images,assets,styles

Notes

  • Export keys are matched without the ./ prefix (e.g., "./images" matches "images")
  • Wildcard patterns are supported: Export keys starting with the ignored key are also ignored (e.g., "images" will ignore both "./images" and "./images/*")
  • Ignored exports are still included in the final package.json for consumers
  • No warnings are generated for ignored exports
  • Works with both simple string exports and nested conditional exports

When using ignoreExportKeys with asset exports, you may also want to configure:

  • validation.packageJson.allowedExportExtensions - Add custom file extensions to the valid export extensions list
  • rollup.copy - Copy asset files to the output directory
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues