Zira
11/24/2025, 10:17 PMjson
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "invalid",
"details": {
"text": "Dynamic require of \"@medplum/core\" is not supported"
}
}
]
}
As of 5.0.4, a recent change to some example projects (I tested examples/medplum-scheduling-demo) switched to ESM for building the bots. I made the change to my project to see if that would fix it, but I'm getting an error with that too for both my project and the example project:
json
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "invalid",
"details": {
"text": "Cannot use import statement outside a module"
}
}
]
}
Since the example project ("project" as in code workspace) is failing, it leads me to believe something is wrong with the settings of the Medplum project stored in my database, since I pointed both code projects at that.
My server is running the latest Docker image as of today (2025-11-24). My project dependencies are all 5.0.4.finnbergquist
11/25/2025, 8:07 PMZira
11/25/2025, 8:16 PMvmcontextfinnbergquist
11/25/2025, 10:17 PMZira
11/26/2025, 4:42 AMrequire as the global require if it exists, else createRequire. Though I believe with ESBuild, require always exists?
I looked at the server's dist/index.js that was generated by ESBuild and found that if I commented out the __require line at the top, my CJS bot code started running. So I can use that as a workaround for now.
I think if the goal is to transition bots to ESM, node:vm has a whole Modules paradigm that isn't currently used in the vmcontext execution fileIan Plunkett
11/27/2025, 1:18 AMIan Plunkett
11/27/2025, 1:19 AMZira
11/29/2025, 1:39 AM