Build library and types with Vite only - #49
Open
edoardocavazza wants to merge 7 commits into
Open
Conversation
Replace the esbuild + tsc + rimraf build pipeline with a single Vite library build, mirroring chialab/dna: a new vite.lib.config.ts bundles src/index.ts with @chialab/dna kept external, and the unplugin-isolated-decl plugin emits co-located .d.ts files per module instead of a separate types/ folder generated by tsc. tsconfig.json now sets noEmit + isolatedDeclarations (tsc is kept only as a type-check gate, wired into the test script, same as DNA's test:typings). Every exported function/method/accessor that lacked an explicit type annotation got one, as isolatedDeclarations requires per-file type information with no cross-file inference. package.json's exports.types now points at dist/synapse.d.ts instead of types/index.d.ts, and esbuild/rimraf are dropped from devDependencies.
|
vite.config.ts is now the library build config (previously vite.lib.config.ts) and doubles as the default used by Vite tooling (e.g. IDE integration, vitest). The demo/pages app gets its own vite.demo.config.ts, referenced explicitly by the dev and pages:build scripts.
Enable vitest's typecheck for all of src/**/*.{ts,tsx}, so `vitest run`
(and therefore `yarn test`) always typechecks the library on its own.
Drop the now-redundant "types" script and its "yarn types &&" prefix
on "test".
Drop the resolve.alias from vite.demo.config.ts and have the demo's own files import the library source with a relative path instead, so the demo no longer needs any bundler-level indirection to pick up local source changes. Bump vite to ^8.0.0 (Rolldown-powered) and switch vite.config.ts's lib build from rollupOptions to rolldownOptions, matching DNA. The external matcher is narrowed to just @chialab/dna (and its subpaths): a broader "externalize anything non-relative" matcher also caught Rolldown's own injected @oxc-project/runtime helpers (needed for decorators/private fields), leaving them as unresolved imports in the published bundle instead of inlined.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the esbuild + tsc + rimraf build pipeline with a single Vite library build, mirroring chialab/dna: a new vite.lib.config.ts bundles src/index.ts with @chialab/dna kept external, and the unplugin-isolated-decl plugin emits co-located .d.ts files per module instead of a separate types/ folder generated by tsc.
tsconfig.json now sets noEmit + isolatedDeclarations (tsc is kept only as a type-check gate, wired into the test script, same as DNA's test:typings). Every exported function/method/accessor that lacked an explicit type annotation got one, as isolatedDeclarations requires per-file type information with no cross-file inference.
package.json's exports.types now points at dist/synapse.d.ts instead of types/index.d.ts, and esbuild/rimraf are dropped from devDependencies.