power-assert-js / babel-preset-power-assert

Babel preset for all power-assert plugins
MIT License
32 stars 2 forks source link

Conflicts with babel-plugin-istanbul #4

Open ELLIOTTCABLE opened 7 years ago

ELLIOTTCABLE commented 7 years ago
   "presets": [ "power-assert" ]
 , "plugins": [ "istanbul" ]

So, I can't narrow it down to a simple test-case; but at the moment, using the power-assert preset (for testing output) alongside the istanbul plugin (for coverage generation) produces obscure syntax errors inside babel:

/home/travis/build/ELLIOTTCABLE/giraphe/node_modules/babel-core/lib/transformation/file/index.js:590
      throw err;
      ^
SyntaxError: /home/travis/build/ELLIOTTCABLE/giraphe/giraphe.js: Invalid left-hand side in prefix operation (3097:69)
  3095 |        KEY = (++cov_1mlpy989m8.s[53], null != opts.keyer ? (++cov_1mlpy989m8.b[19][0], opts.keyer.call(current, current)) : (++cov_1mlpy989m8.b[19][1], current[opts.key]));
  3096 |    ++cov_1mlpy989m8.s[54];
> 3097 |    (0, _powerAssert2.default)(_rec5._expr(_rec5._capt((_rec5._capt(++_rec5._capt(_rec5._capt(_rec5._capt(_rec5._capt(cov_1mlpy989m8, 'arguments/0/left/expressions/0/argument/object/object/object').b, 'arguments/0/left/expressions/0/argument/object/object')[20], 'arguments/0/left/expressions/0/argument/object')[0], 'arguments/0/left/expressions/0/argument'), 'arguments/0/left/expressions/0'), _rec5._capt(_rec5._capt(typeof KEY === 'undefined' ? 'undefined' : (0, _typeof3.default)(KEY), 'arguments/0/left/expressions/1/left') === 'string', 'arguments/0/left/expressions/1')) && (_rec5._capt(++_rec5._capt(_rec5._capt(_rec5._capt(_rec5._capt(cov_1mlpy989m8, 'arguments/0/right/expressions/0/argument/object/object/object').b, 'arguments/0/right/expressions/0/argument/object/object')[20], 'arguments/0/right/expressions/0/argument/object')[1], 'arguments/0/right/expressions/0/argument'), 'arguments/0/right/expressions/0'), _rec5._capt(_rec5._capt(KEY, 'arguments/0/right/expressions/1/left') !== '', 'arguments/0/right/expressions/1')), 'arguments/0'), {
       |                                                                      ^
  3098 |       content: 'assert((++cov_1mlpy989m8.b[20][0], typeof KEY === \'string\') && (++cov_1mlpy989m8.b[20][1], KEY !== \'\'))',
  3099 |       filepath: './giraphe.es6.js',
  3100 |       line: 102
    at Parser.pp$5.raise (/home/travis/build/ELLIOTTCABLE/giraphe/node_modules/babylon/lib/index.js:4454:13)
    at Parser.pp$2.checkLVal (/home/travis/build/ELLIOTTCABLE/giraphe/node_modules/babylon/lib/index.js:3233:14)
    at Parser.checkLVal (/home/travis/build/ELLIOTTCABLE/giraphe/node_modules/babylon/lib/index.js:6086:22)
    at Parser.pp$3.parseMaybeUnary (/home/travis/build/ELLIOTTCABLE/giraphe/node_modules/babylon/lib/index.js:3464:12)

(More: https://travis-ci.org/ELLIOTTCABLE/giraphe/jobs/245592548#L224-L372)

This is fixed by removing babel-preset-power-assert and replacing it with the individual plugins themselves, and then loading all three of them as babel plugins, instead of presets.

   "plugins": [ "espower", "empower-assert", "istanbul" ]
twada commented 7 years ago

Thank you for reporting!

I suspect it's a problem with load-order within babel, and one of the two systems stomping on eachother. https://github.com/istanbuljs/babel-plugin-istanbul/issues/115

That's true. Due to the plugin ordering in Babel6, and it's under discussion in Babel7 (https://github.com/babel/babel/issues/5623, https://github.com/babel/babel/issues/5854).

  • Plugins run before Presets.
  • Plugin ordering is first to last.
  • Preset ordering is reversed (last to first).

Plugin/Preset Ordering

In short, if power-assert transpiler runs before istanbul, it works.

Hmm I'll add this to known problems.

ELLIOTTCABLE commented 7 years ago

Thanks for the quick reply, @twada! Feel free to link to the issue from the README or something like that, then.

Fly safe! <3