Skip to content

Commit 47bb058

Browse files
author
Chuck Dumont
authored
Merge pull request #60 from chuckdumont/work2
Add noConsole option
2 parents 48f3d05 + 256f17e commit 47bb058

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ If not specified, the default pattern `imports-loader|exports-loader)[?!]` is us
199199

200200
This property is optional. If the value is truthy, then undefined features will be treated as false for the purpose of dojo/has loader plugin feature evaluation at build time. See [The dojo/has loader extension](#the-dojohas-loader-extension) for more information.
201201

202+
### noConsole
203+
204+
This property is optional. If the value is truthy, then console output from building the Dojo loader will be suppressed.
205+
202206
# Building the Dojo loader
203207

204208
This plugin uses a custom build of the Dojo loader. The built loader is packaged as a CommonJS module so that it may be more easily consumed by Webpack. The loader build config specifies has.js features which exclude unneeded code (e.g. for loading modules) so that the loader embedded into the client is as small as possible (~4KB after uglify and gzip). The Dojo loader builder requires that the Dojo util directory is a sibling of the `dojo` directory and is named either `util` or `dojo-util`.

lib/DojoAMDPlugin.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = class DojoAMDPlugin {
7474
loaderConfig.baseUrl = path.resolve(compiler.context, loaderConfig.baseUrl || ".").replace(/\\/g, "/");
7575

7676
if (!loaderScope.require) {
77-
this.getDojoLoader(this.options, loaderConfig, (err, dojoLoader) => {
77+
this.getDojoLoader(loaderConfig, (err, dojoLoader) => {
7878
if (!err) {
7979
dojoLoader.call(loaderScope, loaderConfig, {hasCache:{'dojo-config-api':1, 'dojo-inject-api':1, 'host-node':0, 'dom':0, 'dojo-sniff':0}}, loaderScope, loaderScope);
8080
}
@@ -183,7 +183,7 @@ Refer to https://github.com/OpenNTF/dojo-webpack-plugin/blob/master/README.md#bu
183183
alias['dojo/loaderProxy'] = path.resolve(__dirname, "..", "loaders", "dojo", "loaderProxy");
184184
}
185185

186-
getDojoLoader(options__, loaderConfig, callback) {
186+
getDojoLoader(loaderConfig, callback) {
187187
var dojoLoader;
188188
if (this.options.loader) {
189189
try {
@@ -193,7 +193,9 @@ Refer to https://github.com/OpenNTF/dojo-webpack-plugin/blob/master/README.md#bu
193193
}
194194
callback(null, dojoLoader);
195195
} else {
196-
console.log("Dojo loader not specified in options. Building the loader...");
196+
if (!this.options.noConsole) {
197+
console.log("Dojo loader not specified in options. Building the loader...");
198+
}
197199
const execFile = require("child_process").execFile;
198200
const tmp = require("tmp");
199201
let dojoPath;
@@ -221,10 +223,14 @@ Refer to https://github.com/OpenNTF/dojo-webpack-plugin/blob/master/README.md#bu
221223
tempDir // target location
222224
], (error, stdout, stderr) => {
223225
if (error) {
224-
console.log(stderr.toString());
226+
if (!this.options.noConsole) {
227+
console.log(stderr.toString());
228+
}
225229
callback(error);
226230
} else {
227-
console.log(stdout.toString());
231+
if (!this.options.noConsole) {
232+
console.log(stdout.toString());
233+
}
228234
this.options.loader = path.join(tempDir, "dojo/dojo.js");
229235
dojoLoader = require(path.join(this.options.loader));
230236
callback(null, dojoLoader);

test/ErrorTestCases/misc/loaderVersion/webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module.exports = {
1313
loaderConfig: {
1414
paths:{test: "."}
1515
},
16-
loader: loaderPath
16+
loader: loaderPath,
17+
noConsole: true
1718
})
1819
]
1920
};

test/ErrorTestCases/options/badDojoPath/webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = {
66
loaderConfig: {
77
paths:{test: "."},
88
packages:[{name: "dojo", location: "./dojo"}]
9-
}
9+
},
10+
noConsole: true
1011
})
1112
]
1213
};

test/ErrorTestCases/options/missingDojo/webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
new DojoWebpackPlugin({
66
loaderConfig: {
77
paths:{test: "."}
8-
}
8+
},
9+
noConsole: true
910
})
1011
]
1112
};

test/TestCases/dependencies/constDeps/webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
new DojoWebpackPlugin({
66
loaderConfig: {
77
paths:{test: "."},
8-
packages:[{name: "dojo", location: "../../../../node_modules/dojo"}]
8+
packages:[{name: "dojo", location: "../../../../node_modules/dojo"}],
9+
noConsole: true
910
}
1011
})
1112
],

0 commit comments

Comments
 (0)