We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to dynamically import a function with the filename given in a function argument. This are my approaches and outcomes:
First approach: require()
Line of Code: const file = await require(`./${fileName}`); And the compiler options:
const file = await require(`./${fileName}`);
"module": "ESNext", "target": "CommonJS", "esModuleInterop": true,
This is giving me this error:
ReferenceError: require is not defined at (api/test.js:116:87) at (api/test.js:116:24) at (api/test.js:130:28)
However, when i trying the same with an static path and not the variable in the path, it works, no errors. const file = await require('./test');
const file = await require('./test');
Second approach: import()
Line of Code: const file = await import(`./${fileName}`); const file = await import('./test'); And my typescript compiler options:
const file = await import(`./${fileName}`);
const file = await import('./test');
"module": "es2020", "target": "es2020", "esModuleInterop": true,
But that is giving me this error, with the variable in the path and also without.
Error: internal error at (api/test.js:87:52) at (api/test.js:101:34) at (api/test.js:23:11)
The text was updated successfully, but these errors were encountered:
Sorry, that is not supported and not expected to be supported.
You should to get your code ready before passing it to Edge Runtime, like this example: https://edge-runtime.vercel.app/packages/runtime#usage
🙂
Sorry, something went wrong.
No branches or pull requests
Bug Report
I am trying to dynamically import a function with the filename given in a function argument.
This are my approaches and outcomes:
First approach: require()
Line of Code:
const file = await require(`./${fileName}`);
And the compiler options:
This is giving me this error:
However, when i trying the same with an static path and not the variable in the path, it works, no errors.
const file = await require('./test');
Second approach: import()
Line of Code:
const file = await import(`./${fileName}`);
const file = await import('./test');
And my typescript compiler options:
But that is giving me this error, with the variable in the path and also without.
The text was updated successfully, but these errors were encountered: