Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Conversation

@alexander-akait
Copy link
Member

@alexander-akait alexander-akait commented Aug 8, 2017

Notable Changes

  1. Separate cache and parallel options, because they should not be tied up. I can enable cache but disable parallel, also i can enable parallel but disable cache. Seems we were not too careful when we were accepted PR with parallel option.
  2. Fix [v1.0.0-beta.2] parallelization isn't working #97, options parallel doesn't work as expected ([v1.0.0-beta.2] parallelization isn't working #97).
  3. A lot of tests (cache, parallel, ecma-8, ecma-7, ecma-6 ecma-5). Remove unnecessary extra tests from parallel tests.
  4. Refactor some properties and method to easy read.
  5. Simplify: remove src/uglify/cache.js, use cacache directly instead.
  6. Don't use cacheIdentifier (aka metadata) field for invalidate cache because metadata should be used for other purposes (example metadata https://github.com/zkat/cacache#example-2). For invalidate cache we should use cacheKey.
  7. Invalidate cache when uglify-es was updated.
  8. Invalidate cache when uglifyjs-webpack-plugin was updated.
  9. Invalidate cache when options for plugin was changed (we can't use only uglifyOptions because we can change extractComments or warningsFilter options). Maybe we can exclude some options not affecting on cache (test, include, exclude, parallel and sourceMap). Awaiting feedback.

Issues

Fix #100
Fix #97

One strange behavior

I remove [chunkhash] in ecma.test.js because webpack generate difference [chunkhash] for ecma-5 on node 4 and 8, I don't know why :/

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

👍 Only unrelated nits and one question :)

@@ -1,10 +1,9 @@
import os from 'os';
import cacache from 'cacache';
import findCacheDir from 'find-cache-dir';
Copy link
Member

Choose a reason for hiding this comment

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

findCacheDir => cacheDir

Choose a reason for hiding this comment

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

cacheDir sounds like the result of findCacheDir

Copy link
Member Author

Choose a reason for hiding this comment

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

@Kovensky @michael-ciniawsky let's rename, thanks!

Copy link
Member

@michael-ciniawsky michael-ciniawsky Aug 17, 2017

Choose a reason for hiding this comment

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

@Kovensky It is a {Function} which 'contains' the value =>

  1. Directly pass as an argument with 'higher order' => const cache = (data, cacheDir(options)) => cache
  2. Assign it to a scope/block/'namespace' instead of an 'redundant' variable
this.cacheDir = cacheDir(options)  // ok
const cache = { data, dir: cacheDir(options) } // ok

const cacheDir = findCacheDir(options) // unnecessary :D

Anyways just a nitpick 🐦 😛

@@ -1,10 +1,9 @@
import os from 'os';
import cacache from 'cacache';
Copy link
Member

Choose a reason for hiding this comment

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

cacache => cache

Copy link
Member Author

Choose a reason for hiding this comment

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

@michael-ciniawsky i think rename can be misleading, we can use cache variable for other purpose. Also i think it is bad practice, but if someone from the reviewers considers renaming a good practice, say it here and I do it 😄

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest that if it's renamed, we don't go with cache as that's used all over the place in webpack already which may / may not be confusing.

Copy link
Member

Choose a reason for hiding this comment

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

I would stay with cacache as name. name is usual equal to package name.

@@ -1,30 +0,0 @@
import crypto from 'crypto';
Copy link
Member

Choose a reason for hiding this comment

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

Is the caching sufficiently tested elsewhere in the tests ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@michael-ciniawsky be good add more tests, but cache.test.js doesn't test caching (just test get and put function)

Copy link
Member Author

Choose a reason for hiding this comment

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

let's add more tests

@michael-ciniawsky michael-ciniawsky changed the title refactor: respect uglify options and version refactor: respect uglify options and version (options.parallel.cache) Aug 8, 2017
@michael-ciniawsky michael-ciniawsky added this to the 1.0.0 milestone Aug 8, 2017
@alexander-akait alexander-akait force-pushed the refactor-and-improve-cache-key branch from 00d75bb to d2ac477 Compare August 16, 2017 20:33
@alexander-akait alexander-akait changed the title refactor: respect uglify options and version (options.parallel.cache) refactor: cache and parallel options Aug 16, 2017
@alexander-akait alexander-akait force-pushed the refactor-and-improve-cache-key branch 3 times, most recently from e700839 to cc3d49f Compare August 16, 2017 21:01
@alexander-akait
Copy link
Member Author

alexander-akait commented Aug 16, 2017

@michael-ciniawsky @hulkish @bebraw @d3viant0ne friendly ping
Sorry for many changes, but current version don't works as expected 😞
After merge this PR i will do:

  1. Refactor tests (now we got Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. error if something unexpected in tests, but should get pretty output about errors)
  2. Implement include and exclude options.

@michael-ciniawsky
Copy link
Member

Refactor tests (now we got Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. error if something unexpected in tests, but should get pretty output about errors)

This happend for me locally when I didn't build the src before running the tests (shouldn't be needed)

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

options.parallel.cache => options.cache is a breaking change 😞

@alexander-akait
Copy link
Member Author

@michael-ciniawsky we have beta and can change this 😄

@alexander-akait alexander-akait force-pushed the refactor-and-improve-cache-key branch from cc3d49f to e22ee39 Compare August 17, 2017 09:21
@alexander-akait alexander-akait removed the request for review from bebraw August 17, 2017 09:25
@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Aug 17, 2017

Yeah it's not optimal, but the cache as standalone option definitely makes more sense, let's break early as long as we basically 'can' 😛 . I review in depth later today

@joshwiens
Copy link
Member

For reference, we can publish alpha / beta builds directly from this branch. Once everyone is satisfied (enough) with it, we can push a beta for the next semver:Major & get Sean to put it out on blast via Twitter.

That has the side effect of making it easier to test the changes in the major integrations ( @angular/cli & create-react-app )

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Sep 12, 2017

Can we merge this PR and work on a solution for #120 ? Is it possible to rebase the current beta into a develop branch and 'revert' master to v0.4.6 102c18b since v1.0.0 will take a while (webpack v4.0.0 ?)[Particularly talking about npm releases]. Merging into master was a mistake of mine here since v0.4.6 would badly need a fix for the flanky postinstall script and still ships with webpack atm 😞 . With develop (@beta) && master (@latest) development doesn't get blocked by current ecosystem needs and beta dev can happen with less outside pressure + in the end unwanted breaking changes can be (easily) reverted before merging into master

Branch (Github) Tag (npm) SemVer
develop @beta 🏷️ Major
master @latest 🏷️ Minor/Patch
release/vX.X.X @X.X.X 🏷️ Patch (only critical, generic (non use case specific)
release/vX.X.X - 1 @X.X.X - 1 EOL

@michael-ciniawsky michael-ciniawsky changed the title refactor: cache and parallel options refactor: split cache and parallel options Sep 12, 2017
@alexander-akait
Copy link
Member Author

@d3viant0ne @hulkish friendly ping

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

I didn't check the tests, but changes make sense to me

@@ -1,10 +1,9 @@
import os from 'os';
import cacache from 'cacache';
Copy link
Member

Choose a reason for hiding this comment

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

I would stay with cacache as name. name is usual equal to package name.

constructor(options = {}) {
const { cache, parallel } = options;
this.cacheDir = cache === true ? findCacheDir({ name: 'uglifyjs-webpack-plugin' }) : cache;
this.maxConcurrentWorkers = parallel === true ? os.cpus().length - 1 : Math.min(Number(parallel) || 0, os.cpus().length - 1);
Copy link
Member

@sokra sokra Sep 29, 2017

Choose a reason for hiding this comment

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

Is there a reason why only using cpu count - 1? Why not using all CPUs?


I would replace Math.min(Number(parallel) || 0, os.cpus().length - 1) with Number(parallel) || 0. When the user chooses a worker count we should respect it, even if it's more than CPUs.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sokra -1 - one for master other for childs

Copy link
Member

Choose a reason for hiding this comment

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

Yep one core needs to be reserved for the main process running the worker farm

put(this.cache, task.cacheKey, data, cacheIdentifier).then(done, done);

if (this.cacheDir && !result.error) {
cacache.put(this.cacheDir, task.cacheKey, JSON.stringify(data)).then(done, done);
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to move the cache put operation into the worker process?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sokra no sense

@joshwiens
Copy link
Member

@evilebottnawi - This in a place where you are ready for a beta build out to npm?

@alexander-akait
Copy link
Member Author

@d3viant0ne yep

@Genuifx
Copy link

Genuifx commented Oct 10, 2017

why not merge this pr? some of my project in window system doesn't work now. TT

@joshwiens
Copy link
Member

joshwiens commented Oct 10, 2017

@Genuifx - It will merge when we are satisfied with it's stability. In the mean time, there are beta builds available on npm for this branch with the latest being uglifyjs-webpack-plugin@1.0.0-beta.3

@Genuifx
Copy link

Genuifx commented Oct 10, 2017

@d3viant0ne copy that.

@alexander-akait
Copy link
Member Author

@Genuifx feedback welcome 👍

@joshwiens
Copy link
Member

@evilebottnawi - Updated defaults & the npm 5 / Node 4.3 issue. One the snapshots are sorted, i'd like to put out a final beta build & get this finished up this week if possible.

@genintho
Copy link

It will merge when we are satisfied with it's stability

We have been using beta3 at work (Hipmunk) for a few days and have not experienced any issue yet. This represent around 100 build.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants