Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit 4baac2e

Browse files
committed
Merge pull request #1965 from DFurnes/dependency-man
Conditionally loads polyfills based on feature detection.
2 parents 7b4acf0 + 02b0141 commit 4baac2e

File tree

7 files changed

+89
-409
lines changed

7 files changed

+89
-409
lines changed

lib/themes/dosomething/paraneue_dosomething/bower.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
"mailcheck": "~1.0.3",
2626
"html5shiv": "~3.7.0",
2727
"requirejs": "~2.1.11",
28+
"requirejs-text": "requirejs/text#~2.0.12",
2829
"lodash": "~2.4.1",
2930
"unveil": "~1.3.0",
30-
"jquery-once": "~1.2.6"
31+
"jquery-once": "~1.2.6",
32+
"respond": "~1.4.2",
33+
"REM-unit-polyfill": "~1.2.3"
3134
}
3235
}

lib/themes/dosomething/paraneue_dosomething/js/config.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,4 @@
88
(function() {
99
"use strict";
1010

11-
12-
require.config({
13-
baseUrl: "/profiles/dosomething/themes/dosomething/paraneue_dosomething/js/",
14-
include: "main",
15-
paths: {
16-
"neue": "../bower_components/neue/js",
17-
"mailcheck": "../bower_components/mailcheck/src/mailcheck",
18-
"lodash": "../bower_components/lodash/dist/lodash"
19-
},
20-
shim: {
21-
"mailcheck": { exports: "Kicksend.mailcheck" }
22-
}
23-
});
2411
})();
Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,61 @@
1-
//
2-
//
3-
// The main DS app. This guy runs the show.
4-
//
5-
//
1+
/**
2+
* We configure RequireJS options, paths, and shims here.
3+
*
4+
* - baseURL: Path where modules will be loaded from at runtime.
5+
* - paths: Load any Bower components in here.
6+
* - excludeShallow: Any components that should *not* be included
7+
* in the minified production build. They will be loaded in on
8+
* demand via the RequireJS loader.
9+
* - shim: Shim any non-AMD scripts.
10+
*
11+
* @see https://github.com/jrburke/r.js/blob/master/build/example.build.js
12+
*/
13+
require.config({
14+
baseUrl: "/profiles/dosomething/themes/dosomething/paraneue_dosomething/js/",
15+
include: "main",
16+
includeRequire: "main",
17+
paths: {
18+
"neue": "../bower_components/neue/js",
19+
"mailcheck": "../bower_components/mailcheck/src/mailcheck",
20+
"lodash": "../bower_components/lodash/dist/lodash",
21+
"text": "../bower_components/requirejs-text/text",
22+
"rem-unit-polyfill": "../bower_components/REM-unit-polyfill/js/rem",
23+
"respond": "../bower_components/respond/dest/respond.min",
24+
},
25+
excludeShallow: [
26+
"respond",
27+
"rem-unit-polyfill"
28+
],
29+
shim: {
30+
"mailcheck": { exports: "Kicksend.mailcheck" }
31+
}
32+
});
33+
634

35+
/**
36+
* This is where we load and initialize components of our app.
37+
*/
738
define("main", function(require) {
839
"use strict";
940

1041
// let's get going
1142
var $ = window.jQuery;
1243
var Finder = require("finder/Finder");
44+
var Features = require("utils/features");
45+
1346

14-
require("neue/main");
1547

1648
// Load polyfills
17-
require("neue/vendor/polyfills/respond");
18-
require("neue/vendor/polyfills/rem");
49+
if(!Features.mediaQueries) {
50+
require("respond");
51+
}
52+
53+
if(!Features.remUnits) {
54+
require("rem-unit-polyfill");
55+
}
1956

2057
// Initialize modules on load
58+
require("neue/main");
2159
require("campaign/sources");
2260
require("campaign/tips");
2361
require("campaign/ImageUploader");
@@ -34,6 +72,4 @@ define("main", function(require) {
3472
);
3573
}
3674
});
37-
38-
3975
});

0 commit comments

Comments
 (0)