allowedExportExtensions

Additional file extensions to consider valid in exports field validation

allowedExportExtensions

Additional file extensions to consider valid in exports field validation. These will be added to the standard valid extensions.

Type

allowedExportExtensions?: string[]

Default

undefined (only standard extensions are allowed)

Description

By default, packem validates that export paths in your package.json have valid file extensions. The standard valid extensions are:

  • .js, .mjs, .cjs - JavaScript files
  • .ts, .mts, .cts - TypeScript files
  • .d.ts, .d.mts, .d.cts - TypeScript declaration files
  • .jsx, .tsx - React files
  • .json - JSON files
  • .node - Node.js native addons

Use extraExportExtensions to add custom extensions for assets like images, CSS files, or other non-JavaScript files.

Examples

Basic Usage

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

export default defineConfig({
    validation: {
        packageJson: {
            allowedExportExtensions: [".svg", ".css", ".png", ".jpg", ".jpeg", ".gif", ".webp"],
        },
    },
});

With package.json exports

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

With allowedExportExtensions: [".svg", ".css"], these export paths will be considered valid and won't generate warnings.

Common Asset Extensions

Here are some common extensions you might want to add:

allowedExportExtensions: [
    // Images
    ".svg", ".png", ".jpg", ".jpeg", ".gif", ".webp", ".ico", ".bmp", ".tiff",
    // Styles
    ".css", ".scss", ".sass", ".less", ".styl",
    // Fonts
    ".woff", ".woff2", ".ttf", ".eot", ".otf",
    // Documents
    ".pdf", ".md", ".txt",
    // Data
    ".xml", ".yaml", ".yml", ".toml"
]

Notes

  • Extensions should include the leading dot (e.g., ".svg" not "svg")
  • This option only affects validation warnings, not the actual build process
  • Use in combination with ignoreExportKeys to exclude asset exports from build processing
  • Use with rollup.copy to 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