From a8c13a436bb2f7e60f92911fb99b2db3a1475d0d Mon Sep 17 00:00:00 2001 From: Jared Allard Date: Tue, 23 Feb 2016 23:14:57 -0800 Subject: [PATCH] bundle: browserify.paths for controling require paths from nexe --- README.md | 48 ++++++++++++++++++++++++++++++++- lib/bundle.js | 8 +++++- lib/exe.js | 41 +++++++++++++++------------- test/embeded-files/package.json | 11 ++------ 4 files changed, 78 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index a21040d..c576f4c 100644 --- a/README.md +++ b/README.md @@ -165,9 +165,14 @@ is still in works, so it is likely to change. "input": "./bin/nexe", "output": "nexe^$", "temp": "src", + "browserify": { + "requires": [], + "excludes": [], + "paths": [] + }, "runtime": { "framework": "node", - "version": "5.5.0", + "version": "5.6.0", "js-flags": "--use_strict", "ignoreFlags": true } @@ -179,6 +184,47 @@ Notes: * output: can use ^$ for platform specific file extension * js-flags: this is also known as v8 flags, and supports *all* v8 flags. +### Browserify Require Issues + +If you have requires that aren't resolving well, you can do two things. + +Try adding it to `nexe.browserify.requires` in your `package.json` + +```json +"nexe": { + ....... + "browserify": { + "requires": [ + { + "file": "myfile.js", + "expose": "mymodule" + }, + "mymodule.js" + ], + "excludes": [], + "paths": [] + }, + ....... +} +``` + +Or, if that doesn't work (it tends to not work sometimes), you can try altering +browserify.paths like so: + +```json +"nexe": { + ....... + "browserify": { + "requires": [] + "excludes": [], + "paths": ["/path/to/my/loc"] + }, + ....... +} +``` + +If it *still* doesn't work, file a bug with what you tried! (also try using `nexe@0.4.2`) + ## Maintainers * __Jared Allard__ ([@jaredallard](https://github.com/jaredallard)) <[jaredallard@outlook.com](mailto:jaredallard@outlook.com)> (Active) diff --git a/lib/bundle.js b/lib/bundle.js index 83a376d..a5d4725 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -60,12 +60,18 @@ function bundle(input, nc, options, complete) { } }); + let paths = [path.join(nc, 'lib')]; + + if(options.browserifyPaths) { + paths = paths.concat(options.browserifyPaths); + } + _log('executing browserify via API'); let bproc = browserify([input], { debug: options.debug, commondir: false, - paths: [path.join(nc, 'lib')], + paths: paths, builtins: false, insertGlobalVars: insertGlobalVars, detectGlobals: true, diff --git a/lib/exe.js b/lib/exe.js index 138c586..4f3c25f 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -25,30 +25,31 @@ 'use strict'; -var async = require("async"), - outcome = require("outcome"), - mkdirp = require("mkdirp"), - request = require("request"), - gunzip = require("gunzip-maybe"), - path = require("path"), - fs = require("fs"), +const async = require("async"), + outcome = require("outcome"), + mkdirp = require("mkdirp"), + request = require("request"), + gunzip = require("gunzip-maybe"), + path = require("path"), + fs = require("fs"), tarstream = require('tar-stream'), - colors = require('colors'), - ncp = require("ncp").ncp, + colors = require('colors'), + ncp = require("ncp").ncp, ProgressBar = require("progress"), child_process = require("child_process"), - glob = require("glob"), - bundle = require("./bundle"), - embed = require("./embed"), - os = require("os"), - _log = require("./log"), + glob = require("glob"), + bundle = require("./bundle"), + embed = require("./embed"), + os = require("os"), + _log = require("./log"), _monkeypatch = require("./monkeypatch"), - spawn = child_process.spawn; + spawn = child_process.spawn; -var isWin = /^win/.test(process.platform); -var isPy; -var framework; -var version; +const isWin = /^win/.test(process.platform); + +let isPy, + framework, + version; /** * Compiliation process. @@ -979,9 +980,11 @@ exports.package = function(path, options) { framework: (_package.nexe.runtime.framework || options.f) } + // browserify options if(_package.nexe.browserify !== undefined) { obj.browserifyRequires = (_package.nexe.browserify.requires || []); obj.browserifyExcludes = (_package.nexe.browserify.excludes || []); + obj.browserifyPaths = (_package.nexe.browserify.paths || []); } Object.keys(_package.nexe).forEach(function(v, i) { diff --git a/test/embeded-files/package.json b/test/embeded-files/package.json index 2556564..886b86f 100644 --- a/test/embeded-files/package.json +++ b/test/embeded-files/package.json @@ -14,15 +14,8 @@ "hw.txt" ], "browserify": { - "excludes": [ - "./process" - ], - "requires": [ - { - "file": "nexeres", - "expose": "nexeres" - } - ] + "excludes": [], + "requires": [] }, "temp": "src", "debug": false,