You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-26Lines changed: 22 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,7 @@ Webmake allows you to organize JavaScript code for the browser the same way
6
6
as you would for Node.js.
7
7
8
8
For a more in depth look into JavaScript modules and the reason for _Webmake_,
9
-
see the slides from my presentation at Warsaw's MeetJS:
10
-
11
-
**[JavaScript Modules Done Right][slides]**
9
+
see the slides from my presentation at Warsaw's MeetJS: [__JavaScript Modules Done Right__][slides]
12
10
13
11
## How does it work?
14
12
@@ -50,7 +48,7 @@ The generated file _build.js_ now contains the following:
50
48
```javascript
51
49
(function (modules) {
52
50
// about 60 lines of import/export path resolution logic
53
-
})({
51
+
})({
54
52
"foo": {
55
53
"add.js":function (exports, module, require) {
56
54
module.exports=function () {
@@ -71,8 +69,7 @@ The generated file _build.js_ now contains the following:
71
69
inc(a); // 2
72
70
}
73
71
}
74
-
})
75
-
("foo/program");
72
+
})("foo/program");
76
73
```
77
74
78
75
When loaded in browser, _program.js_ is immediately executed.
@@ -85,38 +82,37 @@ When loaded in browser, _program.js_ is immediately executed.
85
82
86
83
### From the shell:
87
84
88
-
$ webmake <input> <output>
85
+
$ webmake [options] <input> <output>
89
86
90
-
_input_ is the path to the initial module that should be executed when
91
-
script is loaded.
92
-
_output_ is the path to which the bundled browser ready code is written.
87
+
__input__ - Path to the initial module that should be executed when script is loaded.
88
+
__output__ - Filename at which browser ready bundle should be saved
93
89
94
-
Additionally you may output modules with [source maps][], for easier debugging.
90
+
#### Options
95
91
96
-
$ webmake --sourcemap <input> <output>
92
+
##### name `string`
97
93
98
-
Source maps work very well in WebKit and Chrome's web inspector. Firefox's Firebug
99
-
however has some [issues][firebug issue].
94
+
Name at which program should be exposed in your namespace. Technically just assigns exported module to global namespace.
100
95
101
-
###Programmatically:
96
+
##### amd `string`
102
97
103
-
```javascript
104
-
webmake(inputPath[, options], callback);
105
-
```
98
+
Expose bundle as AMD module. If used together with _[name](#name-string)_ option, module will be defined with provided name.
106
99
107
-
#### Options
108
-
##### output `string`
100
+
##### include `string`
109
101
110
-
Path of output file, if you want _Webmake_ to create one
102
+
Additional module(s) that should be included but due specific reasons are
103
+
not picked by parser (can be set multiple times)
111
104
112
-
##### include `string|Array`
105
+
##### sourceMap `boolean`
113
106
114
-
Additional module(s) that need to be included (but due specific reasons can't
115
-
be picked by parser).
107
+
Include [source maps][], for easier debugging. Source maps work very well in WebKit and Chrome's web inspector. Firefox's Firebug however has some [issues][firebug issue].
116
108
117
-
##### sourceMap `boolean`
109
+
### Programmatically:
110
+
111
+
```javascript
112
+
webmake(inputPath[, options][, callback]);
113
+
```
118
114
119
-
Include [source maps][].
115
+
`webmake` by default returns generated source to callback, but if _output_ path is provided as one of the options, then source will be automatically saved to file
0 commit comments