pmcelhaney / counterfact

OpenAPI / Swagger to TypeScript generator and mock server
MIT License
83 stars 12 forks source link

finally got hot reload of dependent files working #879

Closed pmcelhaney closed 1 month ago

pmcelhaney commented 1 month ago

Continuation of #875

In order to hot-reload dependent files, we need to be able to control the module cache. We can do that with CommonJS and require(). With ESM, Node doesn't have an API to control the cache.

The solution was to always generate CommonJS files and generate .cjs extensions so everything will still work inside an ESM project.

As it stands, this will break if you require a file with a relative path that is outside the output directory. Not a hard fix, but I doubt anyone is affected and I don't want to deal with it right now.

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: 39cb07899034682ed1e0baf03d3da6fdedf16f65

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------- | ----- | | counterfact | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 8902202965

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/server/app.ts 0 1 0.0%
src/server/module-loader.ts 10 12 83.33%
<!-- Total: 62 65 95.38% -->
Totals Coverage Status
Change from base Build 8901772803: 0.2%
Covered Lines: 3063
Relevant Lines: 3537

💛 - Coveralls