Compack Web Component Bundler

raw JSON →
0.1.10 verified Thu Apr 23 auth: no javascript abandoned

Compack is a command-line interface (CLI) tool designed to bundle Web Components by consolidating their individual HTML, CSS, and JavaScript files into a single distributable HTML file. This approach aimed to facilitate the packaging and distribution of components that could then be imported into web applications using HTML Imports. The package is currently at version 0.1.10. Given its last commit was approximately eight years ago and its core reliance on HTML Imports (which have been deprecated and removed from modern browsers), the project is no longer actively maintained and its output is not directly usable in contemporary web development without significant polyfilling or refactoring. Its key differentiator, the use of HTML Imports for component integration, is now a critical limitation.

error command not found: compack
cause The `compack` package was not installed globally or is not in the system's PATH.
fix
Install compack globally using npm install -g compack.
error Error: Cannot find module 'component.json' or 'components.json'
cause The `compack` command was run in a directory that does not contain a `component.json` configuration file, or the file is misspelled/missing.
fix
Ensure you are in the root directory of a component project created with compack --create or that a valid component.json file exists in the current working directory.
error Failed to load resource: net::ERR_FILE_NOT_FOUND (when loading .html or .js)
cause This error often occurs when the `compack` server is not running, or the HTML file attempting to import the component has an incorrect path to the bundled component or the `webcomponents.min.js` polyfill.
fix
Start the development server with compack --server or ensure all file paths in your test HTML are correct relative to the location of the bundled component and polyfill scripts.
breaking The primary output of Compack relies on HTML Imports (<link rel="import">), which have been deprecated and removed from all major modern browsers (e.g., Chrome 73+). This makes components bundled by Compack largely unusable in current web environments without substantial polyfilling or refactoring to use ES Modules.
fix Modern Web Component development primarily uses ES Modules for component loading and dependency management. Developers should consider modern bundlers (e.g., Rollup, Webpack, Vite) and frameworks (e.g., Lit, Stencil) that natively support ES Modules for building and distributing Web Components. The `@webcomponents/html-imports` polyfill can be used for limited legacy support, but full browser support is not guaranteed.
deprecated The project appears to be abandoned, with no active development or updates since 2018. The last published version is 0.1.10. This implies no support for newer Web Component specifications or modern JavaScript features.
fix Migrate to actively maintained Web Component tools and libraries that embrace current web standards and best practices.
gotcha The `--server` option starts a development server on `http://localhost:8181`. This port might conflict with other local services or development servers.
fix Check for port conflicts before running the server. The documentation does not provide an option to configure a different port, so manual intervention or proxy setup might be required if conflicts occur.
npm install compack
yarn add compack
pnpm add compack

Demonstrates global installation, component boilerplate generation, building a component, and starting a development server, highlighting its use of deprecated HTML Imports.

npm install -g compack

# Create boilerplate for a new component
compack --create my-first-component

# Navigate into the component directory
cd my-first-component

# Install any component-specific dependencies (if package.json exists)
npm install

# Build and bundle the component into a single HTML file
compack

# Start a development server with live reload
compack --server

# To use the component in an HTML file (note: relies on deprecated HTML Imports)
// Add a test.html file in the parent directory of 'my-first-component.html'
// and ensure webcomponents.min.js polyfill is accessible.
/*
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Testing My Component</title>
        <script src="webcomponents.min.js"></script>
        <link rel="import" href="./my-first-component/my-first-component.html">
    </head>
    <body>
        <my-first-component></my-first-component>
    </body>
</html>
*/