Skip to content

Please update the docs for resolve.extensions #1062

@anyong

Description

@anyong

The current docs have a warning:

IMPORTANT: Setting this option will override the default, meaning that webpack will no longer try to resolve modules using the default extensions. If you want modules that were required with their extension (e.g. require('./somefile.ext')) to be properly resolved, you must include an empty string in your array. Similarly, if you want modules that were required without extensions (e.g. require('underscore')) to be resolved to files with “.js” extensions, you must include ".js" in your array.

The middle part about the empty string is also required for regular node_modules imports, without the ./ prefix. I didn't have any imports with the full extension, I had my extensions labelled correctly otherwise in webpack.config.js (i.e.: extensions: ['.js', '.jsx']), and webpack kept complaining that it couldn't find any of my modules. Adding '' to the list solved the problem, but it took me a full day to figure this out, perhaps it should be explicitly mentioned in the docs so others don't make the same silly mistake?

Even better, if webpack comes across a require without a path prefix, it should default to looking for a node_modules module without considering any extensions.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions