简体   繁体   English

将broccoliJS与当前使用requireJS的模块化骨干应用程序一起使用,我想完全删除requireJS

[英]Using broccoliJS with a currently modular backbone app that uses requireJS, and I want to drop requireJS altogether

I have been scouring the internet to figure this out, and i'm here as a last resort. 我一直在搜寻互联网来解决这个问题,而我在这里是最后的选择。 I have a backbone application that was started using requireJS, as many do. 我有一个像许多人一样开始使用requireJS的主干应用程序。 However, I have recently been introduced to broccoliJS to wrap up all my backbone views/models/collections. 但是,最近向我介绍了broccoliJS,以包装我所有的主干视图/模型/集合。

One problem that I forsee is that my app is modular, the models have their own directories, so do views, etc - and it's all well and good if broccoli concats and minifies my js, but i'm going to spend a ton of time specifying which files go in which order in my Brocfile so I don't end up with a completely broken app. 我预见到的一个问题是我的应用程序是模块化的,模型具有自己的目录,视图也是如此,并且-如果花椰菜结合并缩小我的js效果很好,但是我要花很多时间指定哪些文件按我的Brocfile中的顺序排列,这样我就不会遇到一个完全损坏的应用程序。

There has to be a better way? 一定有更好的方法? Like I said in the title, i'm currently using requireJS but I've heard that I can use es6 features to modularize and it works incredible with broccoliJS, and if there is a way to do this, I'd like to drop requireJS altogether. 就像我在标题中说的那样,我目前正在使用requireJS,但我听说我可以使用es6功能进行模块化,并且与broccoliJS配合使用时效果非常好,如果有做到这一点的方法,我想删除requireJS共。

Can anyone shed some light on this for me? 谁能为我阐明一下?

Broccoli and Require aren't mutually exclusive. 西兰花和Require并非互斥。 You should use Broccoli to concat and minify your code and continue using Require to ensure dependencies are loaded properly. 您应该使用Broccoli合并并缩小代码,然后继续使用Require以确保正确加载依赖项。 You could switch to another AMD-type solution, but I think Require should work for you. 您可以切换到另一个AMD型解决方案,但我认为Require应该可以为您工作。

If you want to use ES6, then incorporate Babel into your Broccoli pipeline. 如果要使用ES6,则将Babel集成到Broccoli管道中。 It transpiles your ES6 modules into AMD modules. 它将ES6模块转换为AMD模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM