Skip to content

Packages: Stop using Node.js built-ins in browser-packaged code #13386

@aduth

Description

@aduth

We should seek to move away from referencing Node.js built-ins from modules, e.g. import { parse } from 'url';, where 'url' is a reference to a browser-compatible variant of the Node url module.

Reasons include:

  • These automated polyfills are slated for removal in future versions of Webpack (reference)
  • There is redundancy with other module usage such as the use of qs in the @wordpress/url package
    • Contributes to larger overall bundle sizes
  • The polyfills are not implemented using ES Modules and thus require pulling in much more code than is actually used (example, see full list)

Instances:

(Questionable: Instances within @wordpress/e2e-tests and @wordpress/e2e-test-utils ? These may be compiled with Webpack, despite not being intended for use in a browser)

With this, it should be considered to disable automatic polyfills from Webpack (reference).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueAn issue that's suitable for someone looking to contribute for the first timeNeeds DevReady for, and needs developer efforts[Type] TaskIssues or PRs that have been broken down into an individual action to takenpm PackagesRelated to npm packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions