-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
MissingEntryError with javascript_packs_with_chunks_tag but not with javascript_pack_tag #1967
Comments
UPDATE:It looks like Webpacker is expecting this JSON schema for manifest.json:
I'm not positive, but is that the CommonsChunk JSON schema? Wepacker says it supports Webpack v4; however, the Webpack v4 documentation recommends using SplitChunksPlugin in combination with the ManifestPlugin (see here). The issue is, the ManifestPlugin doesn't output the manifest in the required schema, it uses the standard schema that |
There's another manifest plugin, https://github.com/webdeveric/webpack-assets-manifest, it supports an option entrypoints (https://github.com/webdeveric/webpack-assets-manifest#entrypoints), which compiles a manifest with the entrypoints schema. |
Can confirm, I have exactly the same issue 👍 |
@robbymarston @h0jeZvgoxFepBQ2C Can you post the entire error log with the entire |
Looks like this is working for me: in webpack environment.js
and then use
Strange thing is now, that it doesnt work anymore with |
Ok this f... still not working, since my chunks are loaded twice :( When I only use Can somone post an example on how to do following basic stuff?
And with splitchunks each npm module should be in its own file (https://hackernoon.com/the-100-correct-way-to-split-your-chunks-with-webpack-f8a9df5b7758?gi=3cd6ba7651c0) I just can't make it work :( This should be basic stuff and not take 30+ hours to finish :( I miss the old times where I could just use sprockets and just require these things easily. |
@h0jeZvgoxFepBQ2C, let me repurpose my comment from here #1835 (comment): Splitting your app into multiple packs, just to load them on the same page is the waste of performance and compile time. Webpack is assuming that those different entrypoints are on exclusive pages (hence the duplication). Example: This would be the proper way to make a tree-shaken entrypoint:<%
# Some erb that loads in <head>.
# We need a way to get rails/erb data into webpack-land,
# the best way is to just have a "flag" for each chunk you might want to load.
%>
<script>
window.lazyChunks = {
react_component1: <%= @lazy_chunks[: react_component1].present? %>,
react_component2: <%= @lazy_chunks[: react_component2].present? %>,
};
</script>
<%= javascript_packs_with_chunks_tag 'application' %> <% # Some partial that contains your react_component1 component %>
<% # Setting this here will make `window.lazyChunks.react_component1` true in webpack-land %>
<%= @lazy_chunks[:react_component1] = true %>
<div id='react_component1'></div> // application.js
if(window.lazyChunks.react_component1) // resolves to true from the other file
import(/* webpackMode: "lazy" */ // can be 'lazy', 'lazy-once', 'eager', or 'weak'
/* webpackChunkName: "react_component1" */ // Adding this comment will cause our separate chunk to be named [my-chunk-name].js instead of [id].js.
'./../file/path/to/react_component1');
if(window.lazyChunks.react_component2)
import(/* webpackMode: "lazy" */
/* webpackChunkName: "react_component2" */
'./../file/path/to/react_component2'); Docs for using ES6 dynamic import(). Any sub-files that you need to load will be available to this single entrypoint. Without this, you are fighting and negating any tree-shaking. Better yet, but using dynamic import, webpack can automatically generate vendor chunks (like React) that are shared between your lazy chunks! These are the same methods that your linked guide uses. You can further customize this in webpackER via splitChunks, here is the doc: https://github.com/rails/webpacker/blob/master/docs/webpack.md#add-splitchunks-webpack-v4
Like I said in the other issue, WebpackER makes poor use of webpacks strengths. You are one of many having similar issues. Feel free to ask any follow-up questions, hope this helps! |
Actually I can't really tell why I even have to use webpacker.. Maybe it makes more sense to use just webpack and remove the webpacker gem? I think i understand your solution, but it still looks kinda dirty hack somehow :/ And actually the compiling performance is much better, since during changes you only have to compile your own code, not compile the 1MB file in total with all npm packages included.. At least this is the reason why I even do this - and which also happens now (-> compiling is pretty fast now). |
I and others have suggested this change, it's a shame to see webpack get such a bad rap from webpackER.
You don't, if you look around at other issues, I give better details on how you can resolve packs yourself from a
|
I'm getting a
MissingEntryError
when I usejavascript_packs_with_chunks_tag
but not withjavascript_pack_tag
. Here's the aforementioned error:Clearly react_manager is present in the manifest and in the packs directory, so I'm not sure what the issue is. Note: I'm using Webpacker 4.0.0.rc.7 with Webpack 4.29.5. and react_on_rails' recommended project structure.
Here are my source files (edited for readability):
config/webpacker.yml
webpack.config.js
index.html.erb
Any help is much appreciated, thanks!
The text was updated successfully, but these errors were encountered: