Skip to content

The Result of unwrapExports is Never Assigned #102

Closed
@ryanfitzer

Description

@ryanfitzer

This issue was transferred from rollup/rollup-plugin-commonjs, which had no issue templates

I'm trying to bundle styled-jsx with my React comment and getting errors resulting from the unwrapExports function being called but never assigned. Here is the abbreviated output:

/* ... */

function createCommonjsModule(fn, module) {
    return module = {
        exports: {}
    }, fn(module, module.exports), module.exports;
}

/* ... */

var style = createCommonjsModule(function(module, exports) {

    Object.defineProperty(exports, "__esModule", {
        value: true
    });
    exports.flush = flush;
    exports.default = void 0;
    
    /* ... */
    
    var JSXStyle =
        /*#__PURE__*/
        function(_Component) {/* ... */}(React.Component);

    exports.default = JSXStyle;

    function flush() {/* ... */}
});

unwrapExports(style);
var style_1 = style.flush;

var style$1 = style;

As you can see, unwrapExports(style); is called, but never assigned to style$1. This results in errors when any methods of style$1 are used since its value is module.exports (via createCommonjsModule) instead of module.exports.default.

If I alter the last line to be the following, everything works as expected:

var style$1 = unwrapExports(style);

Am I possibly misconfiguring the plugin? Any pointers will be much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions