Skip to content

Conversation

@jbalsas
Copy link
Contributor

@jbalsas jbalsas commented Dec 22, 2020

Hey @bryceosterhaus, @wincent, my gulp fu is pretty rusty (or my fu in general), but I think this should do it as far as minifying JS in themes goes.

In production mode, terser will be invoked to minify js resources in a theme after every other processing has taken place.

Terser options can be overriden by declaring a terser object in the package.json file of your theme. By default, it is invoked with defaults configuration.

Sourcemaps are enabled by default and handled outside of terser if the minification takes place.

Everytime I get back to this I get an intense urge of rewriting the whole thing, but instead, I end up adding yet another thing. One day, though...

promise

In production mode, `terser` will be invoked to minify `js` resources in
a theme after every other processing has taken place.

Terser options can be overriden by declaring a `terser` object in the
`package.json` file of your theme. By default, it is invoked with defaults
configuration.

Sourcemaps are enabled by default and handled outside of terser if the
minification takes place.
@jbalsas
Copy link
Contributor Author

jbalsas commented Dec 22, 2020

Oh, this fixes #364

@jbalsas
Copy link
Contributor Author

jbalsas commented Dec 22, 2020

@izaera, wouldn't mind you looking at this and merging/releasing if looks good. Otherwise, I'll get my hands dirty with the whole process 😉

source-map "~0.7.2"
source-map-support "~0.5.19"

[email protected]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me super sad... the fact that gulp-terser requires [email protected] and yet we apparently use 4.8.0 befuddles me 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

html-webpack-plugin (last published 10 days ago 🎉) and more directly html-minifier-terser (last published 7 months ago 😢) are the main culprits:

yarn why terser                                                                                                                                             0.29s [wincent/fix-ci] ~/code/liferay-frontend-projects
yarn why v1.22.5
[1/4] 🤔  Why do we have the module "terser"...?
[2/4] 🚚  Initialising dependency graph...
warning Missing version in workspace at "/Users/greghurrell/code/liferay-frontend-projects/projects/js-themes-toolkit", ignoring.
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "terser"
info Reasons this module exists
   - "workspace-aggregator-2b18f523-66b8-4ae1-9a79-f299cab4ade8" depends on it
   - Hoisted from "_project_#@liferay#npm-scripts#terser"
   - Hoisted from "_project_#terser-webpack-plugin#terser"
info Disk size without dependencies: "2.95MB"
info Disk size with unique dependencies: "3.94MB"
info Disk size with transitive dependencies: "3.95MB"
info Number of shared dependencies: 4
=> Found "gulp-terser#[email protected]"
info This module exists because "_project_#liferay-theme-tasks#gulp-terser" depends on it.
info Disk size without dependencies: "2.61MB"
info Disk size with unique dependencies: "3.6MB"
info Disk size with transitive dependencies: "3.61MB"
info Number of shared dependencies: 4
=> Found "html-minifier-terser#[email protected]"
info This module exists because "_project_#@liferay#npm-scripts#html-webpack-plugin#html-minifier-terser" depends on it.
info Disk size without dependencies: "1.86MB"
info Disk size with unique dependencies: "2.85MB"
info Disk size with transitive dependencies: "2.87MB"
info Number of shared dependencies: 4
✨  Done in 0.96s.

And people wonder why I am so grumpy about dependencies...

'build:fix-at-directives',
'build:r2',
'build:copy:fontAwesome',
'build:minify:js',
Copy link
Contributor Author

@jbalsas jbalsas Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait until the very end and then minify all the things. Keep in mind that we don't have a babel step ourselves, but people could configure it on their own, so chances are we're going to break things if that's the case (at least for sourcemaps).

Copy link
Member

@bryceosterhaus bryceosterhaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me, although this is also my first time ever looking at the js-themes-toolkit codebase... So don't put too much confidence in my thoughts here

@jbalsas jbalsas changed the title feat(js-themes-toolkit): adds js minification step feat(js-themes-toolkit): adds js minification step (Fixes #364) Dec 23, 2020
@jbalsas
Copy link
Contributor Author

jbalsas commented Dec 23, 2020

Thanks @bryceosterhaus!

@izaera, this looks good to you? We're merging with merge commits here, aren't we? Not entirely sure about the process... it's been a while 😂

@izaera
Copy link
Member

izaera commented Dec 23, 2020

Everytime I get back to this I get an intense urge of rewriting the whole thing, but instead, I end up adding yet another thing. One day, though...

Happens to all of us 🙄

@izaera
Copy link
Member

izaera commented Dec 23, 2020

@jbalsas This LGTM. Regarding merge, we use merge commit (not rebase), yes 👍 .

@izaera
Copy link
Member

izaera commented Dec 23, 2020

I'll merge now and release in a while.

@izaera izaera merged commit 77397f7 into liferay:master Dec 23, 2020
@izaera
Copy link
Member

izaera commented Dec 23, 2020

@wincent
Copy link
Contributor

wincent commented Dec 28, 2020

Everytime I get back to this I get an intense urge of rewriting the whole thing, but instead, I end up adding yet another thing. One day, though...

When you do this, plz rewrite without gulp. kthxbye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants