@@ -41,10 +41,28 @@ async function buildCJSIndex(name, languages) {
41
41
}
42
42
43
43
async function buildNodeLanguage ( language , options ) {
44
+ const EMIT = `function emitWarning() {
45
+ if (!emitWarning.warned) {
46
+ emitWarning.warned = true;
47
+ process.emitWarning(
48
+ 'Using file extension in specifier is deprecated, use "highlight.js/lib/languages/%%%%" instead'
49
+ );
50
+ }
51
+ }
52
+ emitWarning();` ;
53
+ const CJS_STUB = `${ EMIT }
54
+ module.exports = require('./%%%%.js');` ;
55
+ const ES_STUB = `${ EMIT }
56
+ import lang from './%%%%.js';
57
+ export default lang;` ;
44
58
const input = { ...config . rollup . node . input , input : language . path } ;
45
59
const output = { ...config . rollup . node . output , file : `${ process . env . BUILD_DIR } /lib/languages/${ language . name } .js` } ;
46
60
await rollupWrite ( input , output ) ;
61
+ await fs . writeFile ( `${ process . env . BUILD_DIR } /lib/languages/${ language . name } .js.js` ,
62
+ CJS_STUB . replace ( / % % % % / g, language . name ) ) ;
47
63
if ( options . esm ) {
64
+ await fs . writeFile ( `${ process . env . BUILD_DIR } /es/languages/${ language . name } .js.js` ,
65
+ ES_STUB . replace ( / % % % % / g, language . name ) ) ;
48
66
await rollupWrite ( input , { ...output ,
49
67
format : "es" ,
50
68
file : output . file . replace ( "/lib/" , "/es/" )
0 commit comments