Comments (9)
For my understanding: but should finding the right spliited files not be handled by the runtime.js ?
Not necessarily:
- For static imports, like the one you're doing here, required chunks are supposed to be added to your page using
<script>
tags (theencore_entry_script_tags
does that by reading theentrypoints.json
file). Theruntime.js
file alone does not know anything about your files/chunks, it's mainly generic code that handles chunks registration/loading and should very rarely change between deployments. - For dynamic imports (
import(module).then(...)
) it will indeed retrieve the required chunks automatically (since that's kind of the point of dynamic imports). In this case it's the chunk doing the import that will call a function from the runtime telling it something along the lines of "Hey, I need a chunk called [name], can you load it for me (if not already done before)?".
from webpack-encore.
It might just be moved. import
statements are meant to be at the TOP of the file. If you mix them in the middle, they may be moved to the top (iirc, npm
definitely does this when executing and I assume webpack moves when packaging as well). Also, Webpack does a lot of rewriting your code, especially with the imports. So, it may have moved that code and made it look quite a bit different, but it should be there... somewhere :).
from webpack-encore.
@weaverryan ok, but why breaks an import the whole script?
the console.log() before and after the import doe not appear in the console, when importing the lib between. It seems that everything is broken when importing any(node_modules?) lib, but there is no error on building
this is working => logs 'test 1' and logs 'test 2'
console.log('test before'); import tester from './js/tester'; console.log('test after');
this not => no log 'test1' and no log 'test 2'
console.log('test 1'); import { startStimulusApp } from "@symfony/stimulus-bridge"; console.log('test 2');
from webpack-encore.
That I don't know. I'm not aware of a time when an import would break something in Webpack without showing some sort of error.
from webpack-encore.
this is exactly why I can not fix the problem - no error on build or watch, but a broken script :-(
I am not to ddep into how all the modules are glued together... but might this depend on any babel loader specials?
from webpack-encore.
I don’t know - it’s really bizarre. I’d probably start creating some syntax errors and even tweaking removing code inside that imported module in node_modules just to see if that can help figure out what’s going on.
from webpack-encore.
@langert Could you provide some code so we can try to reproduce the issue? Or at least the content of your webpack.config.js
and the generated files?
Some leads though:
- In the last example of your initial post it seems that you are actually calling the
init()
method, which is not the case forstartStimulusApp()
before. It is theinit()
call that is present between your twoconsole.log()
, not the import, so it makes sense that there is no similar thing forstartStimulusApp()
. - If you enabled
splitEntryChunks()
the code may be splitted into multiple files, did you include all of them into your page? Ideally you'd have to read theentrypoints.json
file to know which ones should be included for each entrypoint.
from webpack-encore.
@Lyrkan yuo made my day! disabled splitEntryChunks() and everything works as expected.
For my understanding: but should finding the right spliited files not be handled by the runtime.js ? I never used webpack encore in a non symfony project without encore_entry_script_tags before, so never payed attention on this.
from webpack-encore.
Nice work @Lyrkan!
The encore_entry_script_tags()
handles figuring out how the files were split and rendering all of the necessary script
tags on the page. The runtime.js
is aware, I believe, of where all of the different code should live, but if you're missing a script tag for one of the split files, it seems that the code just doesn't run.
from webpack-encore.
Related Issues (20)
- how to add plugins HOT 1
- HMR not working with custom domain HOT 1
- How can I transpileDependencies when using webpack encore
- Debugging hanging CSSMinimizerPlugin
- Module build failed: Module not found: "@symfony/stimulus-bundle" HOT 2
- Allow to pass options to babel react preset
- Twig file changes are not working with "watch" or "dev-server" HOT 1
- Getting an error for assets compilation with webpack-encore.
- ReferenceError: __VUE_PROD_DEVTOOLS__ is not defined HOT 2
- Disabling notifications on windows breaks --watch flag HOT 1
- Warning on sass-loader 14 HOT 1
- Svelte loader Module not found
- Two different builds for two versions of Vue.js app HOT 3
- Warning for postcss-loader v8.1.0 to be too new HOT 3
- PrettyError not supported anymore results in an error HOT 3
- Fully support less-loader ^12 HOT 1
- Enhance assets versionning HOT 12
- Support eslint 9 HOT 1
- Disable dev-server reload for PHP files?
- Integrity hashes do not work if contenthash is a query string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-encore.