Giter Site home page Giter Site logo

Comments (14)

jonathanong avatar jonathanong commented on June 7, 2024

@defunctzombie @TooTallNate browserify masters, how to best handle this? are we still doing try/catch's?

from clone.

TooTallNate avatar TooTallNate commented on June 7, 2024

Well my solution is add-component-symlinks, to fix the npm vs. component "require" name discrepancy.

The try/catches must not be in place in order to work with browserify.

from clone.

defunctzombie avatar defunctzombie commented on June 7, 2024

The following setup should work with node, browserify, and component.

Assume package.json is published as foobar-component and component.json is foobar

try {
   var module = require('foobar-component');
}
catch() {
   var module = require('foobar');
}

Package.json needs to have the following

"browser": {
    "foobar": "foobar-component"
}

This will allow browserify to not bork on the foobar require (since it tries to resolve at build time). And it will allow node to work because it will find foobar-component via normal node_modules lookup.

If you don't need to support node and just want to support component and browserify, the js is simpler.

var module = require('foobar');

Hope that helps clear up how to support all three environments.

from clone.

TooTallNate avatar TooTallNate commented on June 7, 2024

Huh... hacky, but clever. I wish there was a way to avoid all the try/catching in the actual script file though :( (ya, I like when they work in node as well. all 3)

from clone.

rauchg avatar rauchg commented on June 7, 2024

Having try/catch all over the place is really painful :(

from clone.

jonathanong avatar jonathanong commented on June 7, 2024

changed it to component-type :D 0.2.1 it's also component-clone now.

from clone.

ntharim avatar ntharim commented on June 7, 2024

require('component-type') doesn't work for me using component. Why is that?

from clone.

jonathanong avatar jonathanong commented on June 7, 2024

gah it doens't work? is the current builder broken?

from clone.

ntharim avatar ntharim commented on June 7, 2024

doesn't work with 0.10.x. I haven't tried 0.12.0 or builder2 so I don't know about those ones.

from clone.

jonathanong avatar jonathanong commented on June 7, 2024

k i'll change it

from clone.

jonathanong avatar jonathanong commented on June 7, 2024

man but i don't want to. all the solutions are ugly

from clone.

defunctzombie avatar defunctzombie commented on June 7, 2024

this is what happens when you create two package managers and one of them doesn't have namespaces.

Reality.

from clone.

lvivier avatar lvivier commented on June 7, 2024

+1 to reality, I got bit by this today (also [email protected]) :(

from clone.

jonathanong avatar jonathanong commented on June 7, 2024

k pushed again -___-

from clone.

Related Issues (4)

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.