Before v5, TypeScript could not understand the exports property in package.json that allows defining multiple entry points in a package. As a result we had to re-export everything from a single file, src/index.ts, and import everything from @h5web/shared. Unfortunately, this type of "barrel" file is really bad for performance in development, since any change to any module in the shared package would trigger an HMR update of every module that depend on the shared package. This used to really ruin the development experience...
Now that we've fully switched to moduleResolution: 'bundler', which does understand exports, I was able to add export entries for each file in @h5web/shared.
The only challenge was to make sure Rollup knew where to find the shared compiled declaration files in packages/shared/dist-ts when generating packages/<app,lib,h5wasm>/dist/index.d.ts.
HMR performance is now much, much better. It's still not perfect, and we could probably also provide multiple entry points in the lib package, but it's a start!
Before v5, TypeScript could not understand the
exports
property inpackage.json
that allows defining multiple entry points in a package. As a result we had to re-export everything from a single file,src/index.ts
, and import everything from@h5web/shared
. Unfortunately, this type of "barrel" file is really bad for performance in development, since any change to any module in the shared package would trigger an HMR update of every module that depend on the shared package. This used to really ruin the development experience...Now that we've fully switched to
moduleResolution: 'bundler'
, which does understandexports
, I was able to add export entries for each file in@h5web/shared
.The only challenge was to make sure Rollup knew where to find the shared compiled declaration files in
packages/shared/dist-ts
when generatingpackages/<app,lib,h5wasm>/dist/index.d.ts
.HMR performance is now much, much better. It's still not perfect, and we could probably also provide multiple entry points in the lib package, but it's a start!