Fix ESM support
Compare changes
I removed rollup but it is quite possible I misunderstood it's purpose, so I apologize if that is the case and can re-add it or refactor the rollup build to work for out needs. I feel more comfortable with tsup right now and it uses rollup under the hood so I figured it shouldn't be too different.
These changes have been tested with npx publint
and npx @arethetypeswrong/cli
, which still reports an issue about the CJS version of the bundle "Masquerading as ESM" (see https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md for the full explanation). Even when emitting both d.mts and d.ts files, I could not fix all of the lint warnings, but at least this version of the bundle works using Next 13's app router. I also tested the bundle in a vanilla TypeScript create-vite-app
.
This should also close https://www.drupal.org/project/drupal_state/issues/3231626 as the compiled js now emits to ./dist