-
-
Notifications
You must be signed in to change notification settings - Fork 16
Replacing virtual-modules with a loader for controller.json #14
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
Conversation
e6760a8
to
f62a939
Compare
I've just tested this in a real project along with its sister PR in Encore. It works great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR, thanks Ryan!
src/index.js
Outdated
// this import is be replaced by the NormalModuleReplacementPlugin | ||
// to point to the real controllers.json file | ||
// See create-controllers-module.js | ||
import symfonyControllers from './webpack/loader!../controllers-placeholder.json'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the loader necessary here? If the NormalModuleReplacementPlugin pass before modules, we could have a nicer syntax here, like @symfony/controllers
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per your recommendation, NormalModuleReplacementPlugin
is gone in favor of an alias :).
So, the loader IS needed here and I think it's helpful: it helps clarify (for a curious reader) that we are not parsing this as JSON, but doing something trickier.
aa18456
to
04fa4be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works really well with aliases, that's nice!
5f6a96b
to
fb5aaf7
Compare
Thanks @weaverryan. |
This PR was merged into the main branch. Discussion ---------- removing old files for the plugin These are extra files I missed in #14 After these are deleted, the error in I added to the readme in #17 will occur if you use the updated version of this lib with an outdated Encore version. Thanks! Commits ------- 017ff71 removing old files for the plugin
…w loader (weaverryan) This PR was squashed before being merged into the main branch. Discussion ---------- updating stimulus-bridge plugin to work with proposed new loader Partner to symfony/stimulus-bridge#14 * [x] Wait for partner PR to be merged Commits ------- 5640760 updating stimulus-bridge plugin to work with proposed new loader
Hi!
The motivation behind this was a few things:
watch
mode and should work just fine with Webpack 5 persistent build caching.This also includes a tricky NormalModuleReplacementPlugin() so that we can continue to handling the parsing of the user's controller.json inside this library (instead of putting the import + loader code in their app).
This will require a partner PR in webpack-encore (symfony/webpack-encore#888). The only line users will need to change in their app is to remove
import '@symfony/autoimport';
from theirassets/bootstrap.js
file.Cheers!