简体   繁体   English

寻找有关将Parceljs与Backbone.js结合使用的建议

[英]Looking for advice on using Parceljs with Backbone.js

I have a number of new and existing projects which use Require.js to manage dependencies. 我有许多使用Require.js来管理依赖项的新项目和现有项目。 I am intrigued by the simplicity of Parceljs and would like to test it on a few smaller projects. 我对Parceljs的简单性很感兴趣,并希望在一些较小的项目中对其进行测试。

I am unsure, however, how to indicate dependencies in my code. 但是,我不确定如何指示代码中的依赖关系。 Using a simple require statement like this: 使用这样的简单require语句:

// Import our view
var AppView = require('./app.view');

would correspond with some examples I have seen. 与我见过的一些例子相对应。 Is that congruent with the Parcel design philosophy? 这与包裹设计理念完全一致吗? It sure is simpler than maintaining Require.js config files but I would prefer to get this right the first time. 它肯定比维护Require.js配置文件简单,但我希望第一次正确。

My primary concern with using require statements is that it is not a comprehensive approach. 我对使用require语句的主要担心是,这不是一种全面的方法。 Calling a module via the router, for example, would likely fail as the dependency to the module JavaScript file would be unknown. 例如,通过路由器调用模块可能会失败,因为对模块JavaScript文件的依赖关系将是未知的。 An alternative would be to add require statements in the router for every module but that seems to go against the Parcel design philosophy from what I can determine. 一种替代方法是在路由器中为每个模块添加require语句,但这似乎与我可以确定的Parcel设计理念背道而驰。

I was hoping for some guidance from the gurus but I realise Backbone.js is a bit passe these days. 我希望从专家那里获得一些指导,但是我知道Backbone.js如今已经过时了。

I have decided the best course forward for these projects is to use ES2015 modules, Babel for transpiling, and Parcel. 我已决定这些项目的最佳前进方向是使用ES2015模块,Babel进行转堆和Parcel。 I ran a few tests and it appears that Parcel can replace Browserify for this purpose. 我进行了一些测试,看来Parcel可以代替Browserify来实现此目的。

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

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