-
Notifications
You must be signed in to change notification settings - Fork 477
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 dependencies" in Webpack #76
Comments
I'm not familiar with webpack, but those lines have a function, which is to expose part of the package.json info for consumers of the library. |
Webpack is like Browserify when packing modules in CommomJS(static analytics). I don't see a good solution here. |
ok, I see, yes, reading that thread that seems to be their recommended solution. |
There is a spec for ignoring modules for the browser: https://gist.github.com/defunctzombie/4339901#ignore-a-module i. e. "browser": {
"./package.json": false,
"./src/formatters": false
} |
This bit me too :( |
For now I am doing this: import jsondiffpatchHtmlFormatter from 'jsondiffpatch/src/formatters/html' |
Can you keep the variable for package.json but remove the variable for ./formatters?
also do the same for texts.js var dmp = require('../../public/external/diff_match_patch_uncompressed' ); so browserify can work? Best Regards. |
I don't use browserify (using webpack), will the suggestion from @sokra work with browserify? |
I changed to webpack too because browserify don't support expression in require(expression).
while jsondiffpatch are installed with npm. |
setting exprContextCritical: false in webpack.config worked for me. |
Any updates on this? Is it safe to use @cmelion's solution? |
Hi, any recommendations for what to do here? I wasn't able to use @cmelion solution, and it would be nice to be able to include this without any major webpack configuration changes. |
@arbesfeld: Can you clarify what prevented you from using the webpack config hack?
|
@cmelion I am getting this error when I add that:
|
@arbesfeld can you get a stack trace? |
I'm having difficulty getting a stacktrace, but here is the source context of the thrown error. I added
|
@arbesfeld I was hoping to see where the reference to ../package.json was coming from. |
I don't have any When I copy and pasted the library and commented out these lines everything worked: https://github.com/benjamine/jsondiffpatch/blob/master/public/build/jsondiffpatch-full.js#L3397-L3411 |
Prior to using NPM to import the dependency I believe I ended up hacking a copy of the lib as well.
Store:
|
@arbesfeld You're right, those requires(exp) generate dynamic contexts, which resolve to webpack bundling every file in ./ - and, of course, neither '../package.json' nor './formatters' are in that list. Setting exprContextCritical to false just gets rid of the build-time warning. For me, what did the trick was using a ContextReplacementPlugin, explicitly mapping all dynamic requires to actual files:
|
For anyone stumbling across this in the future, a discussion around removing the dynamic requires can be found here: #107. Looks like a PR is in order, but will require some testing with webpack, browserfiy, and node. I'm only using the diff creation and patching parts of
|
I tried the context replacement plugin but still get the warning. Does anyone else have luck w/ this? Unfortunately, I'm not directly using jsondiffpatch, but a dependency I'm using requires it so I can't really change how I'm trying to use jsondiffpatch.
|
looks like
|
@tony-kerz you shouldn't import from an inner path, can you try: `import jsondiffpatch from 'jsondiffpatch';`
const diffPatcher = jsondiffpatch.create();
const delta = diffPatcher.diff(left, right); |
This issue was fixed at |
@benjamine the following returns
but the other incantation you provided here works well, so i'm good, thx again! |
I got this warning when in Webpack:
webpack/webpack#196
https://github.com/benjamine/jsondiffpatch/blob/master/src/main.js#L48
It's still working thank god. But is that ok we remove these line to get rid of the warnings?
The text was updated successfully, but these errors were encountered: