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

Fully asserted build #569

Open
phadej opened this issue Mar 30, 2015 · 3 comments
Open

Fully asserted build #569

phadej opened this issue Mar 30, 2015 · 3 comments

Comments

@phadej
Copy link
Member

phadej commented Mar 30, 2015

We could have the Bacon.js build with all runtime-checkable preconditions (e.g. parameter should be a function or a stream) asserted. We already have assert* we strip for production build. But we can assert more.

Related: #568

@lautis
Copy link
Member

lautis commented Mar 30, 2015

Could the asserts use environment variables like React does? This would make it easier to have asserts in your development build, but strip them away in production with envify.

@phadej
Copy link
Member Author

phadej commented Mar 30, 2015

@lautis I'd rather write:

function foo(stream) {
  assertStream(stream);
  // ...
}

function assertStream(stream) {
  if (process.env.NODE_ENV === "development") {
    assert(stream instanceof EventStream):
  }
}
function foo(stream) {
  if (process.env.NODE_ENV === "development") {
    assertStream(stream):
  }
}

function assertStream(stream) {
  assert(stream instanceof EventStream);
}

If envify + uglify can minify the former version, than why so not. Actually if one could mark functions to be inlined by uglify (or something else), that would be awesome.

Sorry, to lazy to try myself.

@lautis
Copy link
Member

lautis commented Mar 30, 2015

UglifyJS isn't able to remove calls to empty functions nor does it have inlining. To remove all traces of asserts with envify/uglifyjs, the latter form would have to be used. However, we could add guards to assert calls in assemble.js or let JS compilers optimise away empty functions.

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