-
Notifications
You must be signed in to change notification settings - Fork 7
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
Comment "stimulusFetch: 'lazy'" is dropped from Stimulus Controller #10
Comments
I've tried to add a Anyway, if I use the new comment like that: import { redo as commandRedo, undo as commandUndo } from "@codemirror/commands";
import { markdown } from "@codemirror/lang-markdown";
import { Compartment, EditorSelection } from "@codemirror/state";
import { githubDark } from "@fsegurai/codemirror-theme-github-dark";
import { githubLight } from "@fsegurai/codemirror-theme-github-light";
import { Controller } from "@hotwired/stimulus";
import { EditorView, basicSetup } from "codemirror";
import { codeLanguages } from "../codemirror/code_languages.js";
import { lightDarkThemeSwitcher } from "../codemirror/light_dark_theme_switcher.js";
/*! stimulusFetch: 'lazy' */
export default class extends Controller {
static targets = ["textarea"];
static classes = ["editor"]; Then I see the comment being at the very top of the file: And the lazy-loading behavior still not works. |
…bundle#10 is fixed This reverts commit 1f2dfd6.
Is it happening both for asset-map:compile and Minify:asset command or just the later? |
Okay dug a little bit deeper and minify will only keep a comment if
So we could make this work by putting |
Just thought of something simpler 😅 StimulusBundle’s Always checking against the source file content would solve this issue: - $content = $asset->content ?: file_get_contents($asset->sourcePath);
+ $content = file_get_contents($asset->sourcePath); I feel like it would make sense 🤔 |
Are you sure this does not work with AssetMapper ? When i tested it i’m pretty sure it did, but i may had another implémentation at that point |
(i’m 100km from my computer right now ^^) |
Yes I successfully reproduced what @Kocal reported: given the following controller: import { Controller } from '@hotwired/stimulus';
/* stimulusFetch: 'lazy' */
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
}
} The import{Controller}from"@hotwired/stimulus";export default class extends Controller{connect(){this.element.textContent="Hello Stimulus! Edit me in assets/controllers/hello_controller.js"}} It doesn’t find the comment and thus considers the controller to be loaded eagerly. symfony/ux#2304 should fix this issue 🤞 |
symfony/ux#2304 will be released in the incoming weeks, so not sure if we can do something in the meantime here :| |
Sure, let's wait |
symfony/stimulus-bundle 2.2.22 has been released, with the fix from @MatTheCat To me everything works as expected (had a weird cache first but not sure if related) Could you guys check on your side? |
I will check :) |
... weeeell, after a whole day of VM/server issues (just after deploying the commit to use this bundle on my website.... 🧐 (just a coincidence don't worry 😛 )). IDK if I did something wrong, but:
I believe this is an issue from AssetMapper and automatic usages of But if you take a look to controllers code, it is compressed as expected: |
Tried StimulusBundle 2.22 on a small project and it behaves as expected: controller is loaded when not being lazy or being used on the page. @Kocal // controllers.js
import controller_0 from'../ux-turbo/turbo_controller.js';
import controller_1 from'../../controllers/places_controller.js';
import controller_2 from'../../controllers/markdown_editor_controller.js';
export const eagerControllers = {
'symfony--ux-turbo--turbo-core': controller_0,
places: controller_1,
'markdown-editor': controller_2
};
export const lazyControllers = {
'symfony--ux-leaflet-map--map': () => import ('../ux-leaflet-map/map_controller.js')
};
export const isApplicationDebug = !1 |
I'm stupid 🤦🏻 When upgrading Symfony UX packages, I ran Updated StimulusBundle to 2.22, it's working now! |
Hey :)
Given my Stimulus controller:
After being minified, the comment
/* stimulusFetch: 'lazy' */
disappear from the source code:Which load the controller (even if not needed since there are no
data-controller="markdown-editor"
on the page) and load all the dependencies (a lot):The text was updated successfully, but these errors were encountered: