question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to improve nested requires?

See original GitHub issue

We would like to figure out how to improve requiring modules.

e.g. take a look at this - we have to go back in the folder tree to be able to require the logging module.

The same problem exists in our test env, see.

global require function

One option could be to add a global.requireSomething fn, which is able to read modules from a defined root path.

e.g. requireRoot('services') - would require a module from the core/server folder. e.g. requireLib('errors') - would require a module inside core/server/lib

other options?

Wait that Node supports import/export and a similar module like ember-resolve. So you can do:

import * from 'ghost/services' - that would be so cool 🙊

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ernstwicommented, Feb 16, 2018

In case it could be useful in future, here’s a script to rewrite the require paths using the current directory as root.

1reaction
kirrg001commented, Feb 14, 2018

@ernstwi Hey, thanks for coming back. I’ll reply tomorrow 👋

Read more comments on GitHub >

github_iconTop Results From Across the Web

Computer Programming/Coding Style/Minimize nesting
Deeply nested code is a common feature of structured programming. While it has some advantages, discussed in that section, it is frequently considered...
Read more >
Javascript: How to improve nested for loops | by Tim Hannan
In this article, we will improve the performance of a function with a nested loop by converting the array from the outer loop...
Read more >
How to reduce the time complexity of nested loops
In this post I'll demonstrate a way to understand, analyse and reduce the time complexity on algorithms, specially on nested loops.
Read more >
How to improve algorithm efficiency for nested loop
Have a Set of numbers you have seen, starting empty; Look at each number in the input list; Calculate which number you would...
Read more >
c# - How to optimize these nested loops for better performance?
I need to optimize this code so it can execute faster, even if that means using more memory: for (int t = 0;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found