indutny / asn1.js

ASN.1 Decoder/Encoder/DSL
MIT License
181 stars 64 forks source link

Unexpected token on version 4.10.0 #91

Closed SamuelBeliveau closed 6 years ago

SamuelBeliveau commented 6 years ago

Since I got the latest version, my webpack build now fails.

Unexpected token: name (len) [./~/asn1.js/lib/asn1/decoders/der.js:58,0][vendor.js:93723,6]
  in undefined

My dependency tree is

`-- webpack@2.6.1
  `-- node-libs-browser@2.0.0
    `-- crypto-browserify@3.11.0
      `-- browserify-sign@4.0.4
        `-- parse-asn1@5.1.0
          `-- asn1.js@4.10.0
indutny commented 6 years ago

I've just tried it with webpack@2.7.0 and 3.x and it appears to be working... If it might be possible to isolate - would you care to share some code that reproduces the issue?

indutny commented 6 years ago

FWIW, the code at that line looks pretty normal:

  let len = derDecodeLen(buffer,
    decodedTag.primitive,
    'Failed to get length of "' + tag + '"');
SamuelBeliveau commented 6 years ago

I'll see what I can do. Maybe that part of the build doesn't understand es6 constructs...

robbinjanssen commented 6 years ago

Not sure how to reproduce but having the same problem, uglify-js is the one who generates the error.

ERROR in js/vendor.876e7517549e49515645.js from UglifyJs
Unexpected token: name (len) [./~/asn1.js/lib/asn1/decoders/der.js:58,0][js/vendor.876e7517549e49515645.js:37953,6]

Using this uglify-js config:

 new webpack.optimize.UglifyJsPlugin({
    sourceMap: true,
    mangle: {
      screw_ie8: true,
      except: []
    },
    comments: true,
    compress: {
      screw_ie8: true,
      sequences: true,
      properties: true,
      dead_code: true,
      drop_debugger: true,
      unsafe: true,
      conditionals: true,
      comparisons: true,
      evaluate: true,
      booleans: true,
      loops: true,
      unused: true,
      hoist_funs: true,
      hoist_vars: false,
      if_return: true,
      join_vars: true,
      cascade: true,
      warnings: false,
      negate_iife: true,
      pure_getters: true,
      pure_funcs: null,
      drop_console: false,
      keep_fargs: false,
      keep_fnames: false
    },
  }),
indutny commented 6 years ago

I can reproduce it too now! Had to use -p flag for webpack to enable uglify. Let's see what's causing it.

indutny commented 6 years ago

Okay, I think I'm going to unpublish the update and do a major bump. It looks like the babel is mandatory now and wasn't mandatory before.

indutny commented 6 years ago

Alright, all is unpublished now. Thank you for reporting. Please let me know if the error persists.

robbinjanssen commented 6 years ago

Solved my problems, thanks 👍

SamuelBeliveau commented 6 years ago

Fixed my problem, too. Thanks.