Are all dependencies required at runtime?
matthewwithanm opened this issue · 3 comments
I have some tests that I'd like to run both in node and the browser. The tests are compiled using Babel (with babel/register to run in node, and with webpack's Babel loader for the browser).
My assumption was that I could just add babel-plugin-espower to my .babelrc plugins in order to apply the transformation for both cases. This worked, however, the browser build is including power-assert's dependencies, including acorn (some of which are causing webpack to generate build warnings). I think I understand why this is happening; my tests require power-assert, so naturally the dependencies are getting bundled.
So my question is, are all of the dependencies necessary at run time or are they just required for the transform? (If just for the transform is there a recommended way to omit them?)
I hope this is the right forum for this question! Thanks so much for such an awesome project!
Hi @matthewwithanm, thank you for your question!
My assumption was that I could just add babel-plugin-espower to my .babelrc plugins in order to apply the transformation for both cases. This worked, however, the browser build is including power-assert's dependencies, including acorn (some of which are causing webpack to generate build warnings). I think I understand why this is happening; my tests require power-assert, so naturally the dependencies are getting bundled.
Yes. You are right.
So my question is, are all of the dependencies necessary at run time or are they just required for the transform? (If just for the transform is there a recommended way to omit them?)
The answer is, "All of the dependencies necessary".
That's due to my design decision. In transformation phase, instrumentors (including babel-plugin-espower) transform assertion expressions by AST level so they should store original expression into code.
At runtime, power-assert-formatter parses them back by using acorn, calculate locations, then maps captured values in a diagram form.
some of which are causing webpack to generate build warnings
Ah webpack... Maybe you need to add some webpack loaders to suppress warnings, but you may not want that.
Once I changed bundled parser from esprima to acorn to support ES6 syntax. Recently esprima 2.5 supports ES6. So it's time to estimate esprima again.
I hope this is the right forum for this question!
Yes. Currently here is the only channel for questions.
Thanks so much for such an awesome project!
Thank you for using power-assert!
Thanks so much! That clears things up a lot.
As for the webpack stuff, there seem to be two things at play: 1) the use of a dynamic require (which I assume is the same reason for this), and 2) acorn's use of a built file. Neither of these is really an issue with power-assert (though a FAQ addressing them would be awesome).
Thanks again for the help!
Hi @matthewwithanm, thanks again for your information!
though a FAQ addressing them would be awesome
Okay, I'll add FAQ section to README.