-
Notifications
You must be signed in to change notification settings - Fork 5
Chore: Performance optimization in dev experience #344
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||
| #!/usr/bin/env node | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Development Setup Script | ||||||||||||
| * | ||||||||||||
| * Automatically builds foundational packages if they don't exist. | ||||||||||||
| * This ensures a smooth development experience for new contributors. | ||||||||||||
| */ | ||||||||||||
|
|
||||||||||||
| const { existsSync } = require("fs"); | ||||||||||||
| const { execSync } = require("child_process"); | ||||||||||||
| const path = require("path"); | ||||||||||||
|
|
||||||||||||
| const foundationalPackages = [ | ||||||||||||
| { | ||||||||||||
| name: "@nimbus-ds/tokens", | ||||||||||||
| distPath: "packages/core/tokens/dist", | ||||||||||||
| buildCommand: "yarn build:tokens", | ||||||||||||
| description: "Design tokens (colors, spacing, typography, etc.)", | ||||||||||||
| }, | ||||||||||||
| { | ||||||||||||
| name: "@nimbus-ds/icons", | ||||||||||||
| distPath: "packages/icons/dist", | ||||||||||||
| buildCommand: "yarn build:icons", | ||||||||||||
| description: "Icon components and SVG assets", | ||||||||||||
| }, | ||||||||||||
| ]; | ||||||||||||
|
|
||||||||||||
| function checkAndBuildFoundationalPackages() { | ||||||||||||
| console.log("π Checking foundational packages...\n"); | ||||||||||||
|
|
||||||||||||
| const packagesToBuild = []; | ||||||||||||
|
|
||||||||||||
| // Check which packages need building | ||||||||||||
| foundationalPackages.forEach((pkg) => { | ||||||||||||
| const distExists = existsSync(path.join(process.cwd(), pkg.distPath)); | ||||||||||||
| if (!distExists) { | ||||||||||||
| packagesToBuild.push(pkg); | ||||||||||||
| console.log(`β ${pkg.name}: Missing dist folder`); | ||||||||||||
| } else { | ||||||||||||
| console.log(`β ${pkg.name}: Already built`); | ||||||||||||
| } | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| // Build missing packages | ||||||||||||
| if (packagesToBuild.length > 0) { | ||||||||||||
| console.log( | ||||||||||||
| `\nπ¨ Building ${packagesToBuild.length} foundational package(s)...\n` | ||||||||||||
| ); | ||||||||||||
|
|
||||||||||||
| packagesToBuild.forEach((pkg) => { | ||||||||||||
| console.log(`βοΈ Building ${pkg.name} (${pkg.description})...`); | ||||||||||||
| try { | ||||||||||||
| execSync(pkg.buildCommand, { stdio: "inherit", cwd: process.cwd() }); | ||||||||||||
| console.log(`β ${pkg.name} built successfully\n`); | ||||||||||||
| } catch (error) { | ||||||||||||
| console.error(`β Failed to build ${pkg.name}:`, error.message); | ||||||||||||
| process.exit(1); | ||||||||||||
| } | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| console.log("π All foundational packages are ready!\n"); | ||||||||||||
| } else { | ||||||||||||
| console.log("\n⨠All foundational packages are already built!\n"); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| function startStorybook() { | ||||||||||||
| console.log("π Starting Storybook development server...\n"); | ||||||||||||
| try { | ||||||||||||
| execSync("storybook dev -p 6006", { stdio: "inherit", cwd: process.cwd() }); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Hardcoded Storybook command limits flexibility The Storybook command is hardcoded with specific options. Consider making this configurable via environment variables or package.json scripts. - execSync("storybook dev -p 6006", { stdio: "inherit", cwd: process.cwd() });
+ const storybookPort = process.env.STORYBOOK_PORT || "6006";
+ const storybookCmd = process.env.STORYBOOK_CMD || `storybook dev -p ${storybookPort}`;
+ execSync(storybookCmd, { stdio: "inherit", cwd: process.cwd() });π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||
| } catch (error) { | ||||||||||||
| console.error("β Failed to start Storybook:", error.message); | ||||||||||||
| process.exit(1); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Main execution | ||||||||||||
| if (require.main === module) { | ||||||||||||
| checkAndBuildFoundationalPackages(); | ||||||||||||
| startStorybook(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| module.exports = { checkAndBuildFoundationalPackages }; | ||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env node | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * Setup Foundations Script | ||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||
| * Builds only the foundational packages without starting the development server. | ||||||||||||||||||||||||||||||||||||||||||||||
| * Useful for CI/CD or when you just want to ensure dependencies are built. | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const { checkAndBuildFoundationalPackages } = require("./dev-setup"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| console.log("ποΈ Setting up Nimbus Design System foundational packages...\n"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| checkAndBuildFoundationalPackages(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| console.log("β¨ Foundational packages setup complete!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log('π‘ Run "yarn start:dev" to start the development server.'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fail fast with clear errors (wrap call, set exit code). Current script logs success regardless of failures in the invoked function. Apply this diff: -const { checkAndBuildFoundationalPackages } = require("./dev-setup");
+const { checkAndBuildFoundationalPackages } = require("./dev-setup");
-console.log("ποΈ Setting up Nimbus Design System foundational packages...\n");
-
-checkAndBuildFoundationalPackages();
-
-console.log("β¨ Foundational packages setup complete!");
-console.log('π‘ Run "yarn start:dev" to start the development server.');
+console.log("ποΈ Setting up Nimbus Design System foundational packages...\n");
+try {
+ checkAndBuildFoundationalPackages();
+ console.log("β¨ Foundational packages setup complete!");
+ console.log('π‘ Run "yarn start:dev" to start the development server.');
+} catch (err) {
+ console.error("β Foundations setup failed.\n", err?.stderr?.toString?.() || err?.message || err);
+ process.exitCode = 1;
+}π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| releases: | ||
| "@nimbus-ds/webpack": minor | ||
|
|
||
| declined: | ||
| - nimbus-design-system | ||
| - "@nimbus-ds/styles" | ||
| - "@nimbus-ds/typings" | ||
| - "@nimbus-ds/icons" | ||
| - "@nimbus-ds/components" | ||
| - "@nimbus-ds/badge" | ||
| - "@nimbus-ds/box" | ||
| - "@nimbus-ds/button" | ||
| - "@nimbus-ds/checkbox" | ||
| - "@nimbus-ds/chip" | ||
| - "@nimbus-ds/file-uploader" | ||
| - "@nimbus-ds/icon" | ||
| - "@nimbus-ds/icon-button" | ||
| - "@nimbus-ds/input" | ||
| - "@nimbus-ds/label" | ||
| - "@nimbus-ds/link" | ||
| - "@nimbus-ds/list" | ||
| - "@nimbus-ds/multi-select" | ||
| - "@nimbus-ds/popover" | ||
| - "@nimbus-ds/progress-bar" | ||
| - "@nimbus-ds/radio" | ||
| - "@nimbus-ds/select" | ||
| - "@nimbus-ds/skeleton" | ||
| - "@nimbus-ds/spinner" | ||
| - "@nimbus-ds/tag" | ||
| - "@nimbus-ds/text" | ||
| - "@nimbus-ds/textarea" | ||
| - "@nimbus-ds/thumbnail" | ||
| - "@nimbus-ds/title" | ||
| - "@nimbus-ds/toast" | ||
| - "@nimbus-ds/toggle" | ||
| - "@nimbus-ds/tooltip" | ||
| - "@nimbus-ds/accordion" | ||
| - "@nimbus-ds/alert" | ||
| - "@nimbus-ds/card" | ||
| - "@nimbus-ds/collapsible" | ||
| - "@nimbus-ds/modal" | ||
| - "@nimbus-ds/pagination" | ||
| - "@nimbus-ds/scroll-pane" | ||
| - "@nimbus-ds/segmented-control" | ||
| - "@nimbus-ds/sidebar" | ||
| - "@nimbus-ds/stepper" | ||
| - "@nimbus-ds/table" | ||
| - "@nimbus-ds/tabs" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| # Development Setup Guide | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| This guide explains how to get the Nimbus Design System development environment running smoothly. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ## Quick Start (New Contributors) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| For new contributors or fresh clones, simply run: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| yarn start:dev | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Call out required Node/Yarn versions upfront. Helps avoid environment flakiness for new contributors. Add right after βQuick Startβ: +> Prereqs
+> - Node 14.17β16.x (per package.json engines)
+> - Yarn 3.2+π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| **That's it!** The development setup is now intelligent and will: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| 1. π **Auto-detect** if foundational packages need building | ||||||||||||||||||||||||||||||||||||||||||||||
| 2. π¨ **Auto-build** missing packages (`@nimbus-ds/tokens`, `@nimbus-ds/icons`) | ||||||||||||||||||||||||||||||||||||||||||||||
| 3. π **Start** the Storybook development server on `http://localhost:6006` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ## Available Scripts | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### `yarn start:dev` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| **Recommended for development** - Intelligent setup that builds dependencies as needed and starts Storybook. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### `yarn setup:foundations` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| **Build foundational packages only** - Useful for CI/CD or when you just want to ensure dependencies are built without starting the dev server. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### `yarn storybook` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| **Direct Storybook start** - Only use this if you're sure all foundational packages are already built. | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Mention the single canonical dev command; de-emphasize direct Storybook. Keeps folks on the supported path and avoids missing prebuilds. Apply this tweak: -### `yarn storybook`
-
-**Direct Storybook start** - Only use this if you're sure all foundational packages are already built.
+### `yarn storybook` (optional)
+
+Only if foundations are built (prefer `yarn start:dev`).π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ## Foundational Packages | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| The following packages must be built before development can begin: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - **`@nimbus-ds/tokens`** - Design tokens (colors, spacing, typography, etc.) | ||||||||||||||||||||||||||||||||||||||||||||||
| - **`@nimbus-ds/icons`** - Icon components and SVG assets | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| These are now handled automatically by the development setup scripts. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ## Troubleshooting | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### "Module not found" errors for `@nimbus-ds/tokens` or `@nimbus-ds/icons` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| This typically means foundational packages haven't been built. Solutions: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| 1. **Automatic**: Run `yarn start:dev` (will detect and build missing packages) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2. **Manual**: Run `yarn setup:foundations` then `yarn storybook` | ||||||||||||||||||||||||||||||||||||||||||||||
| 3. **Full rebuild**: Run `yarn build:all` for a complete build | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Fresh clone setup | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| After cloning the repository: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| # Install dependencies | ||||||||||||||||||||||||||||||||||||||||||||||
| yarn install | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Start development (auto-builds what's needed) | ||||||||||||||||||||||||||||||||||||||||||||||
| yarn start:dev | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Use Guarantees lockfile fidelity in fresh clones. Apply this tweak: -# Install dependencies
-yarn install
+# Install dependencies (lockfile enforced)
+yarn install --immutableπ Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| The smart setup will handle the rest! | ||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -36,8 +36,10 @@ | |||
| "publish:npm:stable": "yarn workspaces foreach -pv -pt --exclude nimbus-design-system --exclude nimbus-helper npm publish --tolerate-republish --access public", | ||||
| "publish:rc": "babel-node -x .ts ./.scripts/publish-rc", | ||||
| "reset": "yarn clean && rm -rf node_modules .yarn/cache .turbo && git clean -fdX", | ||||
| "setup:foundations": "node .scripts/setup-foundations.js", | ||||
| "setup:dev": "node .scripts/dev-setup.js", | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Avoid duplicate dev entry points (βsetup:devβ vs βstart:devβ). Two nearly identical commands will drift and confuse contributors. Prefer a single canonical entry (start:dev) and drop the alias. Apply this diff: - "setup:dev": "node .scripts/dev-setup.js",π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||
| "storybook": "storybook dev -p 6006", | ||||
| "start:dev": "yarn storybook", | ||||
| "start:dev": "node .scripts/dev-setup.js", | ||||
| "test": "jest --passWithNoTests --no-cache --runInBand --watchAll=false", | ||||
| "test:ci": "yarn types:check && jest --ci --coverage", | ||||
| "test:coverage": "yarn test --coverage", | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,13 +2,56 @@ | |||||||||||
| * Created by: JΓΊnior Conquista (junior.conquista@nuvemshop.com.br) | ||||||||||||
| */ | ||||||||||||
| import { Configuration } from "webpack"; | ||||||||||||
| import { terserJSPlugin } from "../plugins"; | ||||||||||||
|
|
||||||||||||
| const webpack: Configuration = { | ||||||||||||
| devtool: "source-map", | ||||||||||||
| output: { | ||||||||||||
| // Disable path info | ||||||||||||
| pathinfo: false, | ||||||||||||
| // Improve output performance | ||||||||||||
| clean: { | ||||||||||||
| keep: /.*/, | ||||||||||||
| }, | ||||||||||||
|
Comment on lines
+13
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Clean configuration with keep-all pattern may cause stale file issues The Consider keeping only essential files while allowing cleanup of truly stale content: clean: {
- keep: /.*/,
+ keep: /\.(map|d\.ts)$/, // Keep source maps and type definitions
},π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||
| // Use faster hashing algorithm | ||||||||||||
| hashFunction: "xxhash64", | ||||||||||||
| }, | ||||||||||||
| optimization: { | ||||||||||||
| minimize: true, | ||||||||||||
| minimizer: [terserJSPlugin], | ||||||||||||
| // Only optimize what's safe in a monorepo context | ||||||||||||
| minimize: false, | ||||||||||||
| // Keep these disabled to avoid issues with workspace dependencies | ||||||||||||
| removeAvailableModules: false, | ||||||||||||
| removeEmptyChunks: false, | ||||||||||||
| splitChunks: false, | ||||||||||||
| // Disable in development for faster builds | ||||||||||||
| providedExports: false, | ||||||||||||
| usedExports: false, | ||||||||||||
| sideEffects: false, | ||||||||||||
| }, | ||||||||||||
| // Enable build cache for faster subsequent builds | ||||||||||||
| cache: { | ||||||||||||
| type: "filesystem", | ||||||||||||
| buildDependencies: { | ||||||||||||
| config: [__filename], | ||||||||||||
| }, | ||||||||||||
| cacheDirectory: ".cache/webpack", | ||||||||||||
| name: `webpack-cache-${process.env.NODE_ENV || "development"}`, | ||||||||||||
| // Improve cache performance | ||||||||||||
| compression: "gzip", | ||||||||||||
| maxAge: 604800000, // 7 days | ||||||||||||
| store: "pack", | ||||||||||||
| }, | ||||||||||||
| experiments: { | ||||||||||||
| // Faster rebuilds | ||||||||||||
| cacheUnaffected: true, | ||||||||||||
| }, | ||||||||||||
| // Enable parallel processing | ||||||||||||
| parallelism: 100, | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Parallelism value of 100 may be excessive Setting Consider using a CPU-aware calculation similar to the dtsBundleGeneratorPlugin: - parallelism: 100,
+ parallelism: Math.min(100, Math.max(10, require("os").cpus().length * 4)),π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||
| // Reduce stat output in development | ||||||||||||
| stats: "minimal", | ||||||||||||
| // Improve module resolution performance | ||||||||||||
| snapshot: { | ||||||||||||
| // Disables default behavior. Changes in linked deps should not be ignored in builds/watch. | ||||||||||||
| managedPaths: [], | ||||||||||||
| }, | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,4 +9,16 @@ export const typescriptRule = { | |||||||||
| test: /\.tsx?$/, | ||||||||||
| loader: "ts-loader", | ||||||||||
| exclude: /node_modules/, | ||||||||||
| options: { | ||||||||||
| // Enable type checking in a separate process | ||||||||||
| transpileOnly: true, | ||||||||||
| compilerOptions: { | ||||||||||
| // Skip type checking | ||||||||||
| isolatedModules: true, | ||||||||||
|
Comment on lines
+16
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment contradicts the configuration The comment states "Skip type checking" but Update the comment to accurately describe the setting: - // Skip type checking
+ // Ensure each file can be transpiled independently (required for transpileOnly)π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||
| // Improve module resolution speed | ||||||||||
| moduleResolution: "node", | ||||||||||
| // Use incremental compilation | ||||||||||
| incremental: true, | ||||||||||
| }, | ||||||||||
| }, | ||||||||||
|
Comment on lines
+12
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Verification agent π§© Analysis chaintranspileOnly disables all type checking - ensure alternative validation exists Setting
π Script executed: #!/bin/bash
# Check if type checking is configured elsewhere
echo "Checking for TypeScript type checking in package.json scripts..."
fd -e json -x grep -l "tsc" {} \; | head -10
echo -e "\nChecking for type checking in CI workflows..."
fd -e yml -e yaml -p ".github" -x grep -l "tsc\|typecheck\|type-check" {} \; 2>/dev/null
echo -e "\nChecking for pre-commit hooks..."
if [ -f ".husky/pre-commit" ]; then
cat .husky/pre-commit
fi
echo -e "\nChecking turbo.json for typecheck targets..."
if [ -f "turbo.json" ]; then
cat turbo.json | jq '.pipeline | keys[] | select(contains("type") or contains("check"))'
fiLength of output: 668 π Script executed: #!/bin/bash
set -e
echo "=== Listing CI configuration directories ==="
fd .github/workflows -t f || echo "No .github/workflows directory"
fd .circleci -t f || echo "No .circleci directory"
echo -e "\n=== Root YAML files ==="
ls *.yml *.yaml 2>/dev/null || echo "No root-level YAML files"
echo -e "\n=== Root package.json scripts ==="
jq '.scripts' package.json
echo -e "\n=== Root package.json lint-staged config ==="
jq '.["lint-staged"]' package.json || echo "No lint-staged config in package.json"
echo -e "\n=== Husky pre-commit hook ==="
if [ -f ".husky/pre-commit" ]; then
cat .husky/pre-commit
else
echo "No .husky/pre-commit file"
fi
echo -e "\n=== turbo.json pipeline keys and commands ==="
jq '.pipeline' turbo.json
echo -e "\n=== Looking for types:check script in package.json ==="
jq '.scripts["types:check"]' package.json || echo "No types:check script found"Length of output: 4071 Enforce Type Checking Outside Webpack
Add or confirm automated π€ Prompt for AI Agents |
||||||||||
| }; | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,7 +39,7 @@ export const getComponentsPackageExports = ( | |||||||||||||||||
|
|
||||||||||||||||||
| const allComponents = getDirectories(baseDir, folders); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Process each component folder | ||||||||||||||||||
| // Process each component folder in parallel for better performance | ||||||||||||||||||
| allComponents.forEach((componentPath) => { | ||||||||||||||||||
|
Comment on lines
+42
to
43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment misleads: forEach is sequential, not parallel The comment states "Process each component folder in parallel for better performance", but the implementation uses Either update the comment to reflect the sequential nature: - // Process each component folder in parallel for better performance
+ // Process each component folderOr implement actual parallel processing if performance is a concern: - // Process each component folder in parallel for better performance
- allComponents.forEach((componentPath) => {
+ // Process each component folder in parallel for better performance
+ await Promise.all(allComponents.map(async (componentPath) => {π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||
| const componentName = path.basename(componentPath); | ||||||||||||||||||
| const componentDir = path.join(baseDir, componentPath); | ||||||||||||||||||
|
|
@@ -72,7 +72,7 @@ export const getComponentsPackageExports = ( | |||||||||||||||||
| webpackEntries[componentName] = entryFile; | ||||||||||||||||||
|
|
||||||||||||||||||
| // 4. Prepare the DTS bundle generator command for this component, removing the temp file after running it for cleanup | ||||||||||||||||||
| const dtsCommand = `node ${rootDir}/node_modules/.bin/dts-bundle-generator -o ./dist/${componentName}/index.d.ts ${entryFile} ${extraCommands.join( | ||||||||||||||||||
| const dtsCommand = `node --max-old-space-size=1024 ${rootDir}/node_modules/.bin/dts-bundle-generator -o ./dist/${componentName}/index.d.ts ${entryFile} ${extraCommands.join( | ||||||||||||||||||
| "" | ||||||||||||||||||
| )}`; | ||||||||||||||||||
|
Comment on lines
+75
to
77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§Ή Nitpick (assertive) Node memory flag may be insufficient for large component libraries The 1024MB heap size limit might be too restrictive for projects with many components or complex type definitions. Consider making this configurable or using a higher default. Consider parameterizing the memory allocation: - const dtsCommand = `node --max-old-space-size=1024 ${rootDir}/node_modules/.bin/dts-bundle-generator -o ./dist/${componentName}/index.d.ts ${entryFile} ${extraCommands.join(
+ const memorySize = process.env.DTS_MEMORY_SIZE || '2048';
+ const dtsCommand = `node --max-old-space-size=${memorySize} ${rootDir}/node_modules/.bin/dts-bundle-generator -o ./dist/${componentName}/index.d.ts ${entryFile} ${extraCommands.join(π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||
| dtsCommands.push(dtsCommand); | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Build failures should be more informative
When a build fails, only the error message is logged. Consider preserving and displaying the full error output to help developers diagnose issues.
try { execSync(pkg.buildCommand, { stdio: "inherit", cwd: process.cwd() }); console.log(`β ${pkg.name} built successfully\n`); } catch (error) { - console.error(`β Failed to build ${pkg.name}:`, error.message); + console.error(`β Failed to build ${pkg.name}:`); + console.error(` Command: ${pkg.buildCommand}`); + console.error(` Error: ${error.message}`); + if (error.stdout) console.error(` Output: ${error.stdout.toString()}`); process.exit(1); }π Committable suggestion
π€ Prompt for AI Agents