Documentation

    Interface PakkOptions

    interface PakkOptions {
        autoPrettier?: boolean;
        binBaseDir?: string;
        binIgnore?: string[];
        bins?: string | string[];
        cwd?: string;
        defaultBinIgnore?: string[];
        defaultExportsIgnore?: string[];
        developmentPackageJsonExportsTarget?: "dist" | "source";
        disabledFeatures?: (
            | "bin"
            | "sort"
            | "copy-license"
            | "export"
            | "export-static"
            | "metadata"
            | "peer"
            | "directive"
            | "remove-workspace-directive"
        )[];
        dry?: boolean;
        dts?: boolean;
        enabledFeatures?: (
            | "bin"
            | "sort"
            | "copy-license"
            | "export"
            | "export-static"
            | "metadata"
            | "peer"
            | "directive"
            | "remove-workspace-directive"
        )[];
        enabledNpmHooks?: string[];
        exportBaseDir?: string;
        exportPackageJson?: boolean;
        exports?: string
        | string[];
        exportsIgnore?: string[];
        fallbackEntries?: Record<string, string>;
        keysFromWorkspace?: string[];
        logger?: Logger<unknown>;
        logLevel?: LogLevel;
        mandatoryKeys?: string[];
        outDir?: string;
        overrideEntries?: Record<string, string>;
        preserveImportAttributes?: boolean | "both" | "assert" | "with";
        shimDir?: string;
        sourcePackageJson?: string;
        srcDir?: string;
        staticExports?: string[];
        svelte?: boolean;
        targetPackageJsonKind?: PackageJsonKindType;
    }

    Hierarchy (View Summary)

    Index

    Properties

    autoPrettier?: boolean

    Formats the json file using prettier and your configuration.

    Disable if you don't have prettier

    true
    
    binBaseDir?: string

    Relative path from srcDir if you want your exports to start from a different directory.

    'bin'
    
    binIgnore?: string[]

    What paths to ignore when collecting bins in addition to defaultBinIgnore so you're not dropping the defaults when you just want to add additional ignore entries.

    []
    
    bins?: string | string[]

    The files to treat as bins elative from the srcDir + binBaseDir directory. It's usually * meaning all files directly here are considered the entry points of the library.

    '*'
    
    cwd?: string

    Current working directory

    process.cwd()
    
    defaultBinIgnore?: string[]

    By default test files are excluded

    ['*.(spec|test).*']
    
    defaultExportsIgnore?: string[]

    By default test files are excluded.

    This option is here if you deliberately want to drop the default ignores. Otherwise use exportsIgnore.

    '*.(spec|test).*'
    
    developmentPackageJsonExportsTarget?: "dist" | "source"

    Where should exports point to in your development packageJson file

    By default, to let you develop locally with the same code as you'd publish, the development packageJson targets the outDir where your built package is supposed to be. This expects you to build the package before running it. (Turbo can orchestrate this for you!)

    But if you wish your local packages to use the source code directly you can set this to 'source' and then exports will point inside your 'src' folder. This can be useful for packages that are not transpiled and are supposed to be used as is.

    Types always point to the source dir so the typescript LSP can provide real-time feedback in other packages too without having to rebuild all the time!

    'dist'
    
    disabledFeatures?: (
        | "bin"
        | "sort"
        | "copy-license"
        | "export"
        | "export-static"
        | "metadata"
        | "peer"
        | "directive"
        | "remove-workspace-directive"
    )[]

    If left empty, all features will remain enabled. Takes precedence over 'enabledFeatures'

    dry?: boolean

    Actual operations are turned off when dry is set to true.

    For example Post requests won't be made, filesystem operations won't write, but still send get requests and read from filesystem.

    false
    
    dts?: boolean

    Generate dts definitions using https://github.com/qmhc/vite-plugin-dts

    enabledFeatures?: (
        | "bin"
        | "sort"
        | "copy-license"
        | "export"
        | "export-static"
        | "metadata"
        | "peer"
        | "directive"
        | "remove-workspace-directive"
    )[]

    If left empty, all features will remain enabled. Except the disabled ones

    enabledNpmHooks?: string[]

    If a bin's name matches with an entry here (which is by default every NPM hook, 'postinstall' 'prebuild' etc.) then it will be automatically added to your packageJson file's scripts. To not interfere with development, hooks invoked during install are disabled for the source packageJson and are only avilable in the distributed packageJson.

    ALL_NPM_HOOKS
    
    exportBaseDir?: string

    Relative path to srcDir if you want your exports to start from a different directory.

    With the default settings src/index.ts will be the "." export
    on your package json. If `exportBaseDir` is set to 'api' then
    "src/api/index.ts" will be the "." export. If on top of this, you
    change exports to be ["*", "sub/*"]
    '.'
    
    exportPackageJson?: boolean

    Whether or not automatically export the package.json file too.

    Note: If you want to refer to the actual distributed package.json in your scripts, you should import it through an export and not use a direct json import, your bundler will bundle your compile time package.json in, and your users will end up using that information, not what was published.

    true
    
    exports?: string | string[]

    The files to treat as entry points to be exported from relative from the srcDir + exportBaseDir directory. It's usually * meaning all files directly here are considered the entry points of the library.

    '*'
    
    exportsIgnore?: string[]

    What paths to ignore when collecting exports in addition to defaultExportsIgnore so you're not dropping the defaults when you just want to add additional ignore entries.

    undefiend
    
    fallbackEntries?: Record<string, string>

    A set of key value pairs that will only be used as packageJson values when not found in the workspace packageJson

    {}
    
    keysFromWorkspace?: string[]

    A list of packageJson keys from the workspace root package.json to autofill in built artifacts

    Keys already present in the package's packageJson file will take precendence if they are objects or arrays, otherwise overwritten

    DEFAULT_AUTO_METADATA_KEYS_FROM_WORKSPACE - ["license", "author", "homepage", "bugs", "keywords", "config", "engines"]
    
    logger?: Logger<unknown>

    An optional Logger target.

    undefined
    
    logLevel?: LogLevel

    A minimum logLevel

    LogLevel.INFO
    
    mandatoryKeys?: string[]

    Keys that you must define yourself. This plugin can't figure them out for you, but it can add their keys as empty values into the source packageJson. When one is missing or empty, the build is aborted!

    DEFAULT_AUTO_METADATA_MANDATORY_KEYS - ["name", "description", "version"]
    
    outDir?: string

    The expected output directory relative to the package's directory.

    'dist'
    
    overrideEntries?: Record<string, string>

    A set of key value pairs that will always be used and overwrite everything else

    {}
    
    preserveImportAttributes?: boolean | "both" | "assert" | "with"

    An option to preserve import attributes in output bundles. It can preserve both 'assert' and 'with' attributes but by default it only keeps asserts.

    Set to false to turn it off.

    'assert'
    
    shimDir?: string

    A directory where shims for the built bins would be placed All these scripts do is to import the yet-to-be-built binary so package managers hava something to symlink to before it's built.

    ! This folder has to be ignored by typescript as it contains broken ! imports before the package is built

    'shims'
    
    sourcePackageJson?: string

    packageJson to modify and put in the artifact, relative to the package's directory.

    'package.json'
    
    srcDir?: string

    Source root, relative to the package directory

    'src'
    
    staticExports?: string[]

    Relative to cwd, a folder whats content will be simply copied to outDir and made available using simple, additional export statements. Make sure their names don't overlap with other exports!

    ["readme.md", "static/\*\*", "export/**"]
    
    svelte?: boolean

    Add svelte export conditions or not

    false
    
    targetPackageJsonKind?: PackageJsonKindType

    Which packageJson to act on. Will do both when left empty.

    • 'development': the one in your packages folder that you yourself edit too
    • 'distribution': the one that is coped to the 'dist' folder

    By default is undefined, meaning both.

    undefined
    
    MMNEPVFCICPMFPCPTTAAATR