Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

bundle all require modules mentioned in nodejs file into one bundle

$
0
0

i have two files imported into the main.js. i want to import all the codes of the required objects or the entire module into the dist.js - mainly bundle all require modules mentioned in nodejs file into one single bundle. anyone knows a simple way of doing it? i am considering webpack for this but any support? open for typescript supported files here

file1.js

function myfunctionhere() {}module.exports = {myfunctionhere}

file2.js

function myfunctionsecondhere() {}function myfunctionfunctionhere() {}module.exports = {myfunctionsecondhere,myfunctionfunctionhere}

main.js

const f1 = require("./file1.js");const { myfunctionsecondhere } = require("./file2.js");myfunctionhere()myfunctionsecondhere()

after bundling the file should be like this:

dist.js

function myfunctionhere() {}const f1 = { myfunctionhere }function myfunctionsecondhere() {}myfunctionhere()myfunctionsecondhere()

i am considering webpack for this but any support? open for typescript supported files here. what options do i have?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>