Skip to content

Commit 2b97e41

Browse files
Name all AMD modules
When the entire bundle (load-image.all.min.js) is loaded, require.js has no concept of which of the bundled modules is which unless we explicitly provide names for them. The developer still needs to tell require.js that this file contains all of the referenced modules though, so I added a note about that in the README.
1 parent 3ddac4f commit 2b97e41

8 files changed

+28
-12
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ Or alternatively, choose which components you want to include:
4545
<script src="js/load-image-exif-map.js"></script>
4646
```
4747

48+
### AMD
49+
The different modules support AMD, so you can load them with require.js either individually or from the minified bundle. The modules are named to support loading the bundle, so you need to use the actual module names in your `requirejs.config` (modules are named like their filenames without the file extension, so `load-image-orientation.js` becomes `load-image-orientation`).
50+
51+
If you want to load multiple modules from the minified bundle, use the [bundles options](http://requirejs.org/docs/api.html#config-bundles) in your `requirejs.config` call, like this:
52+
53+
```js
54+
requirejs.config({
55+
paths: {
56+
'load-image-all': 'vendor/load-image.all.min'
57+
},
58+
bundles: {
59+
'load-image-all': ['load-image', 'load-image-orientation', 'load-image-ios', 'load-image-meta', 'load-image-exif']
60+
}
61+
});
62+
```
63+
4864
## Usage
4965

5066
### Image loading

js/load-image-exif-map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
(function (factory) {
1818
'use strict';
1919
if (typeof define === 'function' && define.amd) {
20-
// Register as an anonymous AMD module:
21-
define(['load-image', 'load-image-exif'], factory);
20+
// Register as a named AMD module:
21+
define('load-image-exif-map', ['load-image', 'load-image-exif'], factory);
2222
} else {
2323
// Browser globals:
2424
factory(window.loadImage);

js/load-image-exif.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
(function (factory) {
1616
'use strict';
1717
if (typeof define === 'function' && define.amd) {
18-
// Register as an anonymous AMD module:
19-
define(['load-image', 'load-image-meta'], factory);
18+
// Register as a named AMD module:
19+
define('load-image-exif', ['load-image', 'load-image-meta'], factory);
2020
} else {
2121
// Browser globals:
2222
factory(window.loadImage);

js/load-image-ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
(function (factory) {
1919
'use strict';
2020
if (typeof define === 'function' && define.amd) {
21-
// Register as an anonymous AMD module:
22-
define(['load-image'], factory);
21+
// Register as a named AMD module:
22+
define('load-image-ios', ['load-image'], factory);
2323
} else {
2424
// Browser globals:
2525
factory(window.loadImage);

js/load-image-meta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
(function (factory) {
2020
'use strict';
2121
if (typeof define === 'function' && define.amd) {
22-
// Register as an anonymous AMD module:
23-
define(['load-image'], factory);
22+
// Register as a named AMD module:
23+
define('load-image-meta', ['load-image'], factory);
2424
} else {
2525
// Browser globals:
2626
factory(window.loadImage);

js/load-image-orientation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
(function (factory) {
1515
'use strict';
1616
if (typeof define === 'function' && define.amd) {
17-
// Register as an anonymous AMD module:
18-
define(['load-image'], factory);
17+
// Register as a named AMD module:
18+
define('load-image-orientation', ['load-image'], factory);
1919
} else {
2020
// Browser globals:
2121
factory(window.loadImage);

js/load-image.all.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/load-image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
};
293293

294294
if (typeof define === 'function' && define.amd) {
295-
define(function () {
295+
define('load-image', function () {
296296
return loadImage;
297297
});
298298
} else {

0 commit comments

Comments
 (0)