Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added silent option to loadLanguages #2147

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion components/index.js
Expand Up @@ -30,7 +30,9 @@ function loadLanguages(languages) {

getLoader(components, languages, loaded).load(lang => {
if (!(lang in components.languages)) {
console.warn('Language does not exist: ' + lang);
if (!loadLanguages.silent) {
console.warn('Language does not exist: ' + lang);
}
return;
}

Expand All @@ -46,4 +48,9 @@ function loadLanguages(languages) {
});
}

/**
* Set this to `true` to prevent all warning messages `loadLanguages` logs.
*/
loadLanguages.silent = false;

module.exports = loadLanguages;
2 changes: 2 additions & 0 deletions index.html
Expand Up @@ -226,6 +226,8 @@ <h2>Usage with Node</h2>

<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>

<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>

</section>

<section class="language-markup">
Expand Down