Skip to content

postal.xframe and webpack #22

@RainerAtSpirit

Description

@RainerAtSpirit

postal.xframe (bower) won't work OOTB with webpack.

Seems that the order of AMD vs CommonJS check in this environment must be CommonJS first like in postal.federation.

(function( root, factory ) {
    if ( typeof module === "object" && module.exports ) {
        // Node, or CommonJS-Like environments
        module.exports = function( postalFed ) {
            return factory( require( "lodash" ), postalFed );
        };
    } else if ( typeof define === "function" && define.amd ) {
        // AMD. Register as an anonymous module.
        define( [ "lodash", "postal.federation" ], function( _, postal ) {
            return factory( _, postal, root );
        } );
    } else {
        // Browser globals
        root.postal = factory( root._, root.postal, root );
    }
}( this, function( _, postal, global, undefined ) {

    //import("xframe.js");

    return postal;

} ));

While this violates the consense made in http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/#update2 reversing the order solves the issue for webpack.

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