Skip to content

'foo.bar' replacement not working with ProvidePlugin in v5 #11619

@mwiencek

Description

@mwiencek

Bug report

Apologies if this is documented somewhere or solved by a simple configuration change. I didn't see anything in https://webpack.js.org/migrate/5/

What is the current behavior?

In Webpack v4 I could pass something like 'texp.l': ['./texp', 'l'] to ProvidePlugin, and it'd be treated as either texp.l() (input) => import * as texp from './texp'; texp.l(); (output) or import {l as texp_l} from './texp'; texp_l(); (output). (Not sure how Webpack handled it under the hood, but it behaved equivalently to one of those.)

If the current behavior is a bug, please provide the steps to reproduce.

See https://github.com/mwiencek/provideplugin-issue

What is the expected behavior?

Passing foo.bar (any property access) as an identifier to the ProvidePlugin should provide/replace that with a reference to the configured module. Similar to the window.jQuery example in the docs.

Other relevant information:
webpack version: 5.0.0-rc.4
Node.js version: v14.10.1
Operating System: macOS 10.15.6
Additional tools: webpack-cli v4.0.0-rc.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions