@hyperfrontend/workspace/generators/make-publishablemake-publishable
Gives a library what a published package needs: a build target in the chosen formats, the publish, version and version-check targets, the manifest fields a registry asks for, a README where the project has none, and an e2e project with one suite per format that installs the packed tarball into a consumer outside the workspace.
npx hf generate make-publishable my-utils
npx hf generate make-publishable my-utils \
--formats=esm,cjs,iife,umd --globalName=AcmeMyUtils
| Option | What it sets |
|---|---|
--project | The project to make publishable (also the first positional argument) |
--formats | The bundle formats among esm, cjs, iife and umd; defaults to esm,cjs |
--globalName | The global for the iife and umd bundles; defaults to the scope and the name as one class name |
--bundleEntry | The entry the browser bundles are built from; defaults to . |
--keywords | npm keywords; defaults to the package's own, else its name, its scope and typescript |
--nodeEngine | The Node.js range the package declares; defaults to the package's own, else >=18.0.0 |
--buildExecutor | The executor of the build target; defaults to @hyperfrontend/workspace:build |
--e2eDirectory | Where the e2e project is created; defaults to e2e |
--skipE2E | Write no e2e project |
--skipFormat | Leave the written files unformatted |
A target the project already configures is kept; the build target gains the executor and the formats it lacks. A project that already publishes keeps every e2e file it has. The browser suites of the e2e project preload a DOM, which needs jsdom installed beside @hyperfrontend/testing.
API Reference§
ƒ Functions
makePublishableGenerator( tree: Tree, options: MakePublishableGeneratorOptions): Promise< void>
Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | The tree, rooted at the workspace |
§options | MakePublishableGeneratorOptions | Which project, and how it is built and tested |
Returns
Promise< void>Examples
A package in ESM and CommonJS
npx hf generate make-publishable my-libA package with browser bundles under a chosen global
npx hf generate make-publishable my-lib --formats=esm,cjs,iife,umd --globalName=MyLibRe-running on a published library changes nothing it already has
import makePublishableGenerator from '@hyperfrontend/workspace/generators/make-publishable'
await makePublishableGenerator(tree, { project: 'my-lib', formats: ['esm', 'cjs', 'umd'] })
// the build target gains its umd options; the existing targets, keywords, README and e2e suites are keptParameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | The tree the project lives in |
§options | MakePublishableGeneratorOptions | The options as given |
Returns
PublishablePlanExample
The formats fall into the build's order and the e2e names follow the package's
planPublishable(tree, { project: 'data-utils', formats: ['umd', 'esm'] })
// => {
// projectName: 'data-utils',
// projectRoot: 'libs/data-utils',
// packageName: '@acme/data-utils',
// formats: ['esm', 'umd'],
// globalName: 'AcmeDataUtils',
// bundleEntry: '.',
// keywords: ['data-utils', 'acme', 'typescript'],
// buildExecutor: '@hyperfrontend/workspace:build',
// e2eProjectName: 'e2e-data-utils',
// e2ePackageName: '@acme/e2e-data-utils',
// e2eProjectRoot: 'e2e/data-utils',
// createE2e: true,
// republishing: false,
// e2eExists: false,
// ...
// }◈ Interfaces
make-publishable generator takes.Properties
nodeEngine:stringThe Node.js range chosen, or undefined to keep the package's own or inherit the root's◆ Types
type BundleFormat = "esm" | "cjs" | "iife" | "umd"