I have a growing app.js file.This file requires other 3rd-party modules for example 'logger', 'puppeteer',' moment'I want to split a function that was part of the app.js into separate module file so I replace the function in the app.js with:const {scBase} = require('./scBasefile')putmodule.exports.scBase = (resultData, siteURL) { // long function that needs 'logger', 'puppeteer',' moment' } into scBasefile.js filebut how to make this module use the modules from the app.js file?In the tutorials the modules that are required are just repeated in the scBasefile.js but that seams wrong and redundant.I don't want to create new const that requires 'puppeteer' - I want to use the instance of puppeteer that is already running in app.jsShould I just put my 'page' const as module argument to make it usable inside the module? What if I have 10 other const from other modules?tldr:If file main.js requires 'logger', 'moment', 'puppeteer' , b.js and c.jsANDb.js requires the same 'logger', 'moment', 'puppeteer'c.js requires the same 'logger', 'moment', 'puppeteer'Where should I require the modules that repeat?
Submitted June 04, 2020 at 11:26AM by Third_Rower
No comments:
Post a Comment