Skip to content

0.4.2 breaks - passes invalid data to babel-helper-evaluate-path #845

@swernerx

Description

@swernerx

Describe the bug

To Reproduce

Minimal code to reproduce the bug

export class Component extends Other {
  constructor() {
    super()
    this.flag = true
  }

  main() {
    alert(this.foo)
  }
}

Actual Output

Nothing!

Expected Output

Output when disabling minify preset:

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Component = void 0;

class Component extends Other {
  constructor() {
    super();
    this.flag = true;
  }

  main() {
    alert(this.foo);
  }

}

exports.Component = Component;

Stack Trace

If applicable,

TypeError: stmts.entries is not a function
    at compareBindingAndReference (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-helper-evaluate-path/lib/index.js:252:32)
    at evaluateBasedOnControlFlow (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-helper-evaluate-path/lib/index.js:213:27)
    at evaluateIdentifier (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-helper-evaluate-path/lib/index.js:119:26)
    at evaluate (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-helper-evaluate-path/lib/index.js:21:12)
    at PluginPass.Expression (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-plugin-minify-constant-folding/lib/index.js:165:21)
    at PluginPass.newFn (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/visitors.js:286:17)
    at newFn (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/visitors.js:243:21)
    at NodePath._call (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/path/context.js:65:18)
    at NodePath.call (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/path/context.js:100:12)

Configuration

How are you using babel-minify?

Directly from the CLI.

babel-minify version: 0.4.2
babel version : 7.0.0-beta.46
babel-minify-config: None

babelrc:

{
 "presets": [
   [ "@babel/env", { "targets": { "node": '6.9.0', "browsers": [] } } ],
   "minify"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions