Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates
paths
for Node16 module resolution.
Node16 module resolution [does not support "directory modules"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#supported-features), yet the `paths` option was linking to a directory. This updates the `paths` to link directly to the associated file or default to `index.mjs`. This isn't an ideal solution as it does not respect `exports` and effectively requires that any exported subpath link to an internal file at exact same path. [TS recommendation](https://www.typescriptlang.org/docs/handbook/modules/reference.html#paths-should-not-point-to-monorepo-packages-or-node_modules-packages) is to avoid `paths` for monorepo resolution for this reason and instead rely on `pnpm` linking. I made an attempt at this and found that it works for `@rules_prerender/declarative_shadow_dom` and `@rules_prerender/preact` pretty well, since they link against their deps via the `workspace:` protocol already. However it doesn't work for the rest of the workspace because they rely on the `npm_link_all_packages` target and if the `package.json` depends on `rules_prerender` or `@rules_prerender/*` packages, then it will duplicate the existing `//:node_modules/rules_prerender`-style targets. However we can't get rid of the existing ones since those build from real source. For now we'll just a less-than-optimal `paths` option, however we should explore in the future how to drop it entirely and rely on `pnpm` linking to solve this problem.
- Loading branch information