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

Fix: ES5 client #2658

Merged
merged 6 commits into from
Aug 26, 2020
Merged

Fix: ES5 client #2658

merged 6 commits into from
Aug 26, 2020

Conversation

knagaitsev
Copy link
Collaborator

@knagaitsev knagaitsev commented Jun 23, 2020

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Yes

Motivation / Use-Case

We need to make the client work with ES5 for webpack@4. This PR does some case-specific patches, rather than trying to fully solve the problem, since webpack@5 always has ES6 syntax in its bundles, unless the user uses babel-loader.

The webpack/lib/logging/runtime and strip-ansi modules use ES6, so they are placed in the transpiled-modules directory and have files that act as a proxy entry to them. Then, these entry files are turned into a bundle with babel-loader, so that the result is a module that works with ES5 and behaves the same way.

Explanation for the ES5 check test: Since webpack takes all the JavaScript and puts it into a string in an eval function, a bundle that will not work with ES5 can still pass a basic ES5 check, since all this bad ES6 syntax is inside of a string. The best course of action for a test I think is to locate these strings in a bundle that eval is being run on, then check that they parse with ES5.

#1286 Actually was not fixed on v4 for the reason above, but should be fixed by this PR.

If you look at the test run below only after the first 2 commits, you can see that the test does not pass because there are still modules being used that don't work with ES5: https://github.com/webpack/webpack-dev-server/pull/2658/files/d01ac6855c0bc20f23054c9ca8832eea2539588d

Breaking Changes

None, client API is the same

Additional Info

@knagaitsev knagaitsev changed the base branch from master to v4 June 23, 2020 23:12
@codecov
Copy link

codecov bot commented Jun 23, 2020

Codecov Report

Merging #2658 into v4 will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v4    #2658      +/-   ##
==========================================
+ Coverage   92.85%   92.86%   +0.01%     
==========================================
  Files          37       39       +2     
  Lines        1301     1304       +3     
  Branches      348      349       +1     
==========================================
+ Hits         1208     1211       +3     
  Misses         89       89              
  Partials        4        4              
Impacted Files Coverage Δ
client-src/default/index.js 92.47% <100.00%> (ø)
client-src/default/utils/log.js 100.00% <100.00%> (ø)
client-src/transpiled-modules/log.js 100.00% <100.00%> (ø)
client-src/transpiled-modules/strip-ansi.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab7f6dd...f33be55. Read the comment docs.

@knagaitsev knagaitsev changed the title [WIP] Fix: ES5 client Fix: ES5 client Jun 24, 2020
@knagaitsev
Copy link
Collaborator Author

Looks like test instability again on Windows.

Copy link
Member

@hiroppy hiroppy left a comment

Choose a reason for hiding this comment

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

still LGTM 👍

filename: 'strip-ansi.js',
},
}),
];
Copy link
Member

Choose a reason for hiding this comment

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

I am afraid, some modules can use new syntax (ES 6) and we can't catch it, for example in patch version

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@evilebottnawi If that happens when we are updating a dependency, it will be caught in CI here: https://github.com/webpack/webpack-dev-server/pull/2658/files#diff-24488ac612ba9666465a7a596040ac73R43

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But if we want full safety, we should do this: #2652. I don't like how that PR ended up because it has so many breaking changes in the API and seems a little risky

Copy link
Member

Choose a reason for hiding this comment

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

Sound good to me. CI is enough for me.

@knagaitsev
Copy link
Collaborator Author

Ah, issue with lodash is making lint fail: https://www.npmjs.com/advisories/1523

@hiroppy
Copy link
Member

hiroppy commented Jul 17, 2020

@Loonride could you rebase this? This PR will be merged after merging #2675

@knagaitsev
Copy link
Collaborator Author

/cc @evilebottnawi @hiroppy

@alexander-akait alexander-akait merged commit c7e53b0 into webpack:v4 Aug 26, 2020
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.

4 participants