🎁

preconstruct

GitHub

Commands

init

preconstruct init

preconstruct init asks questions about your project and how it should be built and creates the appropriate config in your package.json.

build

preconstruct build

preconstruct build creates the bundles for your project.

dev

preconstruct dev

preconstruct dev creates files and symlinks in the dist folders of entrypoints which map to the appropriate source file so that the package can be imported from Node and in bundlers and the source file will be imported.

How should I use it?

It's best to use the dev command in a postinstall hook so that people don't have to worry about running it.

{
"scripts": {
"postinstall": "preconstruct dev"
}
}

Note: preconstruct dev also needs to be run whenever the project's packages or entrypoints change.

fix

preconstruct fix

preconstruct fix fixes invalid configuration in a project. It also throws an error when there is an issue which cannot be resolved automatically.

validate

preconstruct validate

preconstruct validate checks that the project, packages and entrypoints are all valid.

Note: A build can still fail even if validate doesn't fail because there are some checks which can only happen during a build

watch

preconstruct watch

preconstruct watch is similar to preconstruct build except instead of doing a single build, it starts a watcher and rebuilds the project whenever there are changes.

preconstruct watch is only intended to be used as a last resort when preconstruct dev cannot be used. If you have a use case that preconstruct watch solves but preconstruct dev does not, please open an issue.