Registry / web-framework / highlight.js-async-webpack

highlight.js-async-webpack

JSON →
library1.0.4jsnpmunverified

Wraps highlight.js language modules as async webpack chunks, enabling on-demand loading of syntax highlighting. Version 1.0.4 (latest) returns false on error. Provides `hljsBlock(dom, lang, callback)` for async highlighting. Minimal API, no peer dependencies. Only compatible with webpack due to dynamic require context. Not actively maintained; last release 5+ years ago.

npm install highlight.js-async-webpack
INSTALL
IMPORT
SIG · HIGHLIGHT.JS-ASYNC
H
highlight.js-async-webpack
web-frameworkjavascriptv1.0.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import hljs from 'highlight.js-async-webpack'
✗ const hljs = require('highlight.js-async-webpack')
ESM default import only; CommonJS require may return broken object
hljsBlock
✓ hljs.hljsBlock(dom, lang, callback)
✗ hljs.hljsBlock(dom, lang)
Callback is required; omitted callback will break async flow
hljsBlock
✓ import hljs from 'highlight.js-async-webpack'; hljs.hljsBlock(...)
✗ import { hljsBlock } from 'highlight.js-async-webpack'
Named export not available; must use default import

Demonstrates importing the package and invoking hljsBlock with a DOM element, language class, and callback.

import hljs from 'highlight.js-async-webpack'; const codeElement = document.querySelector('code.language-javascript'); if (codeElement) { hljs.hljsBlock(codeElement, 'javascript', () => { console.log('Highlighting complete'); }); }
Debug
Known issues
deprecatedPackage not updated since 2018; may not work with modern webpack (4/5) or Node.js versions.
fix
Consider using highlight.js with dynamic imports directly, or use highlight.js official npm package.
affects: >=1.0.4
breakingRequires webpack and a specific async chunk naming convention; not compatible with other bundlers.
fix
Use only in webpack projects; for others, use highlight.js manual chunking.
affects: >=0.0.0
gotchaThe callback is mandatory; omitting it will cause the highlighting to never complete.
fix
Always provide a callback function even if it's a no-op.
affects: >=1.0.2
gotchaLanguage files must exist at runtime; package does not include all languages by default.
fix
Ensure the required language files are present in the webpack build context.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'highlight.js-async-webpack'
Package not installed or not in node_modules.
fix
Run: npm install highlight.js-async-webpack
TypeError: hljs.hljsBlock is not a function
Incorrect import (e.g., named import) or using require instead of import.
fix
Use: import hljs from 'highlight.js-async-webpack' (default import)
Error: Cannot find module './lang/xxx'
Requested language file not available in the async chunk path.
fix
Check that the language name passed to hljsBlock matches an existing file like 'javascript' (not 'js').
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
highlight.js-async-webpack — npm install highlight.js-async-webpack · libregistry