Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Changes for the v3 release #72

Merged
merged 55 commits into from
Aug 21, 2019
Merged

Changes for the v3 release #72

merged 55 commits into from
Aug 21, 2019

Conversation

jeffposnick
Copy link
Contributor

@jeffposnick jeffposnick commented Jun 7, 2018

A lot of lines of code have changed in this PR, but the changes can roughly be broken down into:

  • Refining the language in the README.
  • Adding support for webpack v4, including running the same integration test suite against webpack v3 and v4.
  • Explicit support for node 6 and higher via @babel/present-env, dropping compatibility with node v4.
  • Refactoring the codebase into smaller modules, and running unit tests against some of them.
  • More robust input validation, and additional error messages.

The most visible functional change is webpack v4 support, with most of the other changes being of the under-the-hood variety.

@addyosmani, if you could focus on the changes to the README (with whatever level of detail you consider appropriate for the other files), that would be appreciated!

The alpha/betas have been used by several folks in the community, including @developit

Fixes #47

@jeffposnick jeffposnick requested a review from addyosmani June 7, 2018 20:39
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

return htmlPluginData;
}

apply(compiler) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good pattern in general.

We ran into issues with folks who listed this plugin prior to the HtmlWebpackPlugin, or just didn't list HtmlWebpackPlugin at all, and in v4 we can detect that at https://github.com/GoogleChromeLabs/preload-webpack-plugin/pull/72/files/b1f8ec65d655dfa064fad73765c6c552dc089a38#diff-1fdf421c05c1140f6d71444ea2b27638R135 and show a meaningful error message. I think it's worthwhile keeping the tapping logic explicit in this case since we're doing that detection.

if (attributeValue === '') {
attributeStrings.push(attributeName);
} else {
attributeStrings.push(`${attributeName}=${JSON.stringify(attributeValue)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if any of the values have this issue, but a quote within a value seems like it would break here. Something like this would circumvent the issue.

Copy link
Contributor Author

@jeffposnick jeffposnick Jul 19, 2018

Choose a reason for hiding this comment

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

JSON.stringify() generally does a good job of making sure that you get back a properly-escaped string, regardless of inner quote characters. I've got a unit test to confirm that:

it(`should properly escape the attribute values as strings`, function(done) {
const elementString = createHtmlElementString({
elementName: 'test',
attributes: {
string: `Strings: '"\``
}
});
expect(elementString).toEqual('<test string="Strings: \'\\"`">');

Does that address your concern, or am I missing a possible edge case?

.babelrc Outdated
@@ -0,0 +1,10 @@
{
"plugins": ["@babel/transform-runtime"],
Copy link

Choose a reason for hiding this comment

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

Can this be left out? lib-size isn't as important for webpack plugins. I'm seeing issues with the runtime not getting hoisted correctly in node_modules.

Copy link

Choose a reason for hiding this comment

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

Actually, I don't think it's a node_module structure issue. I think the latest babel beta changed the runtime api... this project probably needs to be recompiled and published... preferably without the runtime transform.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've bumped all the dependencies in this commit, including babel-related ones to 7.0.0-beta.56. Does that help at all?

That being said, I'm not sure why shipping a project like this that relied on @babel/runtime as a dependency would be an issue. Is there any official guidance from the babel team about that?

Copy link

Choose a reason for hiding this comment

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

The runtime afaik is only meant to reduce babel helper duplication in libraries meant to be bundled. In my opinion, it's not terribly useful for code that is meant to run on node. If not included your code will run just the same. Since you are using the env preset for node6+ there isn't much being transformed.

Here is the docs on that transform: https://babeljs.io/docs/en/next/babel-plugin-transform-runtime.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, fair enough. If it helps, I've removed the transform-runtime in the latest commit.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@jeffposnick
Copy link
Contributor Author

After discussing with @addyosmani, I'm just going to merge this into master and we'll move forward from there with future changes.

@jeffposnick jeffposnick merged commit 5480093 into master Aug 21, 2019
@addyosmani
Copy link
Contributor

addyosmani commented Aug 22, 2019 via email

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

Successfully merging this pull request may close these issues.

Impose a minimum supported version of node + transpile against that
5 participants