penumbra-zone / web

Apache License 2.0
12 stars 15 forks source link

properly output esm #1331

Closed turbocrime closed 3 months ago

turbocrime commented 3 months ago

uses tsc-alias to generate correct import paths for esm support

this may have been related to issues @VanishMax was experiencing

this should permit esm resolution to work properly for the packages' internal modules

edit: okay, tsc-alias doesn't completely solve the issue -

bundlers are fine now, but anything that needs to use node module resolution (vitest, many consumers) will encounter problems because our packages currently use nonstandard module resolution to identify imports from external dependencies.

the tsc-alias tool is only indended for internal paths.

probably we should just comply with esm path spec internally, but that would require changing nearly every import in the codebase, so this PR now combines tsc-alias and changes imports to name external 'js' files that are not resolved via package.json exports.

this mainly just means pb types imports now require a 'js' extension, because those generated packages don't actually define any exports or main configuration.

there's hundreds of pb type imports, so it's a large diff. but this means we don't have to configure a bundler for every package, and the packages should have much better support for many consumers.

edit again:

instead of literally modifying imports, now mutating in a more custom way

this solution is bad. eventually a larger linter/bundler reconfig should happen

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: dfce52908360747c0bbd13b2a8666b8b7d5eafce

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

This PR includes changesets to release 17 packages | Name | Type | | ------------------------------- | ----- | | @penumbra-zone/transport-chrome | Major | | @penumbra-zone/transport-dom | Minor | | @penumbra-zone/perspective | Major | | @penumbra-zone/protobuf | Minor | | @penumbra-zone/services | Major | | @repo/tsconfig | Minor | | @penumbra-zone/bech32m | Minor | | @penumbra-zone/getters | Major | | @penumbra-zone/storage | Major | | @penumbra-zone/client | Major | | @penumbra-zone/crypto-web | Major | | @penumbra-zone/query | Major | | @penumbra-zone/types | Major | | @penumbra-zone/wasm | Major | | minifront | Minor | | @repo/ui | Major | | node-status | Patch |

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