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

Build Tooling: Configure Webpack to skip Node polyfills #21647

Closed
aduth opened this issue Apr 16, 2020 · 8 comments · Fixed by #26382
Closed

Build Tooling: Configure Webpack to skip Node polyfills #21647

aduth opened this issue Apr 16, 2020 · 8 comments · Fixed by #26382
Assignees
Labels
[Package] Scripts /packages/scripts [Status] In Progress Tracking issues with work in progress [Type] Build Tooling Issues or PRs related to build tooling [Type] Task Issues or PRs that have been broken down into an individual action to take

Comments

@aduth
Copy link
Member

aduth commented Apr 16, 2020

Previously: #13386

Context:

Webpack will no longer polyfill Node modules automatically in the upcoming v5 release:

https://github.com/webpack/changelog-v5/blob/master/README.md#automatic-nodejs-polyfills-removed

Task:

Configure default Webpack configurations to disable node polyfills as false:

https://webpack.js.org/configuration/node/#node

Motivation:

Simplify a future upgrade to Webpack 5 by avoiding to put ourselves in the situation of migrating away from the automatic polyfills, by forbidding their introduction in the first place.

Future Considerations:

If we choose to upgrade to Webpack 5 before this task is implemented, the work would no longer be necessary.

@aduth aduth added [Type] Task Issues or PRs that have been broken down into an individual action to take Good First Issue An issue that's suitable for someone looking to contribute for the first time [Type] Build Tooling Issues or PRs related to build tooling labels Apr 16, 2020
@gziolo gziolo added Needs Dev Ready for, and needs developer efforts [Package] Scripts /packages/scripts labels May 9, 2020
@gziolo
Copy link
Member

gziolo commented May 13, 2020

The up to date link to the related document from webpack is:
https://v4.webpack.js.org/configuration/node/#node

Defaults in v4:

module.exports = {
  //...
  node: {
    console: false,
    global: true,
    process: true,
    __filename: 'mock',
    __dirname: 'mock',
    Buffer: true,
    setImmediate: true

    // See "Other node core libraries" for additional options.
  }
};

Defaults in v5:

module.exports = {
  //...
  node: {
    global: false,
    __filename: false,
    __dirname: false,
  }
};

@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label May 13, 2020
@gziolo gziolo self-assigned this May 13, 2020
@gziolo
Copy link
Member

gziolo commented May 13, 2020

I tried to go with node: false in #22312 but it isn't straightforward. Should we maybe update this issue to target webpack v5 upgrade instead?

@aduth
Copy link
Member Author

aduth commented May 13, 2020

Should we maybe update this issue to target webpack v5 upgrade instead?

Ultimately I think that should be the goal. By this, do you mean to put together a pull request using the Webpack 5.0 beta? Just to get ready for the impending release, or to actually start running on the beta?

@gziolo
Copy link
Member

gziolo commented May 13, 2020

Ultimately I think that should be the goal. By this, do you mean to put together a pull request using the Webpack 5.0 beta?

I was thinking about updating the title and description, for now, 😄 Opening PR with webpack v5 branch early might be a good idea as well. I would prefer to avoid running on beta 🤣

@aduth
Copy link
Member Author

aduth commented May 13, 2020

I would prefer to avoid running on beta 🤣

I feel the same. Having the pull request ready though, it may save us time down the line, and help identify all the possible incompatibilities.

@gziolo gziolo removed their assignment Jun 2, 2020
@gziolo gziolo removed the [Status] In Progress Tracking issues with work in progress label Jun 2, 2020
@gziolo
Copy link
Member

gziolo commented Jun 2, 2020

I closed #22312 as it isn't as simple as I anticipated. I hope it's going to be easier to address as part of webpack v5 with their official migration guide. Still, this PR is a good reference to look at when trying to land changes related to how Node polyfills are handed.

@gziolo
Copy link
Member

gziolo commented Oct 14, 2020

Webpack 5 is out now:
https://webpack.js.org/blog/2020-10-10-webpack-5-release/

To v5 from v4 migration guide might be useful as well:
https://webpack.js.org/migrate/5/

@gziolo
Copy link
Member

gziolo commented Oct 24, 2020

@jsnajdr is working on webpack 5 upgrade in #26382 which is going to address this issue one way or another.

@gziolo gziolo added [Status] In Progress Tracking issues with work in progress and removed Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts labels Oct 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Scripts /packages/scripts [Status] In Progress Tracking issues with work in progress [Type] Build Tooling Issues or PRs related to build tooling [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
3 participants