Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: avoid reloading all csses when hot load#1090

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
alexander-akait merged 3 commits intowebpack-contrib:masterfromyiminghe:optimize-locals
Apr 16, 2024
Merged

fix: avoid reloading all csses when hot load#1090

alexander-akait merged 3 commits intowebpack-contrib:masterfromyiminghe:optimize-locals
Apr 16, 2024

Conversation

yiminghe
Copy link
Contributor

@yimingheyiminghe commentedMar 20, 2024
edited by alexander-akait
Loading

This PR contains a:

  • bugfix
  • newfeature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

  • only refresh page when locals change, otherwise accept and hot load
  • avoid reloading all csses

Breaking Changes

Additional Info

Fixes#692

@linux-foundation-easyclaLinux Foundation: EasyCLA
Copy link

linux-foundation-easyclabot commentedMar 20, 2024
edited
Loading

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: yiminghe / name: yiminghe (9bfc65e)
  • ✅ login: alexander-akait / name: Alexander Akait (ace213e,fc80832)

? ""
: "module.hot.accept(undefined, cssReload);";
Copy link
Member

@alexander-akaitalexander-akaitMar 20, 2024
edited
Loading

Choose a reason for hiding this comment

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

Why you change it?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

self accept is enough, it will update when dispose:https://webpack.js.org/api/hot-module-replacement/

alexander-akait reacted with thumbs up emoji
Copy link
Member

@alexander-akaitalexander-akait left a comment

Choose a reason for hiding this comment

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

We need a test case, please add

@yimingheyiminghe changed the titlefix: avoid reload all css when hot loadfix: avoid reloading all csses when hot loadMar 20, 2024
@yiminghe
Copy link
ContributorAuthor

We need a test case, please add

test cases updated

src/loader.js Outdated
// ${Date.now()}
var cssReload = require(${stringifyRequest(
const cssReload = require(${stringifyRequest(

Choose a reason for hiding this comment

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

Don't use const, it will be in the browser and break old browsers

yiminghe reacted with thumbs up emoji
? ""
: "module.hot.accept(undefined, cssReload);";

const localsJsonString = JSON.stringify(JSON.stringify(context.locals));

Choose a reason for hiding this comment

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

Why doubleJSON.stringify? Just typo?

Copy link
ContributorAuthor

@yimingheyimingheMar 28, 2024
edited
Loading

Choose a reason for hiding this comment

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

note the interpolation:

`const localsJsonString =${localsJsonString};`

string comparation is faster

@codecovCodecov
Copy link

codecovbot commentedMar 27, 2024
edited
Loading

Codecov Report

Attention: Patch coverage is50.00000% with1 lines in your changes are missing coverage. Please review.

Project coverage is 92.00%. Comparing base(c7ff30d) to head(9bfc65e).
Report is 7 commits behind head on master.

❗ Current head9bfc65e differs from pull request most recent headfc80832. Consider uploading reports for the commitfc80832 to get more accurate results

FilesPatch %Lines
src/loader.js50.00%1 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##           master    #1090      +/-   ##==========================================+ Coverage   90.61%   92.00%   +1.38%==========================================  Files           5        5                Lines         895      900       +5       Branches      255      258       +3     ==========================================+ Hits          811      828      +17+ Misses         74       67       -7+ Partials       10        5       -5

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

module.hot.dispose(function(data) {
data.value = localsJsonString;
cssReload();
});

Choose a reason for hiding this comment

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

We have a special test directory for HMR, will be great to add a test case there, I know your code works fine, but we should ensure about it

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

what do you mean? I have added cases inside cases folder (hmr, hmr-locals)

Choose a reason for hiding this comment

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Member

@alexander-akaitalexander-akait left a comment

Choose a reason for hiding this comment

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

Let's do small improvements and I am fine with it

@alexander-akait
Copy link
Member

For fixing tests for OLD API just useOLD_API=1 npm run test:only

@alexander-akait
Copy link
Member

Thank you for your PR

@yiminghe
Copy link
ContributorAuthor

For fixing tests for OLD API just useOLD_API=1 npm run test:only

passed

@alexander-akait
Copy link
Member

alexander-akait commentedApr 8, 2024
edited
Loading

@yiminghe We have:

var cssReload = require("/home/runner/work/mini-css-extract-plugin/mini-css-extract-plugin/src/hmr/hotModuleReplacement.js")(module.id, undefined);

As you can see it is an absolute path, let's use it from herehttps://github.com/webpack-contrib/css-loader/blob/master/src/utils.js#L15 (maybe we already have the same util here)

@yiminghe
Copy link
ContributorAuthor

@yiminghe We have:

var cssReload = require("/home/runner/work/mini-css-extract-plugin/mini-css-extract-plugin/src/hmr/hotModuleReplacement.js")(module.id, undefined);

As you can see it is an absolute path, let's use it from herehttps://github.com/webpack-contrib/css-loader/blob/master/src/utils.js#L15 (maybe we already have the same util here)

updated

alexander-akait
alexander-akait previously approved these changesApr 9, 2024
@alexander-akaitalexander-akait merged commit1a56673 intowebpack-contrib:masterApr 16, 2024
@yimingheyiminghe deleted the optimize-locals branchApril 17, 2024 03:21
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@alexander-akaitalexander-akaitalexander-akait left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@yiminghe@alexander-akait

[8]ページ先頭

©2009-2025 Movatter.jp