
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
eleventy-plugin-wcc
Advanced tools
Eleventy plugin for rendering native Web Components using Web Components Compiler (WCC).
A starter kit for 11ty + WCC is also available.
Install from NPM.
$ npm install eleventy-plugin-wcc --save-dev
Add the plugin to your eleventy.js config and provide a URL
for all top level custom element definitions you use.
const path = require('path');
const { pathToFileURL } = require('url');
const wccPlugin = require('./src/index');
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(wccPlugin, {
definitions: [
pathToFileURL(path.join(__dirname, './src/js/my-element.js'))
]
});
};
Write a custom element like below. In this case, we are using Declarative Shadow DOM.
// src/js/greeting.js
const template = document.createElement('template');
template.innerHTML = `
<p>Hello from the greeting component!</p>
`;
class GreetingComponent extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
async connectedCallback() {
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
}
module.exports = GreetingComponent; // using module.exports!
customElements.define('x-greeting', GreetingComponent);
Note: Since Eleventy does not support ESM yet, you will need to use
module.exports = XXX
instead ofexport default XXX
for your definitions.
Add your custom element paths to your .eleventy.js config
const path = require('path');
const { pathToFileURL } = require('url');
const wccPlugin = require('eleventy-plugin-wcc');
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(wccPlugin, {
definitions: [
pathToFileURL(path.join(__dirname, './src/js/greeting.js'))
]
});
};
Now in your content or layouts, use the custom element.
<!-- src/index.md -->
# Hello From 11ty + WCC! 👋
<x-greeting></x-greeting>
Now if you run eleventy
, you should get an index.html in your site/ directory with the custom element content pre-rendered! 🎈
<h2>Hello From 11ty + WCC!</h2>
<p>
<x-greeting>
<template shadowroot="open">
<p>Hello from the greeting component!</p>
</template>
</x-greeting>
</p>
Coming soon!
Please follow along in our issue tracker or make a suggestion!
FAQs
An Eleventy plugin for rendering Web Components with WCC.
The npm package eleventy-plugin-wcc receives a total of 0 weekly downloads. As such, eleventy-plugin-wcc popularity was classified as not popular.
We found that eleventy-plugin-wcc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.