Skip to content

How about modules which are functions with properties? #13

@fabiosantoscode

Description

@fabiosantoscode

If I have a module mymodule which exports a function with properties, as follows:

module.exports = function mymodule() { /* ... */ }
module.exports.foo = 1

How am I supposed to "statify" it, without choosing whether to restrict my client code to use either the function or the properties?

// Case 1: statify the function
staticModule({
    mymodule: function () { return '"something"' }
})  // Bad! cannot access require('mymodule').foo

// Case 2: statify the props
staticModule({
    mymodule: {
        foo: function() { return '1' }
    }
})  // Bad! cannot call require('mymodule')()

My use case is my project over at fabiosantoscode/require-emscripten, which is a node module exporting a function which also has properties.

Metadata

Metadata

Assignees

No one assigned

    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