Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicts with babel-plugin-istanbul #4

Open
ELLIOTTCABLE opened this issue Jun 22, 2017 · 2 comments
Open

Conflicts with babel-plugin-istanbul #4

ELLIOTTCABLE opened this issue Jun 22, 2017 · 2 comments

Comments

@ELLIOTTCABLE
Copy link

   "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
Copy link
Member

twada commented Jun 22, 2017

Thank you for reporting!

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

That's true. Due to the plugin ordering in Babel6, and it's under discussion in Babel7 (babel/babel#5623, babel/babel#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
Copy link
Author

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

Fly safe! <3

twada added a commit to power-assert-js/power-assert that referenced this issue Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants