Coder Social home page Coder Social logo

Leaking 'exports' into global about engine HOT 16 CLOSED

gss avatar gss commented on September 24, 2024
Leaking 'exports' into global

from engine.

Comments (16)

d4tocchini avatar d4tocchini commented on September 24, 2024

looks like an issue with Cassowary.js...

@bergie, maybe something with the component.io wrapper?

from engine.

adampilks avatar adampilks commented on September 24, 2024

Am finding this reoccurring with 1.0.0.rc1

We use requirejs for loading in js dependencies and GSS seems to conflict with the global require function.

from engine.

adampilks avatar adampilks commented on September 24, 2024

On 1.0.4-beta we can actually correctly load both GSS and requirejs as long as we load in GSS first and then let requirejs take over the global require variable. Not the case on 1.0.0.rc1 though.

from engine.

Inviz avatar Inviz commented on September 24, 2024

Rc provides require() shim to enable loading file-by-file. Cassowary provides logic to export global variable. I understand, that re-defining require function is a bad idea, and we try not to do it.

What would be the desired change? Avoid playing with require? or leaking cassowary global variable?

from engine.

paulyoung avatar paulyoung commented on September 24, 2024

Hopefully there's a way to avoid playing with require and not leak a global variable.

Could we use browserify (or their technique) so that require isn't globally scoped?

from engine.

Inviz avatar Inviz commented on September 24, 2024

require() leaking shouldnt be an issue as it seems to me, because everybody who's concerned about it already has it defined. Is it correct?

The idea is to move gss.js out of repo to avoid hundred-ish mb repo as we have now. We'll only have compiled js files separately in the git. We'll have some kind of includes.js which will include each file one by one to use in tests. require() shim will just return globals.

gss.js will be built separately and put on the cdn with a script, it will use browserify thus will not mess with require(), because it'll be predefined there

Current code is set to define a single global variable GSS when you include gss.js. Would you like me to add some sniffing so when you do require('gss') it will not define a global? Both in browserify & node?

from engine.

paulyoung avatar paulyoung commented on September 24, 2024

A nice advantage of browersify is not needing to compile intermediate files: https://github.com/substack/browserify-handbook#transforms

from engine.

paulyoung avatar paulyoung commented on September 24, 2024

Current code is set to define a single global variable GSS when you include gss.js. Would you like me to add some sniffing so when you do require('gss') it will not define a global? Both in browserify & node?

@Inviz - I created this repo to demonstrate how I think this would be taken care of by browserify: https://github.com/paulyoung/browserify-gss-demo

from engine.

Inviz avatar Inviz commented on September 24, 2024

Thanks for example. Latests code already doesnt do anything with require() but I still would like to be able to include GSS file by file and not have gss.js in the repo - i'll figure something out

from engine.

paulyoung avatar paulyoung commented on September 24, 2024

You should be able to do that based on my example. Just imagine that my demo project is responsible for only building gss.js and that GSS.coffee comes from the engine project.

from engine.

Inviz avatar Inviz commented on September 24, 2024

Though I think it plays against that other feature to update only a portion of a file on grunt watch, which would be even more desirable.

from engine.

adampilks avatar adampilks commented on September 24, 2024

I put together a very basic pen http://codepen.io/adampilks/pen/vExNZe that show the errors with requirejs. Requirejs introduces a globals of require and define which are conflicting with gss.

Is there a way to have these work side by side currently?

from engine.

paulyoung avatar paulyoung commented on September 24, 2024

This was addressed in acfae7d in case that's an option for you until it gets merged to master.

from engine.

paulyoung avatar paulyoung commented on September 24, 2024

Actually, the relevant commits are 8334f86 and 77e1a7e but it's all part of the move to browserify that exists on the queries branch.

from engine.

adampilks avatar adampilks commented on September 24, 2024

Great, we are in early development so will point our bower config to that branch for now.

from engine.

paulyoung avatar paulyoung commented on September 24, 2024

We tagged v2.0.0 which includes those commits.

from engine.

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.