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.

Support dynamic require

See original GitHub issue

Many modules uses require to dynamically load JSON files.

Example:

require('./path/' + name + '.json');

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
goto-bus-stopcommented, Oct 26, 2018

@dy fetch()'s return value doesn’t have a .text() method, so with async/await you have to do something like

var resp = await fetch(`posts/${post}.md`)
var content = await resp.text()
0reactions
dycommented, Oct 26, 2018

@YerkoPalma even better now:

var content = (await fetch(`posts/${post}.md`)).text()
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "Dynamic require of "os" is not supported" #1921
Is that possible? ... Just run node index.mjs. This was generated from running build which executes esbuild to bundle this file. Problem: The ......
Read more >
JavaScript modules: dynamic import() - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web ... Loading JavaScript modules dynamically using the import() syntax.
Read more >
Module Methods - webpack
require.ensure() is specific to webpack and superseded by import() . ... Split out the given dependencies to a separate bundle that will be...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
There is also a function-like dynamic import() , which does not require scripts of type="module" . Syntax. import defaultExport from "module- ...
Read more >
Dynamic require not supported in React Native - Stack Overflow
I'm interested to know what exactly a dynamic require is and if it's possible to replace the dynamic require with a normal one....
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