diff --git a/lib/loader.js b/lib/loader.js index 3c3fad5..8f0cc81 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -1,6 +1,6 @@ const cheerio = require('cheerio'); const Prism = require('prismjs'); -require('prismjs/components/prism-typescript'); +const loadLanguages = require('prismjs/components/index'); const classNameUtils = require('./classNameUtils'); const escape = require('./escape'); const option = require('./option'); @@ -13,6 +13,8 @@ const cheerioOption = { decodeEntities: false } +loadLanguages('typescript'); + function loader(input, options) { options = option.assignDefault(options); @@ -23,7 +25,7 @@ function loader(input, options) { const $elements = $(SELECTOR); if ($elements.length !== 0) { - options.languages.forEach(language => require(`prismjs/components/prism-${language}`)); + loadLanguages(options.languages); } $elements.each(function(index, element) {