Skip to content

CommonJS model: minified __esModule marker (!0) and read-only called functions #34

Open

Description

@inth3shadows

Found in the PR #29 round-14 review. Two smaller gaps in PR #29's handling:

  1. F21 __esModule marker only recognises literal true. Minified output (Terser, UglifyJS, minified Babel) writes Object.defineProperty(exports,"__esModule",{value:!0}) or exports.__esModule=!0. With exports.default = load, the file stays modelled, and import load from './m' loses the pre-PR edge to m.js:load. Treat any truthy literal (!0, 1, a non-empty string) as the marker.
  2. A called function declaration that only reads module/exports blocks every member. function isMain(){ return require.main === module } isMain(); or function peek(){ return exports.a } peek(); sets capturesExports, which invalidates the exports with 'indirect eval effects' (a blocking reason), so every member answers no-edge. The arrow and callback forms keep their edges. Only writes, or eval reachability, should set it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions