kenhkan / angular-templates-brunch

Wrap all templates in an AngularJS module for Brunch.IO
0 stars 6 forks source link

Is angular-templates-brunch only working with commonJs enabled? #6

Open AWolf81 opened 9 years ago

AWolf81 commented 9 years ago

In my brunch.config I have these lines:

modules:
    wrapper: false
    definition: false

Which deactivates any wrapping of my files and I need that because I'm using a jQuery library that's difficult to wrap into AMD/commonjs modules. So I decided to use globals for jQuery and Angular.

But it seems that angular-templates-brunch requires commonJS to work, is that right or am I doing something wrong? How can I make it work?

As a work-around I'm wrapping the data from preprocessor into a comment, so it can be extracted later.

Please have a look at this gist.

With-out my code addition im getting in the browser console. The error SyntaxError: expected expression, got '<'..

That's because the html text from the preprocessor gets directly inserted with-out any wrapping into the js file of the template.

kenhkan commented 9 years ago

If I remember correctly, it used to be the case it wouldn't work unless it's CommonJS. Then again, it was when AngularJS was a baby. Do you want to make a PR that would make it jQuery-compatible without breaking CommonJS support?

AWolf81 commented 9 years ago

Sorry, for my late response. At the moment I'm trying different build tools and brunch was the first one and now I'm testing webpack. So I'm still not sure what I'll use in the future but right now my favourite is webpack.

So I don't want to make a PR. Maybe later. But if you like my idea of the comment approach and it doesn't break anything. You're welcome to add it and maybe it helps other people.

kenhkan commented 9 years ago

To be completely honest, I have grown to believe that angular is the wrong approach to web development and brunch unfortunately has already lost the "build tool" war. By the way, "build tool" is usually how most describe brunch but it's definitely much comprehensive than a build tool (e.g. grunt and gulp). I would categorize brunch as an asset pipeline.

Anyway, given that this space is now fairly mature and it's fairly clear who the winners are, I'm not investing more time into brunch. If you decide that this would be the route to take, please let me know. I'd be delighted to have someone benefit from and manage this repo.

AWolf81 commented 9 years ago

Why is angular the wrong approach for web development? What do you use instead to make a web app?

Who's the winner of the "build tool" war? What do you think? I'm still not really sure what to use.

Yes, I think you're right not to invest more time into brunch. Brunch is a good tool but there are others that are in my opinion better (e.g. webpack).

kenhkan commented 9 years ago

Why is angular the wrong approach for web development? What do you use instead to make a web app?

Angular's paradigm is basically just a two-way binding paradigm, which is really problematic when you're dealing with complex applications, where you would have state all over the place changing almost unpredictably (given sufficient problem domain complexity of course) due to the two way communication.

I personally use something like Elm but any reactive framework is better than one with bindings.

Who's the winner of the "build tool" war? What do you think? I'm still not really sure what to use.

Yes, I think you're right not to invest more time into brunch. Brunch is a good tool but there are others that are in my opinion better (e.g. webpack).

Well, I can't really compare brunch vs webpack. Brunch is more of an asset pipeline whereas webpack is more of a package manager. Apple and orange.

When it comes to built tool, Grunt basically had it. Gulp is kind of a contender but you can basically get things done really quickly with Grunt. I'm not advocating for it, but I think it's clear that a "polyglot" setup where you can pick and choose has proven to be superior to a one-size-fit-all approach like brunch.