Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for browserify #55

Open
michael-lawrence opened this issue Aug 13, 2013 · 23 comments
Open

Add support for browserify #55

michael-lawrence opened this issue Aug 13, 2013 · 23 comments

Comments

@michael-lawrence
Copy link

First off, I have to say this looks amazing! The only thing I think it's really lacking is client-side JavaScript compilation and minification. I think browserify would be a match made in heaven! Any chance that we might see support for browserify added? Thanks!

@kennethormandy
Copy link
Collaborator

Hey @michael-lawrence,

JavaScript compression is planned: #54

I believe there’s a plan for compilation that wouldn’t involve Browserify. But just to make sure I understand the use case, you have a bunch of JavaScript files that you’d like reference using a single script tag?

@michael-lawrence
Copy link
Author

@kennethormandy Correct. The thing that makes browserify great is that it uses the CommonJS spec and npm modules. This makes it pretty easy to share code/modules between the server and client. Also, it allows you to specify a transform module that allows for some pretty cool stuff like precompiling handlebars or jade templates and bundling those templates in your single .js file.

@kevinsimper
Copy link

That would be cool to have in Harpjs, but how would you mark the file that it should be browserify?

main.bify would become main.js?

@michael-lawrence
Copy link
Author

You could just add a configuration option in the root harp.json. Something like browserify: ['app.js', 'main.js']. That way you don't have to have any special made up extensions. Alternately, you could do something like main.bundle.js and that could become main.js, so you just watch for .bundle.js files (or .bify.js files).

@kevinsimper
Copy link

I like the idea of that, if the file name features '.bundle.', it will be browerify.

@sintaxi
Copy link
Owner

sintaxi commented Aug 19, 2013

I like the idea of adding browserify support. Esp if it can be achieved through a convention rather than through configuration. We'll keep this issue open for exploring this feature.

@kevinsimper
Copy link

I can see that assets is processed with the module terraform which is broke out of Harpjs.

If you wanted to do it, how would you go around and implement browserify?

@sintaxi
Copy link
Owner

sintaxi commented Aug 20, 2013

@kevinsimper great to hear you want to chip in. I think browserify support is definitely worth exploring.

I would start by proposing a design that can be added to the Harp Spec for how browserify should work. My suggestion would be to put that in a gist or some place where we can iterate on the design.

Once we have a design that we feel aligns with the philosophy of the project then the next step would be to put this in a milestone and get you familiar with the terraform codebase. I would be happy to give you a walk through if you like. We then write some tests and come up with a plan of attack with the implementation.

If you have any other questions on how to move forward or want clarification on the design goals, come find me on #harp (irc.freenode.net).

@zeke
Copy link
Contributor

zeke commented Jan 24, 2014

Reviving this thread. @kevinsimper did you make any progress on this? I'm happy to help out if I can.

@zeke
Copy link
Contributor

zeke commented Jan 26, 2014

@sintaxi's above link to the spec is outdated. It now resides at spec.harp.io

@kennethormandy
Copy link
Collaborator

@zeke Fixed that, thanks.

@ncammarata
Copy link

Would also love to see this. Using Gulp now to get around not having it in Harp.

@kevinsimper
Copy link

I found a simpler solution and create a boilerplate, which can easily be used by saying harp init myblog -b kevinsimper/harp-browserify.

https://github.com/kevinsimper/harp-browserify

@zeke
Copy link
Contributor

zeke commented Aug 13, 2014

@kevinsimper this is a great interim option in the absence of first-class browserify support in Harp. Nice and minimal. Thanks for sharing.

@Prinzhorn
Copy link
Contributor

Do we even need a configuration or convention for this? Can't we serve all JavaScript through browserify? If the file doesn't contain any require statements, then it will just serve it (with some boilerplate). If it does, it resolves them. In both cases you only need to reference a single file, e.g. (main.js) in your HTML.

Or maybe add a flag to harp server and harp compile to enable/disable browserify. This way I could just throw in my modules and require them from my main.js and it just works. Oh well, this might be against the philosophy of harp. So maybe we should really just use a special name like *.require.js or *.bundle.js.

@sintaxi
Copy link
Owner

sintaxi commented Sep 23, 2014

@Prinzhorn indeed. we will have to figure out how this should work. I think you just described the optimal scenario. Thats what I'm hoping we can achieve. it should work identically with coffee-script.

@Prinzhorn
Copy link
Contributor

Following up my comment on live reload (#80 (comment)) I'm now doing this

watchify index.js -o bundle.js

in combination with

browser-sync start --proxy 'localhost:9000' --files 'bundle.js'

and I'm happy with it :)

I'm not saying integrating it into harp would be a bad thing, but this way I know exactly what everything is doing.

@amitkeret
Copy link

+1 for @Prinzhorn's comment.
I love not having to compile files for harp, would be even better if I don't need to package!

It's been almost a year... any progress?

@dgautsch
Copy link

dgautsch commented Aug 23, 2016

Reviving this from the dead, has there been any movement on this feature? Or does this has to be implemented in terraform?

EDIT: I see terraform has an open request for this sintaxi/terraform#97

@howardroark
Copy link

I would very much like to see it happen.

@DubaniWarrior
Copy link

trying to revive it in 2018. Has any progress being made on that?

@sintaxi
Copy link
Owner

sintaxi commented Nov 15, 2018

This has been implemented but not announced. Add a bundle.cjs file to the root of your project and it will create a bundle.js file. Let me know how it goes.

@DubaniWarrior
Copy link

does it work with harp being install globally. because It doesn't seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests