admin管理员组文章数量:1279147
In my Project I am using Browserify (programmatically with gulp). In my main javascript file I am requiring modules A and B. A is also using B. In the output of Browserify I can find the absolute path to module A.
The output looks like this:
!function t(n,o,r){function e(s,a){if(!o[s]){if(!n[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=o[s]={exports:{}};n[s][0].call(f.exports,function(t){var o=n[s][1][t];return e(o?o:t)},f,f.exports,t,n,o,r)}return o[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)e(r[s]);return e}({1:[…]
…
10:[function(t,n){n.exports=t(9)},{"/Applications/MAMP/htdocs/Projects/xyz/node_modules/moduleA/node_modules/moduleB/index.js":9}]},{},[1]);
Here is the relevant part of the gulpfile.js:
browserify(['./app/js/main.js'], {})
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('main.min.js'))
//convert from streaming to buffered vinyl file object
.pipe(buffer())
// Start piping stream to tasks!
.pipe(gulp.dest('app/js/'));
How can I avoid this? I already tried several options of Browserify but it did not help. Side note: The two modules are being installed through npm but from GitHub because they are not published on npm.
In my Project I am using Browserify (programmatically with gulp). In my main javascript file I am requiring modules A and B. A is also using B. In the output of Browserify I can find the absolute path to module A.
The output looks like this:
!function t(n,o,r){function e(s,a){if(!o[s]){if(!n[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=o[s]={exports:{}};n[s][0].call(f.exports,function(t){var o=n[s][1][t];return e(o?o:t)},f,f.exports,t,n,o,r)}return o[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)e(r[s]);return e}({1:[…]
…
10:[function(t,n){n.exports=t(9)},{"/Applications/MAMP/htdocs/Projects/xyz/node_modules/moduleA/node_modules/moduleB/index.js":9}]},{},[1]);
Here is the relevant part of the gulpfile.js:
browserify(['./app/js/main.js'], {})
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('main.min.js'))
//convert from streaming to buffered vinyl file object
.pipe(buffer())
// Start piping stream to tasks!
.pipe(gulp.dest('app/js/'));
How can I avoid this? I already tried several options of Browserify but it did not help. Side note: The two modules are being installed through npm but from GitHub because they are not published on npm.
Share Improve this question asked Dec 1, 2014 at 11:34 ganggang 1,8202 gold badges24 silver badges37 bronze badges1 Answer
Reset to default 14You need to set fullPaths
to false
. For additional pression, have a look at bundle-collapser:
var collapse = require('bundle-collapser/plugin');
browserify(['./app/js/main.js'], { fullPaths: false })
.plugin(collapse)
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('main.min.js'))
//convert from streaming to buffered vinyl file object
.pipe(buffer())
// Start piping stream to tasks!
.pipe(gulp.dest('app/js/'));
Also worth noting that you don't need to buffer the contents, unless you're piping through to uglify or some other non-streaming patible transform.
本文标签: javascriptBrowserify – Avoid output of absolute pathsStack Overflow
版权声明:本文标题:javascript - Browserify – Avoid output of absolute paths - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741280698a2369989.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论