{"id":17875,"library":"polymer-bundler","title":"Polymer Bundler","description":"polymer-bundler is a JavaScript library and command-line tool (CLI) designed for optimizing web component-based projects by processing and packaging project assets into a single output file. Its primary function, integral to the Polymer 1.x and 2.x ecosystems, was to follow HTML Imports, external scripts, and stylesheets, inlining these resources into \"bundles\" to minimize network round-trips and improve initial load times in production environments. The package is at version 4.0.10. While it offers a programmatic API for custom bundling strategies, it was most commonly used via the Polymer CLI. However, its core utility is significantly diminished as HTML Imports, the foundational web standard it built upon, were deprecated in Chrome M70 and removed entirely in Chrome M80 (February 2020) due to lack of adoption across browsers and the rise of ES Modules. Therefore, while the package exists, its practical application for modern web development is largely obsolete.","status":"abandoned","version":"4.0.10","language":"javascript","source_language":"en","source_url":"https://github.com/Polymer/tools","tags":["javascript","web components","polymer","typescript"],"install":[{"cmd":"npm install polymer-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add polymer-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add polymer-bundler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally by the Bundler constructor to provide analysis of and access to files for bundling.","package":"polymer-analyzer","optional":false}],"imports":[{"note":"The primary class for programmatic bundling. Instantiated with an options object.","wrong":"const Bundler = require('polymer-bundler').Bundler;","symbol":"Bundler","correct":"import { Bundler } from 'polymer-bundler';"},{"note":"Used to produce a manifest, which the `Bundler.bundle()` method now accepts directly.","wrong":"const generateManifest = require('polymer-bundler').generateManifest;","symbol":"generateManifest","correct":"import { generateManifest } from 'polymer-bundler';"},{"note":"TypeScript type for the output of the bundling process.","symbol":"BundleResult","correct":"import type { BundleResult } from 'polymer-bundler';"}],"quickstart":{"code":"npm install -g polymer-bundler\n\n# Create a simple HTML file to bundle\necho '<!DOCTYPE html>\\n<html>\\n<head>\\n  <title>Test App</title>\\n  <link rel=\"import\" href=\"./my-component.html\">\\n  <style>body { font-family: sans-serif; }</style>\\n  <script src=\"./app.js\"></script>\\n</head>\\n<body>\\n  <my-component></my-component>\\n</body>\\n</html>' > index.html\n\necho '<dom-module id=\"my-component\">\\n  <template>\\n    <style>h1 { color: blue; }</style>\\n    <h1>Hello from My Component!</h1>\\n  </template>\\n  <script>class MyComponent extends HTMLElement { constructor() { super(); this.attachShadow({mode: \"open\"}).appendChild(document.getElementById(\"my-component\").content.cloneNode(true)); } } customElements.define(\"my-component\", MyComponent);</script>\\n</dom-module>' > my-component.html\n\necho 'console.log(\"App loaded!\");' > app.js\n\n# Bundle the application, inlining scripts and styles, and stripping comments\npolymer-bundler index.html \\\n  --inline-scripts \\\n  --inline-css \\\n  --strip-comments \\\n  --out-file bundled-app.html\n\n# To view the output:\n# cat bundled-app.html","lang":"bash","description":"This quickstart demonstrates installing `polymer-bundler` globally and using it via the CLI to bundle a simple HTML application with a custom element and external resources. It inlines all scripts and styles, strips comments, and outputs to `bundled-app.html`."},"warnings":[{"fix":"For new projects, use modern web component tooling with ES Modules (e.g., Lit, Vite, Webpack, Rollup). For legacy projects, consider migrating away from HTML Imports or ensuring robust polyfill strategies are in place, understanding the inherent limitations.","message":"The core utility of polymer-bundler, which relies on HTML Imports for asset bundling, is fundamentally broken for modern browsers. HTML Imports were deprecated in Chrome M70 and removed in M80 (February 2020) and were never widely adopted by other browsers. Projects heavily dependent on HTML Imports will no longer function natively in modern browsers without polyfills, severely limiting the practical use of this bundler.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always include the `--inline-scripts` and `--inline-css` flags when using the CLI if you intend for external resources to be inlined into the main bundle.","message":"External scripts and stylesheets are not inlined into the bundle by default. If these resources are not explicitly inlined, they will remain as external links in the bundled output, potentially negating performance benefits.","severity":"gotcha","affected_versions":">=2.2.0"},{"fix":"Refer to the specific version's API documentation, particularly the `CHANGELOG.md` or `README`, for correct programmatic usage, especially regarding the `bundle()` method and manifest generation.","message":"Between major versions and even minor updates (e.g., in 2.x), the programmatic API for `polymer-bundler` underwent significant changes. For instance, the `bundle()` method in 2.0.0+ now expects a manifest object instead of separate entrypoints, strategy, and mapper arguments, requiring the use of `generateManifest()`.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"For Polymer 1.x projects experiencing broken relative URLs in templated styles, explicitly use the `--rewrite-urls-in-templates` flag. For Polymer 2.x, ensure `assetpath` is correctly utilized.","message":"URL rewriting behavior for elements within `<template>` tags differs between Polymer 1.x and 2.x. Polymer 1.x projects using relative image URLs in styles within `<template>` tags might render incorrectly after bundling if `--rewrite-urls-in-templates` is not used. Polymer 2.x handles this differently with `assetpath`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider migrating projects to LitElement and modern build tools (e.g., Vite, Webpack, Rollup) for active development and long-term maintainability.","message":"The Polymer library itself is in maintenance mode, with LitElement recommended for new development. As a foundational tool for older Polymer versions, `polymer-bundler` is consequently also a legacy tool.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Install the package globally using `npm install -g polymer-bundler` (or `sudo npm install -g polymer-bundler` on some systems).","cause":"The `polymer-bundler` CLI tool is not installed globally or is not in your system's PATH.","error":"Command not found: polymer-bundler"},{"fix":"Ensure the input HTML file exists and the path is correct, or navigate to the directory containing the file before running the command.","cause":"The specified input HTML file (e.g., `index.html`) does not exist at the provided path, or the command is being run from the wrong directory.","error":"ENOENT: no such file or directory, stat 'index.html'"},{"fix":"Verify that all `<link rel=\"import\">` tags point to valid HTML documents and that those documents are well-formed.","cause":"Often occurs when an HTML Import tries to load a non-HTML file (like a script or JSON) or a malformed HTML file.","error":"HTML Import parsing error: unexpected token <"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}