MCPcopy Index your code
hub / github.com/highlightjs/highlight.js / buildNodeLanguage

Function buildNodeLanguage

tools/build_node.js:37–66  ·  view source on GitHub ↗
(language, options)

Source from the content-addressed store, hash-verified

35}
36
37async function buildNodeLanguage(language, options) {
38 const EMIT = `function emitWarning() {
39 if (!emitWarning.warned) {
40 emitWarning.warned = true;
41 console.log(
42 'Deprecation (warning): Using file extension in specifier is deprecated, use "highlight.js/lib/languages/%%%%" instead of "highlight.js/lib/languages/%%%%.js"'
43 );
44 }
45 }
46 emitWarning();`;
47 const CJS_STUB = `${EMIT}
48 module.exports = require('./%%%%.js');`;
49 const ES_STUB = `${EMIT}
50 import lang from './%%%%.js';
51 export default lang;`;
52 const input = { ...config.rollup.core.input, input: language.path };
53 const output = { ...config.rollup.node.output, file: `${process.env.BUILD_DIR}/lib/languages/${language.name}.js` };
54 await rollupWrite(input, output);
55 await fs.writeFile(`${process.env.BUILD_DIR}/lib/languages/${language.name}.js.js`,
56 CJS_STUB.replace(/%%%%/g, language.name));
57 if (options.esm) {
58 await fs.writeFile(`${process.env.BUILD_DIR}/es/languages/${language.name}.js.js`,
59 ES_STUB.replace(/%%%%/g, language.name));
60 await rollupWrite(input, {
61 ...output,
62 format: "es",
63 file: output.file.replace("/lib/", "/es/")
64 });
65 }
66}
67
68const EXCLUDE = ["join"];
69

Callers 1

buildLanguagesFunction · 0.85

Calls 1

rollupWriteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…