-
-
Notifications
You must be signed in to change notification settings - Fork 1
Build TypeScript sprinkle packages with conditional exports and monorepo dev config #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 6.0
Are you sure you want to change the base?
Conversation
- Install vite-plugin-dts for generating .d.ts files - Create tsconfig.build.json for each sprinkle package - Update vite.config.ts with library mode for all sprinkles - Update package.json exports to point to dist/*.js files - Add build scripts to all packages - Update .gitignore to ignore dist directories - Remove sprinkles from skeleton optimizeDeps.exclude Co-authored-by: lcharette <2566513+lcharette@users.noreply.github.com>
…ilds - Add "development" condition to exports that points to source TS files - Keep "import" condition for dist/*.js for published use - Update skeleton vite config to resolve development condition - Include both src and dist in package files for dual usage - Restore optimizeDeps.exclude for monorepo development HMR Co-authored-by: lcharette <2566513+lcharette@users.noreply.github.com>
|
@copilot Considering the skeleton can be used on it's own, should the development condition be defined in the monorepo vite config instead? |
Instead of always using 'development' condition in skeleton's vite config, detect if we're in a monorepo context and only apply the condition then. This allows skeleton to be used standalone with published npm packages. Co-authored-by: lcharette <2566513+lcharette@users.noreply.github.com>
Good point! I've moved the logic to detect monorepo context within the skeleton's vite.config.ts itself. It now checks for the workspace root structure and only applies the 'development' condition when in the monorepo. When skeleton is used standalone, it will use the default 'import' condition to resolve to published dist files. (ad696a1) |
|
@copilot The end goal is to remove the skeleton's optimizeDeps. The monorepo should have it's own vite config, and the monorepo dev server should call this monorepo vite config |
- Created root-level vite.config.ts for monorepo development - Moved resolve.conditions and optimizeDeps to monorepo config - Removed monorepo-specific settings from skeleton's vite.config.ts - Added 'npm run dev' script to use monorepo vite config - Skeleton now has clean config suitable for standalone use Co-authored-by: lcharette <2566513+lcharette@users.noreply.github.com>
Done! Created a root-level vite.config.ts for monorepo development with the optimizeDeps and resolve.conditions settings. The skeleton's vite.config.ts is now clean and suitable for standalone use. Use |
|
@copilot Fix all build task errors and warning, such as "Property '$t' does not exist on type" |
- Updated tsconfig.build.json to include env.d.ts files - Removed rootDir constraint to allow env.d.ts inclusion - Build now properly includes type declarations for $t, $tdate, $checkAccess - All packages build without TypeScript errors Co-authored-by: lcharette <2566513+lcharette@users.noreply.github.com>
|
@copilot |
- Added "customConditions": ["development"] to root tsconfig.json - Allows TypeScript to resolve conditional exports during typecheck - Fixes all 75+ TypeScript errors that appeared after adding conditional exports - npm run typecheck now passes with zero errors - All package builds work without TypeScript errors Co-authored-by: lcharette <2566513+lcharette@users.noreply.github.com>
Fixed! Added |
…ompiler options for development
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 6.0 #8 +/- ##
=========================================
Coverage 90.59% 90.59%
Complexity 2830 2830
=========================================
Files 638 638
Lines 16193 16193
Branches 506 506
=========================================
Hits 14670 14670
Misses 1515 1515
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Build TypeScript Sprinkle Packages
Summary
Successfully implemented a build system for TypeScript sprinkle packages that allows them to be published as pre-built JavaScript modules with type declarations, while maintaining source code usage for monorepo development.
Changes Completed:
Key Implementation Details:
Conditional Exports: Packages use conditional exports in package.json:
development: Points to source.tsfiles for monorepo dev/HMRimport: Points to builtdist/*.jsfiles for published packagestypes: Points to.d.tstype declarationsTypeScript Configuration:
customConditions: ["development"]to root tsconfig.jsonnpm run typecheckworks correctly with conditional exportsMonorepo Development:
vite.config.tswith monorepo-specific configurationresolve.conditions: ['development', 'import']for source file resolutionoptimizeDeps.excludefor sprinkle packages to enable HMRnpm run devfrom root to start monorepo dev serverSkeleton Configuration:
Build Configuration: Each package has:
tsconfig.build.jsonfor build-specific TypeScript config with env.d.ts includedvite.config.tswith library mode, dts plugin, and external dependenciesFiles Shipped: Packages include both source and dist directories to support both use cases.
Usage:
Monorepo development:
npm run dev # Start dev server from rootBuild all packages:
npm run build # Builds without TypeScript errorsBuild individual packages:
Type checking:
npm run typecheck # Passes with zero errorsNotes:
npm run typecheckpasses with zero errorsOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.