I am learning browserify and I am trying to do two basic things with it: Transform (via shim) non-CommonJS modules for ease-of-use and dependency tracking Bundle the libraries that are project-specific I've found a working process for how to do all of this and automate it with Gulp. This works and produces the right output but, I am curious if it could be made simpler. It seems like I
我正在学习browserify,我正在尝试用它做两件基本的事情: 转换(通过填充)非CommonJS模块,以实现易用性和依赖性跟踪 捆绑项目特定的库 我发现了一个如何完成这些工作的流程,并通过Gulp将其自动化。 这工作,并产生正确的输出,但我很好奇,如果它可以变得更简单。 看来我必须在基于项目的捆绑包上复制大量的配置。 这是一个工作示例: 的package.json 无效评论添加澄清 { //project info and dependencies
I am relatively new to front-end development, and have a question about using Gulp and Browserify together. Here is a description of my setup: I have a project folder that contains everything related to my project (css, html, js, etc.) In my javascript directory, I have a sub-directory named "modules" which contains, say, three sub-directories of its own: A, B, and C. Each of these th
我对前端开发比较陌生,并且对将Gulp和Browserify一起使用有疑问。 这里是我的设置的描述:我有一个项目文件夹,其中包含与我的项目(CSS,HTML,JS等)相关的一切。在我的javascript目录中,我有一个名为“modules”的子目录,它自己的三个子目录:A,B和C.这三个子目录中的每一个都包含任意数量的js文件。 以子目录A为例, 它可能包含js文件1.js,2.js和3.js. 其中每一个都可以导入(使用Browserify识别的'require'
I have recently learnt gulp and scripted this gulp script on my local computer, so that it can watch for any changes, and compile my javascripts (in this case, ./js/main.js with its dependencies) into a single file ./js/bundle.js : var gulp = require('gulp'); // Plugins var jshint = require('gulp-jshint'); var browserify = require('gulp-browserify'); var rename = require('gulp-rename'); // Lint
我最近学习了gulp并在本地计算机上编写了这个gulp脚本,以便它可以监视任何更改,并将我的javascript(在本例中为./js/main.js及其依赖项)编译为单个文件./js/bundle.js : var gulp = require('gulp'); // Plugins var jshint = require('gulp-jshint'); var browserify = require('gulp-browserify'); var rename = require('gulp-rename'); // Lint Task gulp.task('lint', function() { return gulp.src(['./js/**/*.js'
we are in the process of uplifting parts of a huge code base. We are bringing in a module which has been built with webpack. In order to avoid code duplication we have used webpacks externals option. When we start to integrate our module into the main codebase which is currently using browserify, we have an issue where a shared dependency is included twice and causes issues. Is there are a
我们正在提升庞大代码库中的部分代码。 我们正在引入一个使用webpack构建的模块。 为了避免代码重复,我们使用了webpack的外部选项。 当我们开始将我们的模块集成到当前正在使用browserify的主代码库中时,我们遇到了一个问题,即共享依赖包含两次并导致问题。 有没有办法让webpack使用打包版本的依赖关系? 那么在最终的browserified bundle中,我们只需要包含一个依赖项? 在我看来,这似乎是不可能的,如果是的话,
I have several js modules that I bundle with browserify in gulp: gulp.task('build:js', ['clean:js'], function () { browserify({ debug: true, entries: paths.js.src }) .transform('babelify', { presets: ['es2015'] }) .bundle() .pipe(source('bundle.js')) .pipe(buffer()) .pipe(gulp.dest(paths.js.dist)); }); It outputs a single bundle.js . However, when bundled like t
我有几个js模块,我将它们与browserify捆绑在一起: gulp.task('build:js', ['clean:js'], function () { browserify({ debug: true, entries: paths.js.src }) .transform('babelify', { presets: ['es2015'] }) .bundle() .pipe(source('bundle.js')) .pipe(buffer()) .pipe(gulp.dest(paths.js.dist)); }); 它输出一个bundle.js 。 但是,像这样捆绑时,我require浏览器中的单个模块。
(I should clarify up front: My question is about closures and client module patterns in Javascript. It's not about how to use jQuery.noConflict().) I've got a bit of Javascript that people can add to their websites. I want my own code to have access to a $ variable which resolves to a specific version of jQuery that's independent of whatever the page has loaded. This is easy if al
(我应该先澄清一下:我的问题是关于Javascript中的闭包和客户端模块模式,而不是如何使用jQuery.noConflict()。) 我有一些Javascript可以添加到他们的网站。 我希望我自己的代码能够访问$ variable,这个变量可以解析为独立于页面加载的jQuery的特定版本。 如果我所有的代码位于我定义的闭包内的单个文件中,这很容易。 但我正在努力寻找一种干净的方式来使用模块模式来完成此操作,其中我的代码位于单独的闭包中。
/foo /bar.js /foobar.js /index.js In node.js if you a require a directory (require('foo')), it would look into that directory and find an index.js file and return whatever exports I have in that file, so I can just bundle up the contents of the directory in an index.js file. Therefore, I dont have to require bar and foobar separately if index.js already includes them. However thi
/foo /bar.js /foobar.js /index.js 在node.js中,如果你需要一个目录(require('foo')),它会查看那个目录并找到一个index.js文件,并返回我在该文件中的任何导出,所以我可以将这些内容打包index.js文件中的目录。 因此,如果index.js已经包含它们,我不必单独要求bar和foobar。 但是,这种方法不适用于browserify。 似乎只有浏览器能够理解的是相对路径。 /star /star.js /starfoo.js /index.js /
I have a very simple module that I am bundling with Browserify. I want to use that bundle both in the browser as well as in node. In node, it works just fine if I require the non-bundled module; however, if I require the browserified bundle, require returns an empty object. Here's a reproduction: Simple module function Foo(bar) { this.bar = bar; } module.exports = Foo; Test scrip
我有一个非常简单的模块,与Browserify捆绑在一起。 我想在浏览器和节点中都使用这个包。 在节点中,如果我require非捆绑模块,它工作得很好; 不过,如果我require browserified bundle, require返回一个空对象。 这是一个复制: 简单的模块 function Foo(bar) { this.bar = bar; } module.exports = Foo; 测试脚本 var Foo = require("./foo"); // not bundled with Browserify var Foob = require("./foob"); //
Given a crossfilter group that reduce to a key-value pair of something like: [ { key: A, value: 75 }, { key: B, value: 35 } ] (pie chart type data), how to you go about getting the sum of the values (110 in this case)? is there a quick xfilter method I am unable to find? Example Fiddle Here
给定一个交叉过滤组,可以将这个对象缩减为一个键值对: [ { key: A, value: 75 }, { key: B, value: 35 } ] (饼图类型数据),如何获取值的总和(本例中为110)? 有没有我无法找到的快速xfilter方法? 示例小提琴在这里
I am trying to create a rowchart in dc.js which displays the count of a person divided by the hours they worked on a given date. My data is organized as follows: Person Hours Date Joe 3 1-2-16 Joe 3 1-2-16 Devon 5 1-2-16 Devon 5 1-2-16 Joe 4 1-3-16 Devon 1 1-3-16 Devon 1 1-3-16 How do I create a custom reduce function whi
我正在尝试在dc.js中创建一个rowchart,它显示一个人的数量除以他们在给定日期工作的小时数。 我的数据组织如下: Person Hours Date Joe 3 1-2-16 Joe 3 1-2-16 Devon 5 1-2-16 Devon 5 1-2-16 Joe 4 1-3-16 Devon 1 1-3-16 Devon 1 1-3-16 如何创建一个自定义减少功能,可将人员列的计数(reduceCount)相加并将其除以特定日期范围的小时值?