Skip to content

Commit 191b411

Browse files
Added silent option to loadLanguages (#2147)
This adds an option to `loadLanguages` which prevents all warning messages.
1 parent 1fbac16 commit 191b411

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

components/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ function loadLanguages(languages) {
3030

3131
getLoader(components, languages, loaded).load(lang => {
3232
if (!(lang in components.languages)) {
33-
console.warn('Language does not exist: ' + lang);
33+
if (!loadLanguages.silent) {
34+
console.warn('Language does not exist: ' + lang);
35+
}
3436
return;
3537
}
3638

@@ -46,4 +48,9 @@ function loadLanguages(languages) {
4648
});
4749
}
4850

51+
/**
52+
* Set this to `true` to prevent all warning messages `loadLanguages` logs.
53+
*/
54+
loadLanguages.silent = false;
55+
4956
module.exports = loadLanguages;

index.html

+2
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ <h2>Usage with Node</h2>
226226

227227
<p><strong>Note</strong>: Do <em>not</em> use <code class="language-javascript">loadLanguages()</code> with Webpack or another bundler, as this will cause Webpack to include all languages and plugins. Use the babel plugin described above.</p>
228228

229+
<p><strong>Note</strong>: <code class="language-javascript">loadLanguages()</code> will ignore unknown languages and log warning messages to the console. You can prevent the warnings by setting <code class="language-javascript">loadLanguages.silent = true</code>.</p>
230+
229231
</section>
230232

231233
<section class="language-markup">

0 commit comments

Comments
 (0)