Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

implement requirejs module format #626

Closed
jmesserly opened this issue Aug 12, 2016 · 1 comment
Closed

implement requirejs module format #626

jmesserly opened this issue Aug 12, 2016 · 1 comment
Assignees
Labels

Comments

@jmesserly
Copy link
Contributor

... to replace our "legacy" one. We don't have to remove legacy yet but this opens the door.

The reason to support both RequireJS and CommonJS (our "--modules=node" format) is that RequireJS is to offer more options & compatibility, and require is a wee bit more friendly for browsers (as the code is already wrapped in a "define", the script can be executed directly).

http://requirejs.org/docs/start.html
here's an example app
https://github.com/volojs/create-template/tree/master/www

it looks roughly:

define(function (require) {
    // Load any app-specific modules
    // with a relative require call,
    // like:
    var messages = require('./messages');

    // Load library/vendor modules using
    // full IDs, like:
    var print = require('print');

    print(messages.getHello());

    // exports are returned here
});
@jmesserly
Copy link
Contributor Author

https://codereview.chromium.org/2249233002/, I opted for using an explicit deps array to avoid having requirejs parse the body to find require

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant