Skip to content

Add webpack5-compatible options parsing (this.getOptions + URLSearchParams) #10

@shekhei

Description

@shekhei

Context

The loader currently uses loader-utils@^1.2.3 with loaderUtils.getOptions(this) and loaderUtils.parseQuery(this.resourceQuery). Both are legacy patterns; webpack5 prefers this.getOptions() and URLSearchParams-based parsing. Keeping compatibility helps modern projects.

Why this matters

Improves compatibility with webpack5 and reduces reliance on deprecated loader-utils APIs.

Proposal

  • Support this.getOptions() when available, with a fallback for older webpack versions.
  • Replace loaderUtils.parseQuery with URLSearchParams (or a lightweight parser) for resourceQuery.
  • Consider upgrading or removing the dependency on loader-utils if no longer needed.

Tasks

  • Implement const loaderOptions = this.getOptions ? this.getOptions() : loaderUtils.getOptions(this).
  • Parse this.resourceQuery via new URLSearchParams(this.resourceQuery) and coerce numeric values.
  • Update dependencies (e.g., loader-utils v2) if still required.
  • Add/adjust tests for query parsing in webpack4/5.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions