pnpm pack
Створити tar-архів з пакунка.
Files included in the tarball#
Use the files field in package.json to select files and directories. Patterns
support extglobs such as lib/!(*.test.js) and @(dist|lib). A files field
replaces the root .npmignore or .gitignore; ignore files inside selected
subdirectories still apply. An explicitly named file or internal symlink is
included even when its parent directory is excluded.
Brace ranges expand to individual values. For example, part{1..3}.js
matches part1.js, part2.js, and part3.js, and part{a..c}.js matches
parta.js, partb.js, and partc.js. Ranges support descending values,
steps such as part{1..5..2}.js, and zero padding such as part{01..03}.js.
A zero step uses the default increment of 1. Padding in a step such as
part{1..10..02}.js also pads the results to the wider endpoint's width.
These ranges also work in .npmignore and .gitignore.
Without files, pnpm reads .npmignore, falling back to .gitignore.
Negated ignore patterns can re-include default exclusions such as *.orig and
npm-debug.log. Root lockfiles and .npmrc stay excluded.
Private workspace dependencies#
A package that is not private cannot list a private workspace package in
dependencies, because the private package is never published. Packing
such a package fails with ERR_PNPM_PRIVATE_WORKSPACE_DEPENDENCY. List the
private package in devDependencies instead, bundle it by listing it in
bundleDependencies with it installed, or remove the dependency in a
beforePacking hook.
Параметри#
--recursive, -r#
Запакувати всі пакунки з робочого простору.
--out <path>#
Налаштовує вихідний шлях для архіву. Використовуйте %s та %v, щоб включити назву та версію пакета, наприклад, %s.tgz або some-dir/%s-%v.tgz. Стандартно архів зберігається в поточній робочій теці з назвою <package-name><version>-.tgz.
--pack-destination <dir>#
Тека, в якій pnpm pack зберігатиме архіви. Стандартно використовується поточна робоча тека.
--pack-gzip-level <level>#
The gzip compression level of the tarball, from 0 to 9. Values outside that range are rejected.
--json#
Виводіть журнал у форматі JSON. Each archive written has an integrity, its SHA-512 in SRI form, and a size in bytes. A dry run writes no archive, so it prints neither.
The manifest field holds the package.json that goes into the tarball, after publishConfig and the other publish-time changes are applied. Run pnpm pack --dry-run --json to preview it without writing a tarball. A dry run still runs prepack and prepare, unless --ignore-scripts is passed.
--filter <package_selector>#
Читайте більше про фільтрування.
--dry-run#
Виконує всі дії звичайного запуску, окрім пакування tar-архіву. Корисно для перевірки вмісту tar-архіву.
--ignore-pnpmfile#
Don't load the project's .pnpmfile.cjs, so its hooks, including beforePacking, don't run.
--ignore-scripts#
Don't run the prepack, prepare, and postpack scripts.
--skip-manifest-obfuscation#
Keep the original packageManager field and publish lifecycle scripts in the packed manifest instead of stripping them. The pnpm field is still omitted, except for pnpm.config.
Life cycle scripts#
prepackpreparepostpack
підказка
Ви також можете скористатися хуком beforePacking, щоб програмно змінити вміст package.json перед створенням tar-архіву. Це корисно для видалення полів, призначених лише для розробки, або додавання метаданих публікації без зміни локального package.json.