You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment the dependencies of Skosmos are defined in Twig. The scripts are defined in a order that is important and may change how the code works.
We could move this to package.json file, which would enable tools like dependabot to scan our JS dependencies and alert about vulnerabilities (related to #1122).
This can also be used to invoke SASS/SCSS, allowing to improve our stylesheets too, and then producing a single bundle JS (related to #1045).
Furthermore, we could improve browser support via polyfills if necessary, or allow modern JS and transpile it down to ES5/ES6 with something like Babel + webpack.
This could allow us to also write tests with mocha/chai or jest, increasing the overall quality of the code and preventing regressions due to changes in JS.
And, finally, I think this helps to separate the PHP and JS code, which could be helpful if in the future we need/want to move to a framework like Angular/React/Vue/etc.
Implementation
I don't remember seeing a PHP project with the package.json to use as reference 😥 but I've seen Composer scripts for things like generating auth keys, re-creating cache, etc.
So I guess we could hook up one of the composer lifecycles (pre-package? post-package-install?) and call npm build. Then, in the package.json, the build script would run something like webpack ... that would bundle all the JS files (in the order necessary, maybe even doing some tree-shaking to reduce the final JS code size).
This would produce a file index.js (or skosmos.js, or any name we'd like) that would be the single import in scripts.twig. It could also generate the skosmos.css file, combining all the stylesheets (including bootstrap.min.css, again, in the right order, minified).
The text was updated successfully, but these errors were encountered:
At the moment the dependencies of Skosmos are defined in Twig. The scripts are defined in a order that is important and may change how the code works.
We could move this to
package.json
file, which would enable tools likedependabot
to scan our JS dependencies and alert about vulnerabilities (related to #1122).This can also be used to invoke SASS/SCSS, allowing to improve our stylesheets too, and then producing a single bundle JS (related to #1045).
Furthermore, we could improve browser support via polyfills if necessary, or allow modern JS and transpile it down to ES5/ES6 with something like Babel + webpack.
This could allow us to also write tests with mocha/chai or jest, increasing the overall quality of the code and preventing regressions due to changes in JS.
And, finally, I think this helps to separate the PHP and JS code, which could be helpful if in the future we need/want to move to a framework like Angular/React/Vue/etc.
Implementation
I don't remember seeing a PHP project with the
package.json
to use as reference 😥 but I've seen Composer scripts for things like generating auth keys, re-creating cache, etc.So I guess we could hook up one of the composer lifecycles (pre-package? post-package-install?) and call
npm build
. Then, in thepackage.json
, thebuild
script would run something likewebpack ...
that would bundle all the JS files (in the order necessary, maybe even doing some tree-shaking to reduce the final JS code size).This would produce a file
index.js
(orskosmos.js
, or any name we'd like) that would be the single import inscripts.twig
. It could also generate theskosmos.css
file, combining all the stylesheets (includingbootstrap.min.css
, again, in the right order, minified).The text was updated successfully, but these errors were encountered: