Package Exports
- @toolbuilder/rollup-plugin-create-pack-file
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@toolbuilder/rollup-plugin-create-pack-file) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Rollup-Plugin-Create-Pack-File
This Rollup plugin creates a pack file from your package, and moves it somewhere else as part of testing your package.
I test a package by using Rollup to:
- convert units tests so that they use package instead of relative imports (e.g.
../src/indextoiterablefu) - build a test package around those tests
- rollup-plugin-create-test-package-json
- this package
- and run the tests
Installation
npm install --save-dev @toolbuilder/rollup-plugin-create-pack-fileUse
import createPackFile from '@toolbuilder/rollup-plugin-create-pack-file'
export default {
input: 'entry-point.js',
output: {
// You can use `file` instead, the plugin will use path.dirname to get the directory path
dir: 'where/the/pack/file/should/go'
format: 'es'
},
plugins: [
createPackFile() // typically, you won't need any options
]
}This plugin runs using the generateBundle hook. This lets you use the pack file when the writeBundle hook runs. The writeBundle hook runs plugins in parallel, so you can't control plugin execution order.
Options
There are a number of options. The advanced options exist for unit testing, but you might find them useful.
Basic Options:
rootDir- tell the plugin where the package root is located. By default, this isprocess.cwd().packCommand- tell the plugin what command to use to generate the pack file. This is not run in a shell, butexecais used to parse the command. By default, this isnpm pack. For example, I use pnpm instead ofnpm, so my packCommand option looks likepnpm pack. The plugin does expect the pack file name to matchnpmnaming conventions.
Advanced options:
packageJson- By default, the plugin readspackage.jsonatrootDirto figure out the pack file name. If you want something else, provide this option an Object that hasnameandversionattributes just likepackage.jsondoes.mover- Async method that moves the pack file. Signature looks like this: async (fullPackFilePath, fullTargetPackFilePath) => {}. No return value is expected. AnErrorshould be thrown on failure. By default the plugin provides a function to move the file.shellCommand- An async method that creates the pack file when given thepackCommandoption value. No return value is expected, anErrorshould be thrown on failure. By default, the plugin usesexeca.commandto runpackCommand.
Contributing
Contributions are welcome. Please create a pull request.
I use pnpm instead of npm.
Issues
This project uses Github issues.