npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@polymer/html-modules-toolkit

v0.0.2

Published

Let's face it: if you publish stuff on the web, you probably noticed that it is getting harder and harder to use HTML to do it. HTML Imports failed to gain a lot of traction among browser implementors. JavaScript modules are, well, JavaScript; you can use

Downloads

4

Readme

🍢 HTML Modules Toolkit

Let's face it: if you publish stuff on the web, you probably noticed that it is getting harder and harder to use HTML to do it. HTML Imports failed to gain a lot of traction among browser implementors. JavaScript modules are, well, JavaScript; you can use cool tools like lit-html within JavaScript, but traditional markup just isn't on the menu.

HTML has been around for a long time. I mean, sure, just a few decades. But, that's like a million software years. It is a testament to HTML's versatility that we still use it for so many things today. The next generation of web content will need to take advantage of a new generation of HTML capabilities. HTML Modules Toolkit is a collection of tools and libraries to help web authors write their apps and content the way they were meant to be written: in highly declarative HTML. HTML Modules Toolkit unlocks the potential of future HTML standards for the projects of today.

HTML Modules

There is a nascent standard proposal called HTML Modules that could bring actual HTML into a JavaScript module graph near you. This would unlock crafting modules from HTML, and even loading other HTML-based modules from HTML documents or JavaScript modules. Importantly, HTML Modules have a lot more interest from browser implementors than HTML Imports ever did.

HTML Modules aren't standardized yet, but we have a good sense of what they might look like once they are standard and implemented by browsers.

Future HTML today

HTML Modules Toolkit intends to support workflows that incorporate future HTML standards like HTML Modules. Today, this project includes transforms for incorporating HTML Modules into build pipelines, and also middleware for using HTML Modules seamlessly inside of a dev server.

The standards that this project builds upon are still at a very early stage, so these tools should be considered to be in a similar state. We will adapt and improve these libraries to track the related standards as they continue to solidify.

Installing

npm install @polymer/html-modules-toolkit

What is included

This project includes low-level, versatile string-to-string transforms that can analyze a file in place, and produce the appropriate ES Module-compatible output.

You can import these low-level transforms into your Node.js build pipeline or dev server of choice:

import {htmlModuleToJsModuleMap} from
    '@polymer/html-modules-toolkit/lib/html-module-transform';
import {transformSpecifiersInHtmlString,transformSpecifiersInJsString} from
    '@polymer/html-modules-toolkit/lib/html-module-specifier-transform';

This project also includes higher-level wrappers of the transform for different practical use cases. The available wrappers include:

  • Webpack plugin:
    import {HtmlModulesPlugin} from
        '@polymer/html-modules-toolkit/lib/html-module-transform/webpack-plugin';
  • Gulp-compatible vinyl-fs transforms:
    import {HtmlModuleTransform,HtmlModuleSpecifiersTransform} from
        '@polymer/html-modules-toolkit/lib/vinyl-transform';
  • Express middleware:
    import {htmlModulesMiddleware} from
        '@polymer/html-modules-toolkit/lib/express-middleware';
  • Koa middleware:
    import {htmlModulesMiddleware} from
        '@polymer/html-modules-toolkit/lib/koa-middleware';

Specifier transforms

If you look closely at the above import statements, you will notice that in some cases there are separate transforms offered for converting specifiers. This transform is offered separately because it is not always needed. For example, in a dev server the server can control the Content-Type of the file being sent, and can send text/javascript even if the file has a .html file extension.

Usage examples

You can find some concrete usage examples in the examples/ directory of this project. The examples include:

Additionally, you can find a live example of the Koa middleware in action on Glitch.

Contributing

Currently we are only considering features or bugfixes related to the evolving HTML Modules standard. There is no strict spec text for this standard yet, so feature requests may be redirected to w3c/webcomponents if they seem sufficiently novel.