What’s the best way to work on core js files?

I needed to work on the core select.js file to try to find and fix a small bug I found. To make debugging easier I wanted to work on select.js in one of my projects BUT since filament’s js is compiled, I had a hard time figuring out the correct way to work on it. I ended up making the change on my fork of filament, npm run build, and then COPIED the app.js file from Filament into my project to test the change! Over and over again 🤦‍♂️ Barbaric!! It worked, but there has to be a better way. What is it?
10 Replies
awcodes
awcodes15mo ago
The best way is to get it in core. Obviously not as easy as it sounds. Since it affects other things. But overriding JS is not an easy thing to do regardless of the framework. Especially if it’s a third party vendor. The hardest thing I’ve ever had to do is allow people to provided their own plugins to Tiptap editor plugin. So plugins for a plugin. It’s doable right now but it’s not documented because it’s difficult and I’m not happy with the api.
Kenneth Sese
Kenneth Sese15mo ago
So what I did by working in core, rebuilding and copying into my project to test is a viable method??? It feels so wrong.
awcodes
awcodes15mo ago
No, not wrong. Core depends on its execution of the api provided by the third party. If the core use of that api changes then that’s fine. As long as it’s beneficial to the use of core via that 3rd party api.
Kenneth Sese
Kenneth Sese15mo ago
Haha…I think we’re having another communication issue like we were just talking about and I think I know why. When I say select.js I am referring to Filament’s own select.js component file. The one I’m fixing in my most recent PR: https://github.com/filamentphp/filament/pull/6431 I’m not referring to the third party select.js. Hopefully that new context makes my original question more clear
GitHub
Fix options not resetting after backspacing by archilex · Pull Requ...
This PR mostly fixes resetting the select field options when backspacing. Currently, when you search in a select field and then backspace to clear the search term, it will NOT reset to show all the...
awcodes
awcodes15mo ago
All good. Just an outcome of dependence. Same with file pond. Core can only tie into what is provided by the vendor.
Kenneth Sese
Kenneth Sese15mo ago
Hmmmm. So let’s say you/Dan/Zep need to update the alpine code for Filament’s textarea form field. The js for that component, textarea.js, was written by the core Filament team. So as you are working on updating textarea.js, you do what I am doing and copy the compiled app.js file into a demo project to make sure the change works properly?
Dan Harrin
Dan Harrin15mo ago
no, we have a local composer repository set up in composer.json when we make changes to the local repository, we dont need to manually copy anything into the /vendor as its just a symlink
Kenneth Sese
Kenneth Sese15mo ago
I knew there had to be a better way! Thanks!
Dennis Koch
Dennis Koch15mo ago
It worked, but there has to be a better way. What is it?
Symlinking your local version of Filament into the project via Composer as shown in the readme
Kenneth Sese
Kenneth Sese15mo ago
Thanks!