Should process/browser.js be included in build due to require('jquery')?
See original GitHub issueDescription
Coincidence caused me to notice that the Node.js process/browser module is included in my brunch build. I have isolated it to use of jquery, though I see no request for “process” anywhere. Running “brunch b” puts a copy in public/app.js and also inserts the following right around the end of the file:
require.alias(“process/browser.js”, “process”);process = require(‘process’);
Is inclusion of “process” correct behavior by brunch, or at least to be expected? This does not seem right to me, but I am new to brunch, so it makes me wonder if I am doing something wrong.
Here is information about my test case:
Environment
- Brunch: 2.8.2
- Node: 6.5.0
- NPM: 3.10.3
- Operating system: Debian/jessie
package.json contents
{
"name": "brunch-app",
"description": "Description",
"author": "Your Name",
"version": "0.1.0",
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"start": "brunch watch --server",
"build": "brunch build --production"
},
"dependencies": {
"jquery": "^3.1.0"
},
"devDependencies": {
"brunch": "^2.0.0",
"javascript-brunch": "^2.0.0",
"css-brunch": "^2.0.0",
"uglify-js-brunch": "^2.0.0",
"clean-css-brunch": "^2.0.0",
"auto-reload-brunch": "^2.0.0"
}
}
brunch-config.js contents
exports.files = {
javascripts: {joinTo: 'app.js'},
stylesheets: {joinTo: 'app.css'},
templates: {joinTo: 'app.js'}
};
app/initialize.js contents
// Test inclusion of jquery in the project:
var jq = require('jquery');
document.addEventListener('DOMContentLoaded', function() {
// do your setup here
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Node-style require for in-browser javascript? - Stack Overflow
Require -stub — provides node-compliant require in browser, resolves both modules and relative paths. Uses technic similar to TKRequire (XMLHttpRequest).
Read more >An Introduction to jQuery | DigitalOcean
This guide will take you through the JavaScript jQuery library by covering how to install jQuery in a web project; the definitions of ......
Read more >Handling common JavaScript problems - MDN Web Docs
The trouble with JavaScript This is one of the main reasons why libraries like jQuery came into existence — to abstract away differences...
Read more >RequireJS - Quick Guide - Tutorialspoint
RequireJS - Overview. RequireJS is a JavaScript library and file loader which manages the dependencies between JavaScript files and in modular programming.
Read more >CoffeeScript
You can use any existing JavaScript library seamlessly from CoffeeScript (and ... Major new features in CoffeeScript 2 include async functions and JSX....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Umm, strangely when building on Win, the require(‘process’) is not added to the globals, only the alias.
Whereas on Linux, it does add it and caused the error.
So rather than ignore it, I just include process/browser.js with the concatenated jquery file.
this prevents the console error in the browser as it’s included in the first js file I request on my app.
@LMS007 adding
/node_modules\/process\/browser.js/
to ignored in conventions seems to have worked for me:this is my setup on Win 10