Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add one-letter-css plugin #1181

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

denisx
Copy link

@denisx denisx commented Aug 25, 2020

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

resolve issue #1028

For efficient gzip/br compression, plugin combine css hash via one symbol name,
as a classname position at file, with filepath hash:base64:8, to have strong sequences.

@codecov
Copy link

codecov bot commented Aug 25, 2020

Codecov Report

Base: 96.81% // Head: 98.83% // Increases project coverage by +2.01% 🎉

Coverage data is based on head (1f513e9) compared to base (7c5cdcc).
Patch coverage: 97.16% of modified lines in pull request are covered.

❗ Current head 1f513e9 differs from pull request most recent head b06b840. Consider uploading reports for the commit b06b840 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1181      +/-   ##
==========================================
+ Coverage   96.81%   98.83%   +2.01%     
==========================================
  Files          12       12              
  Lines        1131      773     -358     
  Branches      411      236     -175     
==========================================
- Hits         1095      764     -331     
+ Misses         27        9      -18     
+ Partials        9        0       -9     
Impacted Files Coverage Δ
src/plugins/hash-len-suggest.js 90.00% <90.00%> (ø)
src/plugins/one-letter-css.js 100.00% <100.00%> (ø)
src/cjs.js 100.00% <0.00%> (ø)
src/index.js 100.00% <0.00%> (ø)
src/Warning.js 100.00% <0.00%> (ø)
src/runtime/api.js 100.00% <0.00%> (ø)
src/CssSyntaxError.js 100.00% <0.00%> (ø)
src/runtime/getUrl.js 100.00% <0.00%> (ø)
src/plugins/postcss-icss-parser.js 100.00% <0.00%> (ø)
src/plugins/postcss-import-parser.js 100.00% <0.00%> (ø)
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.


console.log();
console.log('Suggest Minify Plugin');
console.log('Matched length (len: number):', matchLen);
Copy link
Member

Choose a reason for hiding this comment

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

We have logger for webpack, avoid using console.log https://webpack.js.org/api/logging/

Copy link
Author

Choose a reason for hiding this comment

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

fix

});

return matchLen;
}
Copy link
Member

Choose a reason for hiding this comment

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

We should use weak cache here, otherwise is was memory leak in watch mode

Copy link
Author

Choose a reason for hiding this comment

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

need help with it

Copy link
Author

Choose a reason for hiding this comment

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

@alexander-akait help plz

}
}

module.exports = HashLenSuggest;
Copy link
Member

Choose a reason for hiding this comment

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

I think we can avoid using plugin, we have the identifier of module, so we can generate names based on this

Copy link
Author

Choose a reason for hiding this comment

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

we use file path to make long cash. and make shortest hash as we can (but need check for collisions)

this.a = 'a'.charCodeAt(0);
this.A = 'A'.charCodeAt(0);
// file hashes cache
this.files = {};
Copy link
Member

Choose a reason for hiding this comment

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

Here potential memory leak in watch mode, if will have a lot of renamed files, the object will grow

Copy link
Author

Choose a reason for hiding this comment

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

fixed at last call - getStat()

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Maybe we can do it using pattern like localIdentName: [single-letter]` and keep login there, it will allow more flexibility

# Conflicts:
#	src/plugins/index.js
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 6, 2021

CLA Not Signed

@MrHBS
Copy link

MrHBS commented Aug 31, 2023

Is this dead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants