Skip to content
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

Proper Custom Code Injection #428

Merged
merged 3 commits into from
Mar 21, 2022
Merged

Proper Custom Code Injection #428

merged 3 commits into from
Mar 21, 2022

Conversation

TurtIeSocks
Copy link
Collaborator

@TurtIeSocks TurtIeSocks commented Mar 19, 2022

== This PR adds a feature that will never be officially supported ==

  • Don't like my implementation?
  • Too lazy to write a configurable PR?
  • Want to maintain custom files while keeping it git friendly?

This PR enables you to replace every single file in the root src folder with your own implementation!

For example, if you want to customize the Pokestop marker:

  1. Copy src/components/markers/pokestop.jsx
  2. Name new file to src/components/markers/pokestop.custom.jsx
  3. Make your changes
  4. Recompile
  5. Celebrate that you're no longer limited to my opinions and praise how generous I am

F.A.Q.
Q. But Turtle, why would I want to write a custom component instead of relying on the config?

  • The config is massive and overwhelming at this point. Most of the options only cater to a small handful of people.
  • We all have opinions, just write your own code, please leave me alone.
  • Performance. All of these unnecessary calculations for things like icon placement starts to impact performance when multiplying it by thousands.

Q. What do you mean this will never be officially supported?

  • If you are writing custom files, it is imperative that you keep an eye on PRs to make sure that they don't break your custom implementations.
  • I will not provide help with your custom implementations.

Q. How can you rudely break my custom component if it's git friendly?

  • Custom components still rely on the props being passed through, using the example above:
export default function pokestopMarker(pokestop, hasQuest, hasLure, hasInvasion, filters, Icons, userSettings)
  • You are still reliant on me passing all of these properties to the Pokestop marker, even in your custom implementation. If the inputs change, you must adjust your custom components.
  • I will do my best to inform people of changes that can affect custom components

Q. What files can I edit?

  • Any .css, .js, or .jsx file in the root src folder. This PR does not apply to files in the server or public folders.

Q. How does this inject custom code while maintaining git friendly-ness??

  • All files with the .custom.[js,jsx,css] ending are git ignored. The compiler checks if a custom file exists during the loading process, if it does, it replaces the contents of the standard file with the custom. Maintaining the original in the file structure while loading your custom file into the end bundle. Magic.

In Closing:

  • With the addition of this functionality, I may start to trim back the config. This is the number 1 way that we can start to claw back some performance gains that we've sacrificed due to the obscene config.
  • Don't think of it as losing config options. Think of it as you just gained a config for every single aspect of the map.

Enables completely custom file implementations that are git friendly
@versx
Copy link

versx commented Mar 19, 2022

We all have opinions, just write your own code, please leave me alone.
💯 😂

@lenisko
Copy link
Contributor

lenisko commented Mar 19, 2022

Perfect! 💯

- Add a check pre-compiling whether custom files exist, skip the plugin if they don't
- Add client var to indicate whether custom files were used
- Inject supported locales from file structure
@TurtIeSocks TurtIeSocks merged commit 020d231 into develop Mar 21, 2022
@TurtIeSocks TurtIeSocks deleted the custom-injection branch March 21, 2022 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants