Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Rewrite typeof module/exports #151

@Rich-Harris

Description

@Rich-Harris

Ref rollup/rollup#1061. If this plugin rewrote typeof module, typeof exports and typeof module.exports inside a createCommonjsModule wrapper as 'object', then a lot of UMD checks could be simplified:

if (typeof exports === "object" && typeof module === "object") {
  module.exports = foo;
} else if (typeof define === "function" && define.amd) {
  define([], function () { return foo; });
} else {
  window.foo = foo;
}

...becomes this...

if ('object' === "object" && 'object' === "object") {
  module.exports = foo;
} else if (typeof define === "function" && define.amd) {
  define([], function () { return foo; });
} else {
  window.foo = foo;
}

...which becomes this:

{
  module.exports = foo;
}

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