You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected test to run successfully, but
Instead, this happened:
⠋ /<...>/node_modules/@artilleryio/int-core/lib/runner.js:97
script.config.processor = require(processorPath);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /<...>/processor.js from /<...>/node_modules/@artilleryio/int-core/lib/runner.js not supported.
Instead change the require of processor.js in /<...>/node_modules/@artilleryio/int-core/lib/runner.js to a dynamic import() which is available in all CommonJS modules.
at loadProcessor (/<...>/node_modules/@artilleryio/int-core/lib/runner.js:97:33)
Files being used:
[test.yml]
config:
# ...
processor: 'processor.js' # pointed to a ES Module
Problem arises from the following code in packages/core/lib/runner.js:
async function loadProcessor(script, options) {
const absoluteScriptPath = path.resolve(process.cwd(), options.scriptPath);
if (script.config.processor) {
const processorPath = path.resolve(
path.dirname(absoluteScriptPath),
script.config.processor
);
if (processorPath.endsWith('.mjs')) { // <- this check is causing to divert to incorrect path
const exports = await import(processorPath);
script.config.processor = Object.assign(
{},
script.config.processor,
exports
);
} else {
// CJS (possibly transplied from TS)
script.config.processor = require(processorPath);
}
}
return script;
}
Probable fix could be simply removing the conditional and always attempt to import(module) as Node.js should be able to determine the module format and import it correctly for both CJS and ESM.
The text was updated successfully, but these errors were encountered:
Version info:
Running this command:
I expected test to run successfully, but
Instead, this happened:
Files being used:
[test.yml]
My project has ES modules with
*.js
extension andtype="module"
set in thepackage.json
. According to https://nodejs.org/api/packages.html#determining-module-system it is a valid way of specifying ES module files.Problem arises from the following code in
packages/core/lib/runner.js
:Probable fix could be simply removing the conditional and always attempt to
import(module)
as Node.js should be able to determine the module format and import it correctly for both CJS and ESM.The text was updated successfully, but these errors were encountered: