Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

Generate CommonJS / AMD compatible .js files #7

@coopernurse

Description

@coopernurse

Not a high priority for me, but probably something to consider. It looks like it would be pretty easy to support as it just impacts the wrapper code around the generated .js file.

mustache.js has a good example:

https://github.com/janl/mustache.js/blob/master/mustache.js

(function (root, factory) {
  if (typeof exports === "object" && exports) {
    module.exports = factory; // CommonJS
  } else if (typeof define === "function" && define.amd) {
    define(factory); // AMD
  } else {
    root.Mustache = factory; // <script>
  }
}(this, (function () {

   // body code here

  var exports = {};
  // bind all exported identifiers -- similar to current output

  return exports;

}())));

This would work with require.js, CommonJS (e.g. node.js), and plain <script> tags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions