Skip to content

Can't defined exposed name with require option #881

@guillaume86

Description

@guillaume86

Using the programmatic API, I try to bundle a file and expose it with a simple name:

bundle.expose(path, { expose: 'simpleName' }')

The resulting file keeps the path as the module identifier.
I digged in the source code and the problematic part seems to be:
https://github.com/substack/node-browserify/blob/master/index.js#L119-L126

I'm on windows and my path is C:\Folder\file.ext and the regex test evaluates to false (path don't start by . or /) so the id is set to the path.
Then the exposed name is not assigned since the id is already defined.

I don't really get what is the purpose of lines 119-121 but I guess it needs to be changed to support windows. If someone can explain it to me I can try to submit a pull request with windows support.

Edit:
It could also be a bug (I don't see why the expose parameter shouldn't be used in any case),
in that case changing the line 121 with : xtend(opts, { id: (expose || file), file: file }) should fix the problem.

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