Skip to content
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

Critical dependency: the request of a dependency is an expression #127

Closed
rm-arun-kumar opened this issue Mar 2, 2021 · 8 comments
Closed

Comments

@rm-arun-kumar
Copy link

This is my code

import { parse, HtmlGenerator } from 'latex.js';

function getLatex (text) {
    const generator = new HtmlGenerator({ hyphenate: false});
    const result = parse(text, { generator }).htmlDocument();
    return result.body.innerHTML;
}

I am using rollup for my project.
when I am running the rollup, end of the task I am getting the below error.

./node_modules/latex.js/dist/latex.js
Critical dependency: the request of a dependency is an expression
@ ./packages/src/js/index.js
@ ./node_modules/react-styleguidist/lib/loaders/styleguide-loader.js!./node_modules/react-styleguidist/lib/client/index.js
@ ./node_modules/react-styleguidist/lib/client/index.js
@ multi ./node_modules/react-styleguidist/lib/client/index ./node_modules/react-dev-utils/webpackHotDevClient.js

What should I do?

@michael-brade
Copy link
Owner

First of all, I have no idea what this really means :-p
But it seems that you are using webpack, not rollup -- or maybe rollup calls webpack somewhere. In any case, this is a webpack warning. So if it is just a warning, it should work anyway. Here is one of the issues that mentions this message:
moment/moment#5489

@michael-brade
Copy link
Owner

whoops, I just noticed that I quoted moment, not webpack. Well, in case this "warning" cannot be ignored, please give me a way to reproduce the problem so that I can take a look.

@rm-arun-kumar
Copy link
Author

rm-arun-kumar commented Mar 2, 2021

So if it is just a warning, it should work anyway

Yes.

But, I published this project as a NPM package and used it by installing it for another project. Since I used Webpack in that project, I am getting the below error

image2

All the contents from the latex.mjs file are thrown as an error.

I raised the above issue based on this error. If the critical dependency warning is not the reason for this issue then what can be the solution?.

@rm-arun-kumar
Copy link
Author

The clear Screen shot is here.!

Screenshot from 2021-03-02 19-48-59

@michael-brade
Copy link
Owner

Yeah, it's a clear screenshot but I still have no idea what is going on. How can I reproduce this?

@rm-arun-kumar
Copy link
Author

rm-arun-kumar commented Mar 5, 2021

I am really sorry, I do not know how to explain this to you clearly. But resolved this.

Reason:-
I missed the entry in the webpack.resolve.alias
Solution:-
After I added the 'latex.js': path.resolve(__dirname, "../node_modules/latex.js/dist/latex.js") line in webpack configuration, I am not getting any errors ( except Critical dependency warning ).

Thanks for your time @michael-brade 😄

@michael-brade
Copy link
Owner

I see! That makes sense in a way 😁 But strange is: why doesn't it pick up the main entry in latex.js's package.json? Hm...

@rm-arun-kumar
Copy link
Author

I also have that doubt. 🤔 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants