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

Are all dependencies required at runtime? #24

Closed
matthewwithanm opened this issue Aug 20, 2015 · 3 comments
Closed

Are all dependencies required at runtime? #24

matthewwithanm opened this issue Aug 20, 2015 · 3 comments
Labels

Comments

@matthewwithanm
Copy link

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!

@matthewwithanm matthewwithanm changed the title Are dependencies required at runtime? Are all dependencies required at runtime? Aug 20, 2015
@twada
Copy link
Member

twada commented Aug 21, 2015

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!

@matthewwithanm
Copy link
Author

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!

@twada
Copy link
Member

twada commented Aug 22, 2015

Hi @matthewwithanm, thanks again for your information!

though a FAQ addressing them would be awesome

Okay, I'll add FAQ section to README.

@twada twada added the question label Jun 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants