Closed mfursov closed 8 years ago
Can you provide your shim config please?
Here is snippet from my package.json:
"browserify-shim": {
"jquery": "global:$"
},
"browserify": {
"transform": [
"browserify-shim"
]
}
I tried to add "deps" & "exports" section like it shown here but it also does not work: jquery is included anyway. Tried both 'parsley' & 'parsleyjs' module names.
http://w3javascript.com/question/make-parsley-js-work-with-require-js/
Adding
.transform('browserify-shim', {global: true})
to my gulpfile.js solves the problem: no more jquery is embedded. Looks like I missed some documentation how to set this flag in package.json without use of gulp.
Complete gulp pipeline:
gulp.task('build', function () {
return browserify('./src/site.js')
.transform(partialify)
.transform('browserify-shim', {global: true})
.bundle()
.pipe(source('site.js'))
.pipe(gulp.dest('./package/js/'));
});
how to set this flag in package.json
You can't. Running transforms on your npm dependencies based on a package flag is not something browserify supports/will support. Think of it this way: package flags are things that are essential to run your package itself, e.g. using babelify to convert ES6 to ES5.
If you want to do transforms like uglifying or shimming to your dependencies, you can only use the API.
Here is a first line from ParsleyJS (v2.2.0-rc4)
The "require('jquery')" is not processed by shim module, and as the result 'jquery' sources are always included into the final bundle by browserify.