polymer-transpiler

raw JSON →
1.1.4-alpha verified Fri May 01 auth: no javascript deprecated

Polymer 1 to Polymer 2 transpiler that converts Polymer function-based elements into ES6 class syntax. Current version is 1.1.4-alpha, released as an unstable alpha with frequent breaking changes. It provides a CLI tool to search and transpile components, allowing customization of base class. Differentiators: specific focus on Polymer 1→2 migration, simple CLI usage, but no other major features or community support.

error Cannot find module 'polymer-transpiler'
cause Package not installed globally or missing from node_modules
fix
Run: npm install -g polymer-transpiler
error TypeError: polymerTranspiler.transpile is not a function
cause Incorrect import or using default import as named object
fix
Use: import polymerTranspiler from 'polymer-transpiler' then call polymerTranspiler.transpile()
error Error: The specified path does not contain Polymer components
cause CLI path option points to a directory without Polymer 1 elements
fix
Provide a valid path with .html files containing Polymer({}) calls
breaking CLI name changed from 'poly-transpiler' to 'polymer-transpiler' in v1.1.0-alpha
fix Update scripts and references to use 'polymer-transpiler' instead of 'poly-transpiler'
deprecated Polymer itself is deprecated; this transpiler is only relevant for legacy codebases
fix Migrate to modern web component frameworks (Lit, etc.)
gotcha Alpha stability: anything can change, no semver in alpha, may break without notice
fix Pin to a specific version and test thoroughly before using in production
npm install polymer-transpiler
yarn add polymer-transpiler
pnpm add polymer-transpiler

Transpile a Polymer 1 element string to Polymer 2 class syntax

import polymerTranspiler from 'polymer-transpiler';

// Example: transpile a single Polymer 1 element file
const input = `
  <dom-module id="my-element">
    <template><span>{{text}}</span></template>
    <script>
      Polymer({
        is: 'my-element',
        properties: { text: { type: String } }
      });
    </script>
  </dom-module>
`;

const output = polymerTranspiler.transpile(input, { extends: 'Polymer.Element' });
console.log(output);
// Output will be ES6 class extending Polymer.Element