{"_id":"@consensus.enterprises/pnp-vendorize","_rev":"1-9c05693ad5212898c7acaa8a805157b6","name":"@consensus.enterprises/pnp-vendorize","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@consensus.enterprises/pnp-vendorize","version":"1.0.0","license":"GPL-2.0-or-later","repository":{"type":"git","url":"git+https://gitlab.com/consensus.enterprises/misc/pnp-vendorize.git"},"homepage":"https://gitlab.com/consensus.enterprises/misc/pnp-vendorize","bugs":{"url":"https://gitlab.com/consensus.enterprises/misc/pnp-vendorize/-/issues"},"type":"module","main":"./src/index.mjs","exports":"./src/index.mjs","bin":{"vendorize":"src/bin.mjs"},"dependencies":{"@babel/core":"^7.20.2","@babel/preset-env":"^7.20.2","@symfony/webpack-encore":"^4.1.1","file-loader":"^6.0.0","webpack":"^5.88.2","webpack-cli":"^4.10.0"},"peerDependencies":{"@babel/core":"^7.20.2","@babel/preset-env":"^7.20.2","@symfony/webpack-encore":"^4.1.1","file-loader":"^6.0.0","webpack":"^5.88.2","webpack-cli":"^4.10.0"},"_id":"@consensus.enterprises/pnp-vendorize@1.0.0","gitHead":"1df5a8433c00f764770f75f0cea80c735530904a","description":"Copy front-end assets from a [Plug'n'Play](https://yarnpkg.com/features/pnp)-compliant package manager such as [Yarn](https://yarnpkg.com/) or [pnpm](https://pnpm.io/) into a publicly accessible vendor directory.","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-+N7j+Lw+Fq/Who/IPpQYFxtyIlmHJ6o9xCqjq1nR6w7wQYp0/P3P2qzPrCII6XDBrWt9pqbGAhpNNrNyNydlwQ==","shasum":"dbefa963f4e62c4814235a6a7dd4bc206f468888","tarball":"https://registry.npmjs.org/@consensus.enterprises/pnp-vendorize/-/pnp-vendorize-1.0.0.tgz","fileCount":8,"unpackedSize":37625,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICuuw0AR2iZodA1uGPSHks2LvYgHTMTy1K7DyFejcStiAiEAmTM427ywTgF7ylIcV6oaI5G6TizQPfDKe4/UzrDKygE="}]},"_npmUser":{"name":"ambient.impact","email":"i@ambientimpact.com"},"directories":{},"maintainers":[{"name":"ambient.impact","email":"i@ambientimpact.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pnp-vendorize_1.0.0_1709308528275_0.7255041245900833"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-01T15:55:28.151Z","1.0.0":"2024-03-01T15:55:28.479Z","modified":"2024-05-14T17:50:21.356Z"},"maintainers":[{"email":"mparker17.work@gmail.com","name":"mparker17"},{"email":"i@ambientimpact.com","name":"ambient.impact"}],"description":"Copy front-end assets from a [Plug'n'Play](https://yarnpkg.com/features/pnp)-compliant package manager such as [Yarn](https://yarnpkg.com/) or [pnpm](https://pnpm.io/) into a publicly accessible vendor directory.","homepage":"https://gitlab.com/consensus.enterprises/misc/pnp-vendorize","repository":{"type":"git","url":"git+https://gitlab.com/consensus.enterprises/misc/pnp-vendorize.git"},"bugs":{"url":"https://gitlab.com/consensus.enterprises/misc/pnp-vendorize/-/issues"},"license":"GPL-2.0-or-later","readme":"Copy front-end assets from a\n[Plug'n'Play](https://yarnpkg.com/features/pnp)-compliant package manager such\nas [Yarn](https://yarnpkg.com/) or [pnpm](https://pnpm.io/) into a publicly\naccessible vendor directory.\n\n# Why?\n\nBy design, package managers like Yarn when using the Plug'n'Play installation\nstrategy optimize for speed and portability of packages, but in order to\nactually make select vendor libraries web-accessible you have to either use\nsomething like [Webpack](https://webpack.js.org/) to extract and bundle them,\nor figure out the API yourself and hack together a solution.\n\nIf you're coming from the PHP world where [the Composer package\nmanager](https://getcomposer.org/) is the de facto standard in managing\ndependencies, and you're working with a content management system (CMS) like\n[Drupal](https://www.drupal.org/) that has its own framework for defining\nlibraries, handling dependency trees, and bundling them as needed for a given\nroute, then this package is for you. It's intended as a drop-in solution to make\nyour front-end package manager behave a bit more like Composer for certain\npackages.\n\n# What?\n\nLet's say you have `dependency1` and `dependency2` in your `package.json`:\n\n```javascript\n{\n  \"name\": \"my-package\",\n  // ...\n  \"dependencies\": {\n    // ...\n    \"dependency1\": \"^1.0.0\",\n    \"dependency2\": \"^1.0.0\",\n    // ...\n  }\n}\n\n```\n\nThen you do a [`yarn install`](https://yarnpkg.com/cli/install) or\n[`pnpm install`](https://pnpm.io/cli/install) and your package manager does its\nmagic to pull in the packages. Now they're in `.yarn/cache` or `node_modules`\nbut that's (hopefully) outside of your public web root. How do you make those\nspecific dependencies web accessible without writing custom code or bundling\nvia something like Webpack?\n\n# How?\n\n```bash\nyarn add '@consensus.enterprises/pnp-vendorize' --dev\n```\n\nor\n\n```bash\npnpm add '@consensus.enterprises/pnp-vendorize' --dev\n```\n\nNext, you need to define the subset of dependencies you want vendorized by\nadding a `\"vendorize\"` entry to your `package.json`:\n\n```javascript\n{\n  \"name\": \"my-package\",\n  // ...\n  \"dependencies\": {\n    // ...\n    \"dependency1\": \"^1.0.0\",\n    \"dependency2\": \"^1.0.0\",\n    // ...\n  },\n  \"vendorize\": [\n    \"dependency1\",\n    \"dependency2\"\n  ]\n}\n```\n\nNote that you must explicitly declare a package as a dependency. If you don't,\nVendorize will throw an error - even if the package has been installed by Yarn\nfrom another workspace in the same project.\n\nNow you can run `yarn run vendorize` or `pnpm run vendorize` and once it's\ncompleted, you'll find a `vendor` directory inside your package like so:\n\n```\nmy-package\n↳ vendor\n  ↳ dependency1\n    ↳ ...\n  ↳ dependency2\n    ↳ ...\n```\n\nYou can also automate this so you don't need to run the command yourself by\nadding it as a `postinstall` script:\n\n```javascript\n{\n  \"name\": \"my-package\",\n  // ...\n  \"scripts\": {\n    // ...\n    \"postinstall\": \"yarn run vendorize\",\n    // ...\n  },\n  // ...\n}\n```\n\nIf using pnpm, replace `yarn run vendorize` with `pnpm run vendorize` above.\n\nNow you only need to install your package and it'll automagically run Vendorize.\n\n# Advanced\n\nVendorize can be configured by converting the `vendorize` key in your\n`package.json` into an object with the array of packages to vendorize under a\n`packages` key like so:\n\n```javascript\n{\n  \"name\": \"my-package\",\n  // ...\n  \"dependencies\": {\n    // ...\n    \"dependency1\": \"^1.0.0\",\n    \"dependency2\": \"^1.0.0\",\n    // ...\n  },\n  \"vendorize\": {\n    \"packages\": [\n      \"dependency1\",\n      \"dependency2\"\n    ]\n  }\n}\n```\n\nThen you can specify one or more of the following:\n\n```javascript\n{\n  // ...\n  \"vendorize\": {\n    \"packages\": [\n      \"dependency1\",\n      \"dependency2\"\n    ],\n    // If true (the default), will delete the contents of the vendor directory\n    // before copying files into it.\n    \"cleanBefore\": true,\n    // Don't like the name \"vendor\"? Weird, but you can change it, sure.\n    \"dirName\": \"vendor\",\n    // If true (the default), a .gitignore file will be placed in the vendor\n    // directory to ignore its contents.\n    \"gitIgnore\": true\n  }\n}\n```\n\n# Miscellaneous\n\nNot to be confused with [the `vendorize`\npackage](https://www.npmjs.com/package/vendorize), which only copies npm\npackages from a `node_modules` directory.\n","readmeFilename":"readme.md"}