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

deps: Add webpack 4 compatibility #33

Merged
merged 5 commits into from
Mar 19, 2018
Merged

deps: Add webpack 4 compatibility #33

merged 5 commits into from
Mar 19, 2018

Conversation

benurb
Copy link
Contributor

@benurb benurb commented Mar 16, 2018

Should fix #32
Also should not break compatibility with previous webpack versions.

@benurb benurb requested a review from jhnns March 16, 2018 15:01
@benurb
Copy link
Contributor Author

benurb commented Mar 16, 2018

Test fails because webpack 4 is not compatible with Node.js 4. We can change the .travis.yml here, too, but I also created a PR for this #34

Copy link
Member

@jhnns jhnns left a comment

Choose a reason for hiding this comment

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

LGTM in general, despite two minor issues 😁

const publicPath = options.publicPath === undefined ? this.options.output.publicPath : options.publicPath;
const publicPath = options.publicPath ||
(this.options && this.options.output && this.options.output.publicPath) ||
(this._compilation && this._compilation.outputOptions && this._compilation.outputOptions.publicPath);
Copy link
Member

Choose a reason for hiding this comment

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

  1. I think we should check for "publicPath" in options here because an empty string as publicPath is a valid option
  2. The check for this.options is necessary with webpack 4, but could you add a TODO that this should be removed with the next major release
  3. I guess you've added the this._compilation part so that we can still derive the publicPath. We should also remove that with the next major release since this._compilation is likely to be removed in the future.

Copy link
Member

Choose a reason for hiding this comment

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

I've created an issue for that: #35

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. You're right. I'll change that.
  2. and 3. Remove access of this.options and this._compilation #35 is enough, isn't it?

stats.compilation.fileDependencies.forEach(
dependency => {
dependencies.push(dependency.slice(basePath.length));
}
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, this could be solved with Array.from:

const dependencies = Array.from(stats.compilation.fileDependencies)
    .map(dependency => dependency.slice(basePath.length));

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, looks good. I'll change that 👍

@benurb
Copy link
Contributor Author

benurb commented Mar 19, 2018

I've addressed your remarks 👍 PTAL

Copy link
Member

@jhnns jhnns left a comment

Choose a reason for hiding this comment

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

Almost done 😁

I think it's important that the empty string for the publicPath is used.

const publicPath = options.publicPath ||
(this.options && this.options.output && this.options.output.publicPath) ||
(this._compilation && this._compilation.outputOptions && this._compilation.outputOptions.publicPath);
const publicPath = options.publicPath || getPublicPath(this);
Copy link
Member

Choose a reason for hiding this comment

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

If options.publicPath was an empty string, the empty string should be used. Maybe change that line to:

const publicPath = "publicPath" in options ? options.publicPath : getPublicPath(this)

Or maybe put that logic into getPublicPath as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea behind getPublicPath() was a function that can be removed when we work on #35 .
That's why options was not included.

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.

Support Webpack v4
2 participants