Well, you wouldn't. What you would do instead is leverage require
's to the child files, or es6 harmony Import/Exports
. Like so:
Using module.export syntax:
index.js
const fs = require('fs')
/*...Other Imports...*/
// Get access to messages data
const callbacks = require('./messages')
messages.js
const fs = require('fs')
/* Setup Callbacks */
module.exports = callbacks
The Harmony Way:
index.js
import fs from 'fs'
/*...Other Imports...*/
// Get access to messages data
import {callbacks, variable1, closure2} from './messages'
messages.js
import fs from 'fs'
/* Setup Callbacks */
export {callbacks, personalClosure as closure2, variable1}
Note: You will require babel to run this code (harmony import/export
) since it's not fully suported yet [As of 3/2017]