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

moat-maker-commonjs

v2.2.0

Published

A commonjs-compatible version of Moat Maker

Downloads

6

Readme

Moat Maker for CommonJS

This is a CommonJS-compatible version of Moat Maker. The main Moat Maker repository can be found over here.

A quick recap on CommonJS vs ES Modules: CommonJS is Node's default module system where you use require() to import stuff. "ES Modules" are the newer, standard module system where you use import ... from ... syntax to import stuff. If you're using TypeScript, you may be writing your code with ES Module syntax, but TypeScript is secretly transpiling your code down to CommonJS. You can check your transpiled output to see what module system it will use. If you get errors such as "require() of ES Module ... from ... not supported." when running a project, it likely means you're using CommonJS while trying to import a package (such as Moat-Maker) that's built with ES Modules.

If you're using CommonJS and wish to use Moat-Maker, simply install this package (npm i moat-maker-commonjs) instead of the main moat-maker project and you should be good to go.

How supported is this package?

You can expect this CommonJS version of Moat Maker to be updated less frequently. It will occasionally receive some of the more important updates, but minor changes or small bug fixes may not be brought over for a while. What's more, it's possible that support for this package may be dropped eventually. At the moment, creating a CommonJS version of the project is fairly easy to do - it just takes a couple config tweaks and it works. However, CommonJS and ES Modules are not interchangeable - there is an ever-growing set of features provided by ES Modules that is simply not supported by CommonJS. If there is ever a need to use one of these incompatible features, it may mean the end of support for this CommonJS project. Finally, it's also important to note that the algorithm being used to transpile from ES Modules to CommonJS isn't perfect. While unlikely, it's possible that differences in behaviors or bugs could crop up in this repo due to transpiling errors.

All that being said, this package is still considered production-ready. If your project hasn't yet converted to ES Modules, feel free to use this package until you're ready to make the plunge into ES Modules.

Why not make the main Moat-Maker project support both CommonJS and ES Modules?

Many NPM packages are capable of simply supporting both CommonJS and ES Modules. This dual-support is usually accomplished by bundling both a CommonJS and an ES Module version of the project into the same NPM package, doubling the size of the package and creating lots of unnecessary bloat. Providing strong support for both versions also prevents the use of some of the features ES Modules has to offer, since those features are simply not compatible with CommonJS.

Because Moat Maker is a fairly newer project that doesn't have a CommonJS history to it, it made sense to keep CommonJS out of the main repo.