I'm using duojs, which is a front-end webdevelopment tool not unlike browserify or component. It allows you to import css and js straight from the file itself, without any external package manifests.
I'm trying to understand how to write my js so it works well with duojs, but am not sure what kind of architecture it uses for its module definitions. I've looked for it in the documentation, but couldn't find it there. From what I can tell it looks like the duojs compiler wraps all components in commonjs style wrappers:
See for example this compiled js file on their repo (below is a snippet):
/**
* Return newest require.
*/
return require;
})({
1: [function(require, module, exports) {
/**
* Module Dependencies
*/
var Highlight = require('segmentio/highlight');
/**
* Code highlighting.
*/
new Highlight()
.use(require('segmentio/highlight-javascript'))
.use(require('segmentio/highlight-xml'))
.use(require('segmentio/highlight-css'))
.use(require('segmentio/highlight-json'))
.all();
Can anyone tell from the code what kind of js module api is being used here? To me this looks like a commonjs style module definition, but I'm not sure, it might be node as well.
Duo uses duo-pack to build it's javascript. duo-pack's javascript packer is very similar to browserify's browser-pack. duo-pack differs in that it also supports packing CSS.
It's packed in such a way that the entry file will get executed immediately when the script is included.
As I understand it, and from what I've found, it doesn't use another API structure. Check out https://github.com/duojs/duo/blob/master/docs/api.md for information about how-to use the DuoJS API.
To my eye, it appears that it is entirely built from scratch, but I'm not an expert in any form of JavaScript.