Piral CLI Parcel Bundler Plugin
Piral CLI Parcel is a plugin designed to integrate Parcel Bundler (specifically Parcel v1) into the Piral CLI ecosystem. It enables developers to use Parcel for bundling both Piral instances and individual pilets, simplifying the build and debug processes. The current stable version is v1.1.0, with ongoing active development and recent updates including a move to a dedicated repository. This plugin eliminates the need for manual Parcel installation or configuration, providing a 'batteries included' approach by bundling essential Parcel plugins such as `parcel-plugin-at-alias`, `parcel-plugin-codegen`, `parcel-plugin-externals`, and `parcel-plugin-import-maps`. While it offers a streamlined development experience for Piral projects using Parcel v1, users should be aware of its reliance on the older Parcel version, which has different features and behavior compared to Parcel v2. Its primary differentiator is seamless integration with `piral-cli`, offering an alternative bundling solution alongside other options like Webpack or ESBuild within the Piral framework.
Common errors
-
No bundler found for the current project.
cause The `piral-cli` could not detect an installed bundler plugin (like `piral-cli-parcel`) in the project's `devDependencies`.fixRun `npm install piral-cli-parcel --save-dev` in the root of your Piral instance or pilet project to install the Parcel bundler plugin. -
Parcel build failed: Cannot find module 'some-external-package'
cause Parcel v1's module resolution, especially for external dependencies in Piral, might fail to locate a required package.fixEnsure 'some-external-package' is correctly listed in your `package.json` `dependencies` (for the Piral instance or pilet). If it's a shared Pilet external, verify it's correctly declared and provided by the Piral instance. For complex resolution issues, review Parcel v1's documentation regarding externals or consider explicit aliases.
Warnings
- gotcha This plugin is specifically built for and relies on Parcel v1. Users expecting Parcel v2 features, bug fixes, or a more modern bundling experience may find limitations. Parcel v1 is no longer actively maintained by the Parcel team.
- gotcha The `piral-cli-parcel` plugin must be explicitly installed as a development dependency (`npm i piral-cli-parcel --save-dev`) within a Piral instance or pilet project for `piral-cli` to detect and use Parcel as the bundler. A global Parcel installation is not sufficient.
- breaking As of v0.15.0, the `piral-cli-parcel` package was moved to a dedicated repository. While this is generally transparent for npm installations, it could affect users who previously relied on internal paths or specific monorepo structures for direct imports or tooling integrations.
Install
-
npm install piral-cli-parcel -
yarn add piral-cli-parcel -
pnpm add piral-cli-parcel
Quickstart
import { execSync } from 'child_process';
import path from 'path';
// This quickstart demonstrates how piral-cli-parcel enables Parcel v1 bundling
// for Piral CLI commands by installing it into a new Piral instance.
const projectName = 'my-parcel-app';
const projectDir = path.join(process.cwd(), projectName);
try {
// Ensure piral-cli is installed globally (recommended for Piral development)
console.log('Installing piral-cli globally...');
execSync('npm install -g piral-cli@latest', { stdio: 'inherit' });
// Create a new Piral instance project
console.log(`\nCreating Piral instance: ${projectName}`);
execSync(`piral new ${projectName} --template default --npm`, { stdio: 'inherit' });
process.chdir(projectDir); // Change to the newly created project directory
// Install piral-cli-parcel as a development dependency.
// The presence of this package automatically configures `piral-cli` to use Parcel v1.
console.log('\nInstalling piral-cli-parcel into the project...');
execSync('npm install piral-cli-parcel --save-dev', { stdio: 'inherit' });
console.log('\nConfiguration complete. Piral CLI commands will now use Parcel v1.');
console.log('To start debugging your Piral instance: run `piral debug` from this directory.');
console.log('To build your Piral instance for production: run `piral build` from this directory.');
// Demonstrating a build command that completes quickly
console.log('\nExecuting a Piral build command (using Parcel v1) to demonstrate functionality...');
execSync('piral build --target release', { stdio: 'inherit' });
console.log('\nBuild completed using Parcel v1. Check the `dist/release` directory.');
console.log(`\nQuickstart finished. To clean up, run: rm -rf ${projectName}`);
} catch (error) {
console.error('An error occurred during the quickstart setup or execution:', error);
} finally {
process.chdir(process.cwd()); // Return to the original directory
}