browserify

How to keep Browserify bundle size sensible when using requires for thirdparty stuff (via grunt if it matters)

血红的双手。 提交于 2019-12-09 12:46:34
问题 I'm trying to bundle up my own code (A) which in turn uses 2 third party components (B and C) where C also needs B. Everything as far as I know is written using CommonJS node style modules. A on its own when bundled comes out at 60K. B is included separately and assumed to be global, I've got this working just fine by doing a dirty bit of a replace in my build step that swaps out require("B") with global.B C is whats causing me issues though, its meant to be "just 8K" in size yet when I try

Require jsx files without specifying extension

房东的猫 提交于 2019-12-08 23:22:49
问题 I am using browserify and watchify , and would like to require() files other than the default extensions .js and .json without specifying the extension, for instance: // Not ideal (tedious) var Carousel = require('./components/Carousel/Carousel.jsx') // Ideal var Carousel = require('./components/Carousel/Carousel') I have tried --extension=EXTENSION as specified in the browserify documentation: "scripts": { "build": "browserify ./src/App.js --transform [ reactify --es6 ] > dist/script.js -v

How to set process.env before a browserified script is run?

非 Y 不嫁゛ 提交于 2019-12-08 17:06:02
问题 The initial html comes from the back-end. The server has a defined process.env.NODE_ENV (as well as other environment variables). The browserified code is built once and runs on multiple environments ( staging , production , etc.), so it isn't possible to inline the environment variables into the browserified script (via envify for example). I'd like to be able to write out the environment variables in the rendered html and for browserified code to use those variables. Is that possible? Here

Yarn Workspaces and Browserify - package.json in subfolder breaks the build

僤鯓⒐⒋嵵緔 提交于 2019-12-08 16:37:31
问题 My ultimate goal is to use Yarn Workspaces in a project using Browserify and Babel 7. This is a minimal reproduction of a problem I'm having. Basically it seems that the presence of a package.json file in a subfolder (which is one of the things that you have when using Yarn Workspaces) breaks my Browserify build, and I can't figure out why. Here's a GitHub repo with a minimal reproduction of the problem. First, install the dependencies (you can use yarn or npm, doesn't matter): $ npm install

PostgreSQL connection via javascript

送分小仙女□ 提交于 2019-12-08 13:39:14
问题 I am searching for a way to connect to postgresql directly in the browser. Im trying to utilize nodejs and browserify but have had no luck so far with the bundling. Whenever I compile a script that contains a require('pg') it specifically states in the browser: Cannot find module '/node_modules/pg/lib/client' the browser tells me afterwards that he is not able to find the modules that pg requires. Maybe i need to bundle pg with browserify before ? I appreciate if somebody has an idea on how

How to browserify a Node.js WebSocket server?

谁说我不能喝 提交于 2019-12-08 09:09:33
问题 Using examples from node-chromify I managed to run a Node.js Http server on a client side - inside a Chrome browser. Then I tried to do exactly the same with a WebSocket server. Unfortunately I failed. I think I tried most of the popular WebSocket libraries (npm modules) from Github. While they work fine in configurations: (a) both a WebSocket server and a WebSocket client are started from a Node command line (b) the server runs from the command line and the client is included as a JavaScript

browserify Error : http.createServer is not a function

若如初见. 提交于 2019-12-08 07:26:55
问题 I tried to browserify this node js script : var phantom = require('phantom') phantom.create(function(ph) { ph.createPage(function(page) { page.open("editor.html", function(status) { console.log("opened diagram? ", status); page.evaluate(function() { return document.getElementById("GraphImage").src; }, function(result) { //console.log(result); ph.exit(); }); }); }); }); So I used this command: browserify myscript.js > bundle.js and when I run bundle.js from an html file I get this error: http

npm i and npm update breaking gulp, browserify builds

老子叫甜甜 提交于 2019-12-08 03:58:09
问题 What were you expecting to happen? Gulp to transpile vue.js components into usable and functional JS. What actually happened? When I run gulp contacts (shown under the Code and Configuration section below), the transpiling runs fine. No errors are outputted in the terminal, and everything appears to complete successfully. The problem is, when the page is reloaded I have an error in the console stating Uncaught SyntaxError: Unexpected end of input . When looking at the source, devtools shows

browserify & factor-bundle dependency ids

青春壹個敷衍的年華 提交于 2019-12-07 19:44:42
问题 I'm using browserify and factor-bundle to manage dependencies, and in theory it should work great. We have different endpoints across pages, and running factor-bundle splits really quickly and efficiently for caching. The problem is that I'm running into this issue: https://github.com/substack/factor-bundle/issues/13 Unless there's a workaround, this appears to make factor-bundle completely useless until the issue is fixed. Is there a way to split off common dependencies manually in the

Browserify multiple files into a single bundle

若如初见. 提交于 2019-12-07 16:07:13
问题 Currently, I browserify a single js file into a bundle.js $ browserify X1.js --standalone XXX > bundle.js What if I have multiple js files and want to join them into a single browserified bundle.js How should the command look like? Can I do something like this? $ browserify X1.js X2.js --standalone XXX > bundle.js I am using node.js v6 回答1: You have already answered your own question. I confirm that it is correct. $ browserify X1.js X2.js --standalone XXX > bundle.js 来源: https://stackoverflow