I am using browserify with CommonJs.
I have file 2 with this structure.
module.exports = { value: 'bling bling' }; I have file 1 with this structure.
var file2 = require('./file2.js'); console.log('this is the file 2 object value', file2.value); So I run the following command in my terminal
$ browserify -g uglifyify ./file1.js | uglifyjs -c > bundle.js The bundle result would be.
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var file2=require("./file2.js");console.log("this is the file 2 object value",file2.value)},{"./file2.js":2}],2:[function(require,module,exports){module.exports={value:"bling bling"}},{}]},{},[1]); I was wondering if there is any chance to get a different result for my bundle file with any transformation in order to get the following.
var file2 = { value: 'bling bling' }; console.log('this is the file 2 object value', file2.value); I just want my code in the final result without any extra coding of browserify or webpack or requirejs, may be I am just using the tool incorrectly, but this always happens to me when using each of this tools.
Some of this tools produce more or less coding, but I could not figure it out how to remove this extra code.