WPTT / theme-sniffer

Theme Sniffer plugin using sniffs.
MIT License
270 stars 3 forks source link

Using ES6 for development? #73

Closed dingo-d closed 6 years ago

dingo-d commented 6 years ago

Could we use ES6 when developing the plugin? We could use babel for transpiling, and webpack to bundle assets when serving the production version, and when working on development.

I think that we could refactor some JS code that is a bit messy atm.

grappler commented 6 years ago

I don't mind what we use. It just needs to work for the users.

Though by using ES6 we are raising the barrier for entry.

dingo-d commented 6 years ago

Well since webpack is now used in the wp-core (https://core.trac.wordpress.org/ticket/40894) it wouldn't be a bad idea to start using it. Plus I'd be glad to write a documentation on how it's used.

Not to mention that once it is set up, any future developer wouldn't need to modify the actual webpack.config.js (maybe minor modifications based on the updates) and the benefit is that we would be teaching people how to use modern JavaScript :)

carolinan commented 6 years ago

I think this also depends if we want to see the sniffer used on wordpress.org?

The current code will not work on .org. Will this?

Or do we want to maintain two different versions?

Also will either pass plugin review guidelines? We still want to add it to the plugin directory, correct?

dingo-d commented 6 years ago

Once you build it (in the case of the PR I submitted with npm run build) it will work just fine.

My plan is, after the PR is merged, to rewrite the plugin in OOP with namespaces and using autoloader for class autoloading. Also, I can create a gulp task to bundle the working plugin from the development like I did in this case https://github.com/infinum/json-wp-post-parser/, where the src gets bundled to the build folder with the plugin folder that can be copied to wp-content and it will work.

The development of the plugin can be done on github, and then the finished and bundled plugin can be put on wp.org. Not only that, but we can automate this process probably to sync the plugin here on github to that on wp.org each time we release new version.

We just need to see what the guidelines are regarding script bundling for plugins with the plugin team.