Code Monkey home page Code Monkey logo

Comments (18)

zenorocha avatar zenorocha commented on June 14, 2024

What if we declare main to point to dist/clipboard.js? https://github.com/substack/browserify-handbook#browser-field /cc @mauriciosoares

from clipboard.js.

mauriciosoares avatar mauriciosoares commented on June 14, 2024

damn, this browser-field might do the trick

I was trying to point main directly to the dist file, but there was a lot of "require" errors in the terminal, since all the required files are already bundled in the dist file.

This might be a solution 👍

from clipboard.js.

mauriciosoares avatar mauriciosoares commented on June 14, 2024

@zenorocha, tested here with my lib, and I think that will actually work.

will you work on that?

so_good

from clipboard.js.

zenorocha avatar zenorocha commented on June 14, 2024

HAHAHAHAAH

Nope, can you test with Node and send a PR?

from clipboard.js.

mauriciosoares avatar mauriciosoares commented on June 14, 2024

Sure, I'll probably work on that tonight.

from clipboard.js.

mauriciosoares avatar mauriciosoares commented on June 14, 2024

Hey @zenorocha, just did a PR #19

I'll take a look in how I can improve the tests for requirejs and commonjs projects, in the meanwhile, this PR has tests for projects that uses browserify.

screen shot 2015-07-20 at 13 03 42

from clipboard.js.

zenorocha avatar zenorocha commented on June 14, 2024

@ibc it should be fixed as of https://github.com/zenorocha/clipboard.js/releases/tag/v1.3.1

Could you test and let us know?

from clipboard.js.

ibc avatar ibc commented on June 14, 2024

If I add the lib (master branch) into the package.json of my browserify based project, calling browserify on the project fails because babelify is required. It is included in the devDependencies of the lib, but those are not installed. babelify should be placed under dependencies. If so, it does work :)

from clipboard.js.

zenorocha avatar zenorocha commented on June 14, 2024

I moved to dependencies as requested ;)

from clipboard.js.

ibc avatar ibc commented on June 14, 2024

browserify does not need to be added into dependencies ;)

from clipboard.js.

ibc avatar ibc commented on June 14, 2024

I mean: is up to me whether I'm building a browserify based project or not. If so, when browserify "compiles" clipboard.js it will honor the "browserify" data in package.json, but browserify should not be placed in dependencies.

from clipboard.js.

zenorocha avatar zenorocha commented on June 14, 2024

But you can't run babelify without browserify. I'm confused.

from clipboard.js.

ibc avatar ibc commented on June 14, 2024

Example usecase:

  • I build a JS library named myApp.js intended for browser usage.
  • myApp.js is made using the Node's way (require('xxxx');, package.json, etc).
  • My deps are the node-debug module and clipboard.js (they are included in the dependencies field of my package.json).
  • myApp.js includes a Gruntfile or gulpfile with a browserify task to build the "browserified" library dist/myapp.js, so I add browserify into my devDependencies.

When I run my browserify task it takes the debug module and clipboard module. When browserifing clipboard browserify realizes that there is a browserify field in its package.json, so it honors those settings (in this case, it loads the babelify transform).

That's all. I won't use the browserify module within clipboard but the browserify module I set into my project's package.json. Hope it's clear now :)

from clipboard.js.

heldr avatar heldr commented on June 14, 2024

Uhm...one approach is to create a clipboard.transpiled.js into dist folder and point it in "browser" field(I can do this with a PR using babel compiler as dev dependencie).

Then neither browserify nor babelify would be a main dependency, and the install would turn faster on NPM 3. Not to mention webpack and jspm could reach this file as well without any transpiler required.

from clipboard.js.

heldr avatar heldr commented on June 14, 2024

However we have src/clipboard-action.js to be transpiled as well . Maybe create a folder dist/transpiled and point it in "browser" field. 😞

from clipboard.js.

heldr avatar heldr commented on June 14, 2024

Example: heldr@b041513

drawback: Babel's _classCallCheck is repeated twice

from clipboard.js.

zenorocha avatar zenorocha commented on June 14, 2024

Fixed in v1.5.3

from clipboard.js.

heldr avatar heldr commented on June 14, 2024

nice! 😎

from clipboard.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.