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

mimosa-require-commonjs

v1.0.1

Published

A CommonJS wrapping module for Mimosa AMD/RequireJS projects

Downloads

4

Readme

mimosa-require-commonjs

Overview

This is a Mimosa module for wrapping browser code written in CommonJS with requirejs' simplified CommonJS wrapper. This is an external module and does not come by default with Mimosa.

This module provides CommonJS support via RequireJS and AMD. So if you are a fan of writing your modules in the CommonJS style, but want to use AMD in the browser and take advantage of all that RequireJS' configuration allows you, like, among other things, creating module path shortcuts and aliases, then this is the module for you.

Stated differently, this module allows you to write your AMD/RequireJS application using CommonJS.

Because this module still leverages AMD/RequireJS, when you write your browser code in CommonJS, you will still take advantage of all of the functionality provided by the mimosa-require module, like path verification, and circular dependency checking and on-the-fly optimization if your entire application.

For more information regarding Mimosa, see http://mimosa.io

Usage

Add 'require-commonjs' to your list of modules. That's all! Mimosa will install the module for you when you start up.

If you are using "use strict" in your code, and you are using the mimosa-lint module, you'll want to make sure that in your list of modules, require-commonjs comes before lint. If it comes after mimosa-lint, then mimosa-lint may complain about certain objects not being available that are provided by the require-commonjs module.

Functionality

The 'require-commonjs' module will wrap your JavaScript code with the simplified CommonJS wrapper that RequireJS provides. This turns your CommonJS file into an AMD module.

The module performs this wrapping during the afterCompile step of the buildFile, add and update Mimosa workflows. Which simply means whenever JavaScript is compiled or copied, post-compilation the wrapper is applied. For JavaScript the wrapper is added to the raw JavaScript code before it is written, and for something like CoffeeScript, it is added to the compiled JavaScript.

The module will not wrap files that it determines are already wrapped in a define block. It will also not wrap files that match the requireCommonjs.exclude regexes. See config below.

Default Config

requireCommonjs:
  exclude:[/[/\\]vendor[/\\]/, /[/\\]main[\.-]/]
  • exclude: an array of regexes and/or strings. List of regexes or strings to match files that should be excluded from wrapping in requirejs' commonjs wrapper. String paths can be absolute or relative to the watch.javascriptDir. Regexes are applied to the entire path. By default anything in a vendor folder and anything that begins with 'main.' or 'main-' are excluded as presumably those are already wrapped or are main requirejs config files and should not be wrapped in a commonjs wrapper.

Example

The AngularFunMimosaCommonJS project is a working example of a project that uses Mimosa and CommonJS. Check it out. Hopefully it'll answer any questions you have.