Skip to content

Commit ea4e71e

Browse files
author
Chuck Dumont
authored
Merge pull request #33 from chuckdumont/work
Build smaller Dojo loader if version of Dojo has dojo/dojo#266
2 parents c22fae3 + b74e8f4 commit ea4e71e

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

buildDojo/loader.profile.js

+29-16
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,41 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
/*
1817
* Dojo build profile for building the loader
1918
*/
2019
const nodeRequire = require.rawConfig && require.rawConfig.loaderPatch.nodeRequire || require;
2120
const path = nodeRequire("path");
2221
const fs = nodeRequire("fs");
23-
var profile = (() => {
24-
var profilePath, dojoPath;
25-
process.argv.forEach((arg, i) => {
26-
if (arg === '--profile') {
27-
profilePath = process.argv[i+1];
28-
} else if (arg === '--dojoPath') {
29-
dojoPath = process.argv[i+1];
30-
}
31-
});
32-
if (!profilePath) {
33-
throw new Error("--profile command line option not specified");
34-
}
35-
if (!dojoPath) {
36-
throw new Error("--dojoPath command line option not specified");
22+
23+
var profilePath, dojoPath;
24+
process.argv.forEach((arg, i) => {
25+
if (arg === '--profile') {
26+
profilePath = process.argv[i+1];
27+
} else if (arg === '--dojoPath') {
28+
dojoPath = process.argv[i+1];
3729
}
30+
});
31+
if (!profilePath) {
32+
throw new Error("--profile command line option not specified");
33+
}
34+
if (!dojoPath) {
35+
throw new Error("--dojoPath command line option not specified");
36+
}
37+
38+
const version = nodeRequire(path.resolve(dojoPath, "../", "./package.json")).version;
39+
const versionParts = version.split(".");
40+
const majorVersion = parseInt(versionParts[0]), minorVersion = parseInt(versionParts[1]), patchVersion = parseInt(versionParts[2]);
41+
if (majorVersion !== 1) {
42+
throw new Error("Unsupported Dojo Version");
43+
}
44+
const hasInjectApiFix = /* True if the version of Dojo has https://github.com/dojo/dojo/pull/266 */
45+
minorVersion > 12 ||
46+
minorVersion === 12 && patchVersion >= 3 ||
47+
minorVersion === 11 && patchVersion >= 5 ||
48+
minorVersion === 10 && patchVersion >= 9;
49+
50+
var profile = (() => {
3851
const profileDir = path.resolve(profilePath);
3952
const dojoDir = path.resolve(dojoPath, "..");
4053
var util = "../dojo-util";
@@ -61,7 +74,7 @@ var profile = (() => {
6174

6275
staticHasFeatures:{
6376
'dojo-config-api': 1,
64-
'dojo-inject-api': 1,
77+
'dojo-inject-api': hasInjectApiFix ? 0 : 1,
6578
'dojo-built': 1,
6679
'config-dojo-loader-catches': 0,
6780
'config-tlmSiblingOfDojo': 0,

0 commit comments

Comments
 (0)