Coder Social home page Coder Social logo

Comments (9)

colindresj avatar colindresj commented on August 29, 2024

👍 on this. Early on I was doing some pseudo-type checking on getters using isGetter, but decided to drop that approach because I didn't find it reliable enough.

from nuclear-js.

jordangarcia avatar jordangarcia commented on August 29, 2024

Sure I can implement this to be a true isGetter check.

I was hesitant to do it at first since its a potentially expensive operation that will happen recursively.

@colindresj if you are planning to add these checks to your code I would wrap them in a flag that removes them in production code

from nuclear-js.

appsforartists avatar appsforartists commented on August 29, 2024

I can open a PR if you like. I hesitated because I didn't know if changing isGetter to be more complicated would be discouraged for perf reasons.

from nuclear-js.

colindresj avatar colindresj commented on August 29, 2024

Definitely @jordangarcia. I think this kind of approach is useful in dev, where you don't care about perf.

In the future, I actually think Nuclear should automatically turn this (and other dev-only helpers) off when in production, kind of like React does with PropTypes, et al. That means updating how Nuclear config is currently handled though, so definitely a different issue entirely, and for now devs should take care of this themselves.

from nuclear-js.

jordangarcia avatar jordangarcia commented on August 29, 2024

@colindresj yeah its something i've been thinking about

as to having a nuclear.js or nuclear-debug.js be the version with the __DEV__ flag on and also having invariant checks like isGetter.

I like the idea of keeping the dispatch logs in the code as something that can be configured when you instantiate a Reactor. At optimizely we have a flag that turns debugging on in production which has been immensely helpful when debugging issues that have already made it to prod.

I want to think about this a bit more before we decide anything. I am currently leaning towards adding more invariant checks and then having the minified version remove them.

Also: the way npm's package.json main works is to point at the unminified version of Nuclear. I'd like to be able to allow people to use npm but get a version of Nuclear without the invariants. Anyone have ideas?

from nuclear-js.

appsforartists avatar appsforartists commented on August 29, 2024

@jordangarcia I think React has one version for npm, but has a const (NODE_ENV === "production") that determines whether or not the tests run. They presume that if you care about perf, you'll run it through Webpack and Uglify, which will strip the unreachable blocks.

from nuclear-js.

colindresj avatar colindresj commented on August 29, 2024

In addition, React has a set of npm-specific grunt tasks for building the unminified main file with the conditional checks that @appsforartists mentioned, as well as a dist folder which includes minified files for React, addons, etc. I really like the approach, because you can build the library agnostic of where it'll be hosted, then have specific tasks for publishing it to NPM, etc.

The directory that eventually hits NPM is here: https://github.com/facebook/react/tree/master/npm-react

And the tasks for generating the files that get put in the directory are here: https://github.com/facebook/react/blob/master/grunt/tasks/npm-react.js

There's a release task that eventually publishes React everywhere it needs to: https://github.com/facebook/react/blob/master/grunt/tasks/release.js

from nuclear-js.

jordangarcia avatar jordangarcia commented on August 29, 2024

I am a bit uncomfortable adding this stricter validation without having a good way to remove it, and that will require rethinking the __DEV__ approach.

Punting this to 1.1.x

from nuclear-js.

colindresj avatar colindresj commented on August 29, 2024

I think that makes sense. I'd like to have I strong isGetter method, but think a strong approach to dev builds is even more important.

On Thu, Jun 4, 2015 at 1:42 PM, Jordan Garcia [email protected]
wrote:

I am a bit uncomfortable adding this stricter validation without having a good way to remove it, and that will require rethinking the __DEV__ approach.

Punting this to 1.1.x

Reply to this email directly or view it on GitHub:
#59 (comment)

from nuclear-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.