deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

fix(http): make the debug panel compatible with Yarn PnP installs

Open LEW21 opened this issue 6 months ago • 0 comments

I'm trying to get deepkit running with Yarn PnP (using deepkit-node - I might send a pull request with that later, when I figure out if it'll actually be usable).

Summary of changes

Right now, running an app (yarn node --import deepkit-node ./app.ts server:start) with FrameworkModule({ debug: true }) in a Yarn PnP environment produces a warning:

Warning: node_modules/@deepkit/framework-debug-gui no build found in /home/linus/dev/my-deepkit-app/.yarn/unplugged/@deepkit-framework-virtual-9069fc273b/node_modules/@deepkit/framework/dist/esm/src/debug

As a result, the debug panel doesn't work. This is because the node_modules path is hardcoded, and there is no node_modules on Yarn PnP.

With this change, it works. I'm using import.meta.resolve to resolve a path to index.html, and I'm forcing yarn to actually unzip ("unplug") the static files, so that it's possible to access them in a traditional way.

As import.meta is accessible only in the ESM mode, I'm doing some hack to do the resolution with require.resolve in CJS mode - I don't really like this solution, but I don't have any idea for a better one. Theoretically, this should be transparently handled by the ESM->CJS transpiler, but TypeScript doesn't support it.

Relinquishment of Rights

Please mark following checkbox to confirm that you relinquish all rights of your changes:

  • [x] I waive and relinquish all rights regarding this changes (including code, text, and images) to Deepkit UG (limited), Germany. This changes (including code, text, and images) are under MIT license without name attribution, copyright notice, and permission notice requirement.

LEW21 avatar Aug 22 '24 00:08 LEW21