N
N
Nwton2017-02-06 21:37:46
Node.js
Nwton, 2017-02-06 21:37:46

How crazy is this decision?

I decided to experiment and include a third-party js file into the main js file without exports:
eval(fs.readFileSync(__dirname + '/foo.js') + '');
The output suits me, but:
1) Does anyone actually do this?
2) What are the disadvantages of such a solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Kalashnikov, 2017-02-07
@Nwton

By the looks of it, you're solving your architectural problems through muddy hacks. You can of course, but this is not a solution.
If the module is large and does too much, break it up into smaller ones, make one a facade, and it will simply contain a set of submodules. You instantiate others inside and forward calls to them.

D
Dark Hole, 2017-02-06
@abyrkov

1. You. Looks like no one else
2. Scope is the same, modularity goes to hell. As, however, and compatibility. In addition, require is more low-level, it is an api feature, almost a kernel one. Those. will be faster.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question