highlightjs/highlightjs-vue

Error in dist files

cyberalien opened this issue · 2 comments

File dist/highlightjs-vue.cjs.js starts with invalid code:

var module$1 = module$1 ? module$1 : {};

It should be:

var module$1 = module ? module : {};

Sorry, I see no dist files in this repo or in the package as it was resolved by yarn when I required it.

Am I missing something obvious here or is this package just broken?

Its just broken. I've used this code instead of this package:

import hljs from 'highlight.js';

/**
 * Copied from highlightjs-vue: https://github.com/highlightjs/highlightjs-vue
 *
 * Author: Sara Lissette Luis Ibáñez <lissette.ibnz@gmail.com>
 * License: BSD-3-Clause
 */

export function hljsDefineVue() {
	return {
		subLanguage: 'xml',
		contains: [
			hljs.COMMENT('<!--', '-->', {
				relevance: 10,
			}),
			{
				begin: /^(\s*)(<script>)/gm,
				end: /^(\s*)(<\/script>)/gm,
				subLanguage: 'javascript',
				excludeBegin: true,
				excludeEnd: true,
			},
			{
				begin: /^(\s*)(<script lang=["']ts["']>)/gm,
				end: /^(\s*)(<\/script>)/gm,
				subLanguage: 'typescript',
				excludeBegin: true,
				excludeEnd: true,
			},
			{
				begin: /^(\s*)(<style(\sscoped)?>)/gm,
				end: /^(\s*)(<\/style>)/gm,
				subLanguage: 'css',
				excludeBegin: true,
				excludeEnd: true,
			},
			{
				begin: /^(\s*)(<style lang=["'](scss|sass)["'](\sscoped)?>)/gm,
				end: /^(\s*)(<\/style>)/gm,
				subLanguage: 'scss',
				excludeBegin: true,
				excludeEnd: true,
			},
			{
				begin: /^(\s*)(<style lang=["']stylus["'](\sscoped)?>)/gm,
				end: /^(\s*)(<\/style>)/gm,
				subLanguage: 'stylus',
				excludeBegin: true,
				excludeEnd: true,
			},
		],
	};
}

Code above is using ES modules, but if you are not using ES modules, replace import and export lines and it should be working.