title: How to workaround the "Unexpected Token Operator (>)" error when packaging a React app?
body: <p>I am having some problems building the distributable package for a React app.</p>
  
  <p>I'm trying to execute the following sentence:</p>
  
  <p><code>rimraf dist &amp;&amp; env-cmd .env cross-env NODE_ENV=production webpack -p --config ./config/webpack/prod.js</code></p>
  
  <p>And receiving this error:</p>
  
  <pre><code>ERROR in a86e50ffd4893c44fdfd.app.js from UglifyJs Unexpected token:
  operator (&gt;) [a86e50ffd4893c44fdfd.app.js:10679,43]
  </code></pre>
  
  <p>The line indicated in that trace corresponds to one of the libraries being loaded as dependencies, and not to the actual code of my app. This is the line itself (line 10679 corresponds to the declaration of the const method with the arrow function):</p>
  
  <pre><code>const DEFAULT_DISPLAY_LABEL_FOR_NULL_VALUES = '';
  /* unused harmony export DEFAULT_DISPLAY_LABEL_FOR_NULL_VALUES */
  
  const getAllColumnLabels = (columnLabels) =&gt; {
      const columnNames = [];
      columnLabels.forEach((value) =&gt; {
          columnNames.push(value.label);
      });
      return columnNames;
  };
  </code></pre>
  
  <p>At first I thought it could be related to Babel config, but it is identical to another project which is building correctly. The content of my <code>.babelrc</code> file is shown below, loaded using <code>babel-preset-env</code>:</p>
  
  <pre><code>{
    "presets": [
      [
        "env", {
          "modules": false,
          "targets": {
            "browsers": [
              "Chrome &gt;= 52",
              "FireFox &gt;= 44",
              "Safari &gt;= 7",
              "Explorer 11",
              "last 4 Edge versions"
            ]
          },
          "useBuiltIns": true
        }
      ]
    ]
  }
  </code></pre>
  
  <p>An additional test to rule out some possibilities has been done using the default presets for Babel, though no success was achieved with this test.</p>
  
  <pre><code>{
    "presets": [
      [
        "env",
        {
          "modules": false
        }
      ]
    ]
  } 
  </code></pre>
  
  <p>The settings in tsconfig.json could also be of interest, so i'm showing them here even though they also are identical to the ones in this another project mentioned above, which builds correctly:</p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es6",
      "module": "es6",
      "lib": ["dom", "es2017"],
      "moduleResolution": "node",
      "declaration": false,
      "noImplicitAny": false,
      "sourceMap": true,
      "jsx": "react",
      "noLib": false,
      "allowJs": true,
      "suppressImplicitAnyIndexErrors": true,
      "skipLibCheck": true,
      "noUnusedLocals": true,
      "noUnusedParameters": true,
    },
    "compileOnSave": true,
    "exclude": [
      "node_modules",
      "**/*.spec.ts"
    ]
  }
  </code></pre>
  
  <p>I've tried to delete <code>node_modules</code> and re-install the dependencies, also played setting <code>uglify</code> to <code>false</code> in the env for Babelrc, but surprisingly (at least, to me!) it didnt help.</p>
  
  <p>There is a <a href="https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/104" rel="nofollow noreferrer">thread in the webpack-contrib Github</a> site which is marked as closed but I didnt find anything that helped me.</p>
  
  <p>Any ideas? I have some experience with npm but this issue certainly is blocking me.</p>
  
  <p>Thanks!</p>