Skip to content

Conversation

@Noyabronok
Copy link
Contributor

@Noyabronok Noyabronok commented Oct 29, 2025

The fix

  • Use jiti to load the user config files. Jiti will handle importing ESM modules
  • Updated the multi-file.config.ts file with an esm module import to verify changes
  • Fixes an issue where some instances of generated msw files were referencing _faker instead of faker

Note: this fix is needed for orval versions 8 and 7.14-7.15

Background:

Version 7.14 was a breaking change requiring Node 22. It broke ESM module loading. If you run the orval tests in this PR without jiti you'd get errors like

yarn generate:multi-file
🍻 orval v8.0.0-rc.0 - A swagger client generator for typescript
file:///Users/alex/projects/orval/packages/orval/dist/generate-D7dh3r2M.js:1182
                 throw new Error(`failed to load from ${configFilePath} => ${errorMsg}`);
                       ^

Error: failed to load from ./configs/multi-file.config.ts => Cannot find module '/Users/alex/projects/orval/tests/configs/my-module' imported from /Users/alex/projects/orval/tests/configs/multi-file.config.ts
     at generateConfig (file:///Users/alex/projects/orval/packages/orval/dist/generate-D7dh3r2M.js:1182:9)
     at async Command.<anonymous> (file:///Users/alex/projects/orval/packages/orval/dist/bin/orval.js:44:9)
     at async Command.parseAsync (/Users/alex/projects/orval/node_modules/commander/lib/command.js:1122:5)

Node.js v24.11.0

Alternative solutions

Without this fix, the user can specify NODE_OPTIONS to process the imports. For example, this is how you'd process with tsx:

"generate:multi-file": "orval --config ./configs/multi-file.config.ts",
"generate:multi-file:workaround": "NODE_OPTIONS='--import tsx/esm' yarn generate:multi-file"

yarn generate:multi-file // error
yarn generate:multi-file:workaround // pass

@melloware melloware added this to the 8.0.0-rc.1 milestone Oct 29, 2025
@Noyabronok
Copy link
Contributor Author

@melloware fixed the update-samples issue and tested locally...please run the checks again

@Noyabronok Noyabronok force-pushed the config-module-import branch 3 times, most recently from 5d0ac49 to 338c134 Compare October 30, 2025 00:34
@Noyabronok
Copy link
Contributor Author

Noyabronok commented Oct 30, 2025

@melloware fixed the issues with update-samples and updated commits with proper messaging (hence the force push). Please rerun checks. Thanks!

@melloware
Copy link
Collaborator

Running now.

@Noyabronok
Copy link
Contributor Author

@melloware the failing tests looks the same as the ones for another PR that was merged today https://github.com/orval-labs/orval/actions/runs/18918526841/job/54009465663

@melloware
Copy link
Collaborator

@Noyabronok yep i am investigating today

@Noyabronok
Copy link
Contributor Author

@melloware since those tests were already broken, does this PR need to wait for them to be fixed? The config file processing changes in this PR have passed their checks. Can we merge?

@melloware
Copy link
Collaborator

Nope nothing i need you to do yet.

@melloware
Copy link
Collaborator

ok i fixed main can you get the latest changes and we can watch the build again please?

@melloware melloware added breaking change Breaking change on upgrade enhancement New feature or request and removed breaking change Breaking change on upgrade labels Oct 30, 2025
@Noyabronok Noyabronok force-pushed the config-module-import branch from 338c134 to e997f71 Compare October 30, 2025 16:34
@Noyabronok
Copy link
Contributor Author

@melloware done

@melloware melloware merged commit 7baea4c into orval-labs:master Oct 30, 2025
2 checks passed
@Noyabronok
Copy link
Contributor Author

@melloware Thanks! I tested this in v8rc.1 and it works well. However, there are several other breaking changes in version 8. Is there a process to apply changes in this PR to 7.15 to ease upgrade pains, while version 8 is baking?

@melloware
Copy link
Collaborator

@Noyabronok i just created a v7 branch if you want to submit a PR against that I can try and release 7.16.0 https://github.com/orval-labs/orval/tree/v7

@Noyabronok
Copy link
Contributor Author

@Noyabronok i just created a v7 branch if you want to submit a PR against that I can try and release 7.16.0 https://github.com/orval-labs/orval/tree/v7

awesome! I did figure out how to get the old behavior back in v8... httpClient: 'axios' and generateEachHttpStatus: false did the trick....so it's a little less urgent for me at the moment, but I'll see if I can find the time to PR against the new v7 branch soon!

@melloware
Copy link
Collaborator

Yep we have a migration guide: https://orval.dev/guides/migration-v8

let us know if we missed anything and we can add it.

@Noyabronok
Copy link
Contributor Author

Noyabronok commented Oct 30, 2025

Yep we have a migration guide: https://orval.dev/guides/migration-v8
let us know if we missed anything and we can add it.

hmm..I wish I saw this migration guide before. I think with the jiti changes in this PR the .mjs or type: modules requirements are not necessary. I still have my config file as orval.config.ts and package.json still using commonjs type without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants