Piral CLI Parcel Bundler Plugin

1.1.0 · active · verified Tue Apr 21

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

Warnings

Install

Quickstart

This script demonstrates installing `piral-cli-parcel` into a new Piral instance project and verifies that Piral CLI commands like `piral build` now utilize Parcel v1 as the underlying bundler.

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
}

view raw JSON →