Giter Club home page Giter Club logo

Comments (9)

isaacs avatar isaacs commented on August 16, 2024

Why is clojure compiler complaining about these things?

Using the typeof operator on a undefined reference is safe. Setting a variable without var defines it as a global, which is also valid JavaScript.

This is a bug in clojure.

from node-semver.

isaacs avatar isaacs commented on August 16, 2024

Also, if you're using browserify, then it's wrong -- exports and module WILL be defined when this script is run.

from node-semver.

matthew-andrews avatar matthew-andrews commented on August 16, 2024

Thanks for your quick reply @isaacs.

I'm sorry I took a shortcut and the output above was inaccurate:

Also, if you're using browserify, then it's wrong -- exports and module WILL be defined when this script is run.

You're right - those two will be defined - but semver is not.

The error thrown during closure compiling the browserified script was actually just ERROR - variable semver is undeclared semver = {}.

The previous output was got using Google Closure Compiler on the whole browser bundle (which in retrospect was not a fair test). Apologies for the confusion.

from node-semver.

isaacs avatar isaacs commented on August 16, 2024

Well... look at the code. It's only going to assign to the semver global if module and exports are undefined. And if they are undefined, then it's not "leaking" a global, it's intentionally setting a very specific global.

So, this is still a case of clojure being either overly zealous or misconfigured.

from node-semver.

isaacs avatar isaacs commented on August 16, 2024

Sorry, I misspoke, it'll set semver = {} if both exports and define are unset. It sniffs module.exports to determine whether it's in a Node-like system or simply a CommonJS-like system.

from node-semver.

matthew-andrews avatar matthew-andrews commented on August 16, 2024

Ok I think this is just a case of different opinions of coding style. Thanks for your time in going through this with me and explaining it in detail. I have a workaround - and I will discuss with my colleagues about whether we should reduce the enthusiasm of our current Google Closure Compiler settings. Thank you again.

from node-semver.

isaacs avatar isaacs commented on August 16, 2024

Oh, I just realized, if it's getting tripped up by the code style of putting semver = {} on a new line, I'd be happy to accept a patch to shuffle things around so that clojure will be happy. But it should be posted as a bug upstream.

from node-semver.

matthew-andrews avatar matthew-andrews commented on August 16, 2024

I will investigate this and get back to you.

Thanks for your advice.

from node-semver.

tomByrer avatar tomByrer commented on August 16, 2024

@matthew-andrews Did you ever find a work-around please?

from node-semver.

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.