-
Notifications
You must be signed in to change notification settings - Fork 221
Module Systems
Xiaohan Zhang edited this page Mar 14, 2017
·
1 revision
- commonjs -
require()
andexports =
- nodejs - same as commonjs except
module.exports =
is the actual variable they look at (and they aliasexports
tomodule.exports
) - AMD -
define(["dep1"], function(dep1) {...})
- async capable
- ES2015 Modules -
import { } from "foo"; export var k = ...
- Browsers don't support yet
- Global export -
window.foo = ...
, and you add scripts in the correct order
- Typescript - same as ES2015 module syntax, and then you specify
"module": commonjs, amd, systemjs, etc
in the tsconfig.json; Typescript converts the ES2015 module syntax into the other module system that you've specified - UMD - a piece of code you put at the beginning of your file to convert commonjs, AMD, or global export to work with each other
- Systemjs - some new thing that supports everything...?
- webpack/browserify - Can work with all of the module systems to create one js file that runs on the web
- require.js - an AMD only loader; you reference it in your webpage and it does the async loading of all the modules
- node.js - runs code specified in the nodejs module system (obviously)
Plottable 3.0 and later:
- Is written in ES2015 module syntax with Typescript
- Compiles and ships commonjs modules in its
/build
folder on npm - Compiles a single UMD module at
plottable.js