-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
require function is used in a way in which dependencies cannot be statically extracted #2675
Comments
This is fixed in webpack@2 |
with webpack@2, it's reproduced again. function getAsyncComponent(path, chunkname) {
return function(nextState, cb) {
require.ensure([], function(require) {
cb(null, require(path).default)
}, chunkname)
}
}
const Routes = (
<Router history={browserHistory}>
<Route path='/' getComponent ={ getAsyncComponent('./App.jsx','asyncApp') }>
<IndexRoute component ={ Home} />
<Route path='/hello' component = {Hello} />
<Route path='author' component = {AuthorList}>
<Route path= ':id' component = {Author} />
</Route>
</Route>
</Router>
)
export default Routes; |
@minnaq it indeed is being used in a way in which dependencies cannot be statically extracted.
|
@Kovensky
That part seems to be supported. Search this page for |
Is it possible to get webpack to ignore these errors? Then allow the amd-plugin that builds for the runtime to find bundles that you package via separate webpack configs ie. i18n A more complete example of https://github.com/webpack/i18n-webpack-plugin would be helpful here |
same issue. How to solve this? Thanks. |
How this one be closed ? |
The short answer is that webpack statically analyzes your require statements explained here: https://webpack.github.io/docs/context.html Fixing this is different for every case. If you post some code somebody should be able to point you in the right direction. https://gitter.im/webpack/webpack |
@drewwells the real issue was that thousands of lines were printed making it hard to find out what the problem was. The code literally was |
I understand there was a specific start to this thread, but the title indicates a more general issue that people find via Google searches. This being the use of variables in require() calls. It may help to change the title or open a new issue about console.log() if its desired to fix that. I don't think that particular bug will be addressed, since require.ensure is documented already: https://webpack.github.io/docs/code-splitting.html#commonjs-require-ensure |
I'm getting this error with this line: const broquire = require("broquire")(require); |
My code is:
There is the same warning in terminal
And there is also two error in browser
What's the reason is ? |
I get the same error for typedjson-npm. WARNING in ./~/typedjson-npm/js/typed-json.js |
My problem was solved by making following change - FROM
TO
i.e, avoiding the use of a Don't know the reason though. :| |
Using |
My problem is this
Are there any ways to fix this? |
My problem was a line in a library similar to var library = {};
library.require = require; // whyyyyy ಠ_ಠ |
Same here. @storybooks/storybook config goes like this;
Replacing line 1 with;
errors (warns?) with
Using webpack@3.11.0 |
That is because the code was changed from calling require.context in a way that was analyzable into a way that isn't. Webpack doesn't know what your arbitrary "resolve" function returns, or that PATH is immutable (if you compile your code to ES5) |
@Kovensky From what I understand, this warning means the dependencies are not statically analyzable, and thus cannot be tree-shaken. Is this correct? Is there anything else I should be aware of? If I weren't compiling down to ES5, would webpack figure out that PATH is immutable? |
The bigger problem here is that webpack doesn't know what the result of This is also not about tree-shaking, this is about knowing what to bundle in the first place. If webpack can't see that you're trying to look into the |
@sokra this is reproduced with webpack@3.11.0 as well. |
@jony89 what is your |
Im using https://github.com/biesbjerg/ngx-translate-extract and get this error when using marker function to extract strings :( |
@senyaak Submit an issue to that repo |
@montogeek this is a webpack issue... |
In case anyone else comes across this - I got this error because I was using |
@aj-r it's work |
You can get this error if you accidentally import something from For example this just happened to me when I used |
WARNING in ./node_modules/html-webpack-plugin/index.js 242:85-92 |
I added
console.log(require.ensure)
to my code and it resulted in thousands of error lines from webpack. Had to increase my tmux scrollback to 40K lines to see what happened.Not sure if it's really a bug but would have been nice if that message had been isolated from all the subsequent thousands of error lines that are really irrelevant.
The text was updated successfully, but these errors were encountered: