-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug in a browser:Uncaught ReferenceError: process is not defined. #3222
Comments
Can you provide a reproducible example or JSFiddle? That code should never even be run in a web browser (and doesn't even exist in our web builds)... it's solely for Node if you import the files improperly (would double extensions)... Those What setup are you using to bundle? And what does the code where you import us look like? |
import hljs from "highlight.js/lib/core.js";
import javascript from "highlight.js/lib/languages/javascript.js";
export default hljs;
hljs.registerLanguage("javascript", javascript); |
It should be imported with out any extension (so the dynamic exports can do their thing), which is what the warning says. import javascript from "highlight.js/lib/languages/javascript"; Perhaps we should have introduced a build-time error instead. |
"d:\Documents\github\markdown-reader\node_modules\highlight.js\lib\languages\javascript.js.js" function emitWarning() {
if (!emitWarning.warned) {
emitWarning.warned = true;
process.emitWarning(
'Using file extension in specifier is deprecated, use "highlight.js/lib/languages/javascript" instead of "highlight.js/lib/languages/javascript.js"',
'DeprecationWarning'
);
}
}
emitWarning();
module.exports = require('./javascript.js'); |
I should be able to use highlight.js in the browser correctly with webpack 5. |
I upgraded highlight.js from 10.7.2 to 11.0, and then it crashed. |
As I said, you need to remove the import javascript from "highlight.js/lib/languages/javascript"; // NO .js extension Languages are now always imported without an extension in version 11. |
Technically (with a build system) this code could end up in the browser, so we should use only APIs available in both browser and node.js. Resolves highlightjs#3222.
Technically (with a build system) this code could end up in the browser, so we should use only APIs available in both browser and node.js. Resolves #3222.
Resolved with release of 11.0.1. |
bug in a browser:
highlight.js/tools/build_node.js
Line 37 in 5dc5176
Uncaught ReferenceError: process is not defined
You should use "console.warn" when running in a browser.
The text was updated successfully, but these errors were encountered: