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

esb4esm

v0.0.3

Published

Opinionated builder for web source, specifically targeting javascript as es modules.

Downloads

3

Readme

Heads up! This project (inculding this documentation) is a work in progress! It is functional and the api probably won't change too much, but the overall "hygiene" leaves a lot to be desired -- there will be improvements to documentation, code comments, tests, and overall file structure... at some point.


esb4esm

A VERY opinionated layer on top of esbuild to build source code du jour in to ES Modules

Goal

The goal is to enable developers to author code using the tools of their choosing, but without needing to maintain a build script or be locked in to a particular platform or framework.

Specifically, esb4esm exists so that developers can write native es modules and import external packages without having to worry about bundling, static asset serving, or other build script concerns -- just author code for the web and run it on the web.

Install

> npm install -g esb4esm

Overview

At a high-level, this package takes a glob of web* source files (html, css, js), "compiles**" them and their dependencies, and then, primarily, outputs them in a root directory and ensures their import paths have been updated to be relative to the root directory.

Once these files have been "compiled" and written to the root directory, any one of them can be loaded using native browser loading mechanisms: <script> tag, dynamic import(), <link>, etc.

The esb4esm binary also includes watch and serve functionallity to support additional workflows that are common with this setup. Run esb4esm --help to see options.

* web source files are native HTML, CSS, JavaScript files that have been authored against the latest (or emerging) standards; however, they may need a "compile" step to make sure they're runnable for all browsers and users. Additionally, it's possible to use non-web source files like TypeScript, JSX, SCSS, etc through plugins.

** the compilation step is performed by esbuild and handles standard build/compilation features like minification, DEC/tree shaking, polyfilling, etc; however, because of the nature of this package, it does not handle bundling.

Why ES Modules?

ES Modules is a well-supported standard for importing and exporting dependencies natively within the browser.

Utilizing this functionality is a huge step forward for a build-free web while still allowing for builds steps where they make sense.

A build-free web first and foremost, lowers the barrier to entry for developing on and for the web by inverting today's standard practice of first learning some arcane DSL or framework rote with propriety syntax and conventions. Instead, it allows one to focus on the core tenets of the web (like html, css, javascript) while still taking advantage of some a few standard practices (e.g., small, focused files, etc)

And, practically, a build-free web will also minimize maintenance costs and increase focus on what you're actually building/creating!

Why esbuild?

tl;dr it's very fast and its opinions pretty much align with this packages opinions.

Why not x?

// TODO: add other projects and approaches

Examples

Run esb4esm --help to see cli args.

esb4esm should be able to work with most existing setups; however, feel free to take a look at the layout of the fixtures for the tests.

// TODO: add more inline examples...

Example command:

esb4esm --watch --sources 'tests/fixtures/external-deps/src/**/*.{html,css,js}' --outdir tests/build/EXTERNAL_DEPS/