Conflicting Files NPM Resource Changed ? Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
11 Dec 2020

Pull Request for Issue # .

Summary of Changes

  • Remove the current script for gzipping .min.css && .min.js files
  • Remove the zopfli dependency

side effect

  • Place fontawesome in the dependencies (not in the dev dependencies)
  • Remove path dependency (path is a core module)

Testing Instructions

Git clone the Repo to a temp folder somewhere in your HDD
run composer install
Run npm install (set a stopwatch to benchmark the process)
Then run npm run gzip

Git clone the Repo to another temp folder somewhere in your HDD
Checkout this PR
Run composer install
Run npm install
Then run npm run gzip (set a stopwatch to benchmark the process)

Compare the 2 benchmarks
Compare the 2 folders

Actual result BEFORE applying this Pull Request

Gzipping the assets is a very long task

Expected result AFTER applying this Pull Request

Gzipping the assets is snappy

Documentation Changes Required

@wilsonge @HLeithner I know this might seems like I selflessly plugin my code here but there are couple benefits here:

  • dropping dependencies
  • The code has 0 dependencies
  • The code supports Brotli (just add -b at the end of each command)
  • You can still fork the code if you need to modify it
  • Feel free to close this if it breaks any rules about code ownership, etc
avatar dgrammatiko dgrammatiko - open - 11 Dec 2020
avatar dgrammatiko dgrammatiko - change - 11 Dec 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Dec 2020
Category JavaScript Repository NPM Change
avatar HLeithner
HLeithner - comment - 11 Dec 2020

If I understand you package right it simply uses zlib, so we could simply add the lines adding the compression to our build.js? I mean at the moment your script get loaded 3 times from github (maybe cached) but looks like a waste of resources.

Or I'm wrong?

avatar dgrammatiko
dgrammatiko - comment - 11 Dec 2020

your script get loaded 3 times from github (maybe cached) but looks like a waste of resources.

You could combine the 3 commands to 1. Also since this is done with npx there is no real dependency added (mind that the command is only executed by the release leader, it's a one off execution just before the release of a package)
But yes you could fork the code in the project if you like. (having it as a node package is better imo as 3rd PD can use it as well for their own packages ? )

avatar wilsonge
wilsonge - comment - 11 Dec 2020

I’m down - although is there a reason not to have you package as a dev dependency? Just so it’s version locked with everything else

avatar dgrammatiko
dgrammatiko - comment - 11 Dec 2020

although is there a reason not to have you package as a dev dependency

The idea is to reduce the dependencies that need to be installed (both for CI and local development). Maybe another approach is to create a repo for the npm tools and fork the code there and also transfer the rest of the build tools there as well (yeah I know breaking things to different repos makes it more difficult to maintain but then again those tools should be available to all the 3rd PD, right now this is true only through the 4.0-dev repo). Hard for me to justify what fits better the project but I guess having one line npm commands for any dev should be handy

avatar brianteeman
brianteeman - comment - 17 Dec 2020

Unable to test as the command npm run gzip does nothing on my install

avatar dgrammatiko
dgrammatiko - comment - 17 Dec 2020

@brianteeman interesting, this was already tested on windows, can you try runningcd media and then npx --no-install github:dgrammatiko/compress ? do you get any message? Were any .gz files created?

avatar brianteeman
brianteeman - comment - 17 Dec 2020
`C:\htdocs\joomla-cms>npm run gzip 

> joomla@4.0.0 gzip C:\htdocs\joomla-cms
> node -e 'require("./build/build-modules-js/gzip-assets.es6.js").gzipFiles()'

npx --no-install github:dgrammatiko/compress` works perfectly

`

avatar dgrammatiko
dgrammatiko - comment - 17 Dec 2020

I see, somehow you're executing the old command > node -e 'require("./build/build-modules-js/gzip-assets.es6.js").gzipFiles()', this was before the changes in this PR. I guess it has to do with the conflict?

avatar dgrammatiko dgrammatiko - change - 17 Dec 2020
Labels Added: NPM Resource Changed ?
avatar brianteeman
brianteeman - comment - 17 Dec 2020

Yes I am trying to do the first part of the test instructions before applying the pr

Sorry that wasn't clear

avatar dgrammatiko
dgrammatiko - comment - 17 Dec 2020

Yes I am trying to do the first part of the test instructions before applying the pr

Maybe my instructions are bad, you need to clone and check out the 4.0-dev repo for the first step

avatar brianteeman
brianteeman - comment - 17 Dec 2020

thats what I am using - the clone that I do all my dev on

avatar brianteeman
brianteeman - comment - 17 Dec 2020

Just to confirm I did a completely new clone and the output of npm run gzip is exactly the same as before

avatar dgrammatiko
dgrammatiko - comment - 17 Dec 2020

node -e 'require("./build/build-modules-js/gzip-assets.es6.js").gzipFiles()

This probably won't run on windows, can you change ./build/build-modules-js/gzip-assets.es6.js to C:\htdocs\joomla-cms\build\build-modules-js\gzip-assets.es6.js

avatar brianteeman
brianteeman - comment - 17 Dec 2020

I could if I could find the file to change :(

avatar dgrammatiko
dgrammatiko - comment - 17 Dec 2020

It's the package.json but you should be able to run the command directly in the terminal:
node -e 'require("C:\htdocs\joomla-cms\build\build-modules-js\gzip-assets.es6.js").gzipFiles()'

avatar brianteeman
brianteeman - comment - 17 Dec 2020

I had already tried that but just double double checked
no change

Maybe its me, maybe its windows. Perhaps another windows user can confirm

avatar brianteeman
brianteeman - comment - 17 Dec 2020

found the bug
changing the code in package.json from
"gzip": "node -e 'require(\"./build/build-modules-js/gzip-assets.es6.js\").gzipFiles()'",

to

"gzip": "node -e require('./build/build-modules-js/gzip-assets.es6.js').gzipFiles()",

note the change from "\ to ' and the removal of the ' around require

avatar dgrammatiko dgrammatiko - change - 3 Jan 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-01-03 10:37:18
Closed_By dgrammatiko
Labels Added: Conflicting Files
avatar dgrammatiko dgrammatiko - close - 3 Jan 2021

Add a Comment

Login with GitHub to post a comment