Updated project to React 19

This commit is contained in:
Richard Osborne
2025-12-07 17:32:53 +01:00
parent 2153baf627
commit 8fed72d025
70 changed files with 4534 additions and 5309 deletions

View File

@@ -158,3 +158,263 @@ React 19 removed the deprecated `findDOMNode` API.
**Total files modified**: 8
**Build status**: All packages compiling successfully (was 95 errors, now 0)
**Confidence**: 8/10 (code compiles, but manual testing of `scrollToElement` functionality recommended)
---
## [2025-12-07] - Cline (AI-assisted) - P0 Critical Items from TASK-000 Analysis
### Summary
Completed the P0 critical items identified in the TASK-000 dependency analysis:
1. Fixed Storybook scripts and dependencies in noodl-core-ui
2. Standardized TypeScript version across packages
---
## P0 Item 1: Fix Storybook in noodl-core-ui
### Issue
- Old Storybook CLI commands (`start-storybook`, `build-storybook`) were being used
- Missing framework-specific packages required for Storybook 8.x
- Configuration file (`main.ts`) using deprecated format
### Changes Made
#### package.json scripts update
```json
// OLD
"start": "start-storybook -p 6006 -s public",
"build": "build-storybook -s public"
// NEW
"start": "storybook dev -p 6006",
"build": "storybook build"
```
#### Added Storybook dependencies
- `@storybook/addon-essentials`: ^8.6.14
- `@storybook/addon-interactions`: ^8.6.14
- `@storybook/addon-links`: ^8.6.14
- `@storybook/addon-measure`: ^8.6.14
- `@storybook/react`: ^8.6.14
- `@storybook/react-webpack5`: ^8.6.14
- Updated `storybook` from ^9.1.3 to ^8.6.14 (version consistency)
#### Updated `.storybook/main.ts`
- Changed from CommonJS (`module.exports`) to ES modules (`export default`)
- Added proper TypeScript typing with `StorybookConfig`
- Updated framework config from deprecated `core.builder` to modern `framework.name` format
- Kept custom webpack aliases for editor integration
**Files Modified**:
- `packages/noodl-core-ui/package.json`
- `packages/noodl-core-ui/.storybook/main.ts`
---
## P0 Item 2: Standardize TypeScript Version
### Issue
- `packages/noodl-viewer-react` was using TypeScript ^5.1.3
- Rest of the monorepo (root, noodl-core-ui, noodl-editor) uses ^4.9.5
- Version mismatch can cause type compatibility issues
### Fix
Changed `packages/noodl-viewer-react/package.json`:
```json
// OLD
"typescript": "^5.1.3"
// NEW
"typescript": "^4.9.5"
```
**File Modified**:
- `packages/noodl-viewer-react/package.json`
---
## Validation
### Build Test
- `npm run build:editor:_viewer`: **PASS**
- Viewer builds successfully with TypeScript 4.9.5
### Install Test
- `npm install`: **PASS**
- No peer dependency errors
- All Storybook packages installed correctly
---
## Additional Files Modified (P0 Session)
- [x] `packages/noodl-core-ui/package.json` - Scripts + Storybook dependencies
- [x] `packages/noodl-core-ui/.storybook/main.ts` - Modern Storybook 8 config
- [x] `packages/noodl-viewer-react/package.json` - TypeScript version alignment
---
## Notes
### Storybook Version Discovery
The `storybook` CLI package uses different versioning than `@storybook/*` packages:
- `storybook` CLI: 9.1.3 exists but is incompatible with 8.x addon packages
- `@storybook/addon-*`: Latest stable is 8.6.14
- Solution: Use consistent 8.6.14 across all Storybook packages
### TypeScript Version Decision
- Chose to standardize on 4.9.5 (matching majority) rather than upgrade all to 5.x
- TypeScript 5.x upgrade can be done in a future task with proper testing
- This ensures consistency without introducing new breaking changes
---
## [2025-07-12] - Cline (AI-assisted) - P1 High Priority Items from TASK-000 Analysis
### Summary
Completed the P1 high priority items identified in the TASK-000 dependency analysis:
1. Updated webpack plugins in noodl-viewer-react (copy-webpack-plugin, clean-webpack-plugin, webpack-dev-server)
2. Aligned css-loader and style-loader versions
3. Updated Jest to v29 across packages
4. Updated copy-webpack-plugin in noodl-viewer-cloud
---
## P1.1: Update Webpack Plugins in noodl-viewer-react
### Dependencies Updated
| Package | Old Version | New Version |
|---------|-------------|-------------|
| clean-webpack-plugin | ^1.0.1 | ^4.0.0 |
| copy-webpack-plugin | ^4.6.0 | ^12.0.2 |
| webpack-dev-server | ^3.11.2 | ^4.15.2 |
| css-loader | ^5.0.0 | ^6.11.0 |
| style-loader | ^2.0.0 | ^3.3.4 |
| jest | ^28.1.0 | ^29.7.0 |
| ts-jest | ^28.0.3 | ^29.4.1 |
| @types/jest | ^27.5.2 | ^29.5.14 |
### Webpack Config Changes Required
#### Breaking Change: clean-webpack-plugin v4
- Old API: `new CleanWebpackPlugin(outputPath, { allowExternal: true })`
- New API: Uses webpack 5's built-in `output.clean: true` option
- Import changed from `require('clean-webpack-plugin')` to `const { CleanWebpackPlugin } = require('clean-webpack-plugin')`
#### Breaking Change: copy-webpack-plugin v12
- Old API: `new CopyWebpackPlugin([patterns])`
- New API: `new CopyWebpackPlugin({ patterns: [...] })`
- `transformPath` option removed, use `to` function instead
- Added `info: { minimized: true }` to prevent Terser from minifying copied JS files
**Files Modified**:
- `packages/noodl-viewer-react/webpack-configs/webpack.viewer.common.js`
- `packages/noodl-viewer-react/webpack-configs/webpack.deploy.common.js`
- `packages/noodl-viewer-react/webpack-configs/webpack.ssr.common.js`
### Webpack Config Migration Example
```javascript
// OLD (v4.6.0)
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
new CleanWebpackPlugin(outputPath, { allowExternal: true }),
new CopyWebpackPlugin([
{
from: 'static/shared/**/*',
transformPath: (targetPath) => stripStartDirectories(targetPath, 2)
}
])
// NEW (v12.0.2)
const CopyWebpackPlugin = require('copy-webpack-plugin');
// output.clean: true in config
output: {
clean: true
},
new CopyWebpackPlugin({
patterns: [
{
from: 'static/shared',
to: '.',
noErrorOnMissing: true,
info: { minimized: true }
}
]
})
```
---
## P1.2: Update copy-webpack-plugin in noodl-viewer-cloud
### Dependencies Updated
| Package | Old Version | New Version |
|---------|-------------|-------------|
| copy-webpack-plugin | ^4.6.0 | ^12.0.2 |
| clean-webpack-plugin | (not present) | ^4.0.0 |
**Files Modified**:
- `packages/noodl-viewer-cloud/package.json`
- `packages/noodl-viewer-cloud/webpack-configs/webpack.viewer.common.js`
---
## Build Issue: Terser Minification of Copied Files
### Problem
When using copy-webpack-plugin v12 with webpack 5 production mode, Terser tries to minify all JS files in the output directory, including copied static files. This caused errors because some copied JS files contained modern syntax.
### Solution
Added `info: { minimized: true }` to CopyWebpackPlugin patterns to tell webpack these files are already minimized and should not be processed by Terser.
```javascript
{
from: 'static/deploy',
to: '.',
noErrorOnMissing: true,
info: { minimized: true } // <-- Prevents Terser processing
}
```
---
## Validation
### Build Test
- `npm run build:editor:_viewer`: **PASS**
- All three viewer builds (viewer, deploy, ssr) complete successfully
### Install Test
- `npm install`: **PASS**
- Net reduction of 197 packages (removed 214 old, added 17 new)
---
## Files Modified (P1 Session)
### noodl-viewer-react
- [x] `packages/noodl-viewer-react/package.json` - All dependency updates
- [x] `packages/noodl-viewer-react/webpack-configs/webpack.viewer.common.js`
- [x] `packages/noodl-viewer-react/webpack-configs/webpack.deploy.common.js`
- [x] `packages/noodl-viewer-react/webpack-configs/webpack.ssr.common.js`
### noodl-viewer-cloud
- [x] `packages/noodl-viewer-cloud/package.json`
- [x] `packages/noodl-viewer-cloud/webpack-configs/webpack.viewer.common.js`
---
## Summary
**P0 + P1 Total files modified**: 14
**Build status**: All packages building successfully ✅
**Packages reduced**: 197 (cleaner dependency tree with modern versions)
### Dependency Modernization Benefits
- Modern plugin APIs with better webpack 5 integration
- Smaller bundle sizes with newer optimizers
- Better support for ES modules and modern JS
- Consistent Jest 29 across all packages
- Removed deprecated clean-webpack-plugin API

View File

@@ -72,11 +72,34 @@ After this task:
- [x] Improve build performance
- [x] Fix hot reload issues
### Additional Items from TASK-000 Analysis
Based on [TASK-000 Dependency Analysis](../TASK-000-dependency-analysis/README.md), the following items should be added:
#### 🔴 P0 - Critical (Added) ✅ COMPLETED
- [x] **Fix Storybook scripts in noodl-core-ui** - Updated to Storybook 8.6.14 with modern CLI commands
- [x] **Standardize TypeScript version** - noodl-viewer-react updated to 4.9.5 to match rest of monorepo
#### 🟡 P1 - High Priority (Added) ✅ COMPLETED
- [x] Update webpack plugins in noodl-viewer-react:
- [x] copy-webpack-plugin 4.6.0 → 12.0.2
- [x] clean-webpack-plugin 1.0.1 → 4.0.0 (replaced with output.clean)
- [x] webpack-dev-server 3.11.2 → 4.15.2
- [x] Align css-loader (5.0.0 → 6.11.0) and style-loader (2.0.0 → 3.3.4) in noodl-viewer-react
- [x] Update Jest to v29 across all packages (jest 29.7.0, ts-jest 29.4.1, @types/jest 29.5.14)
- [x] Update copy-webpack-plugin in noodl-viewer-cloud (4.6.0 → 12.0.2)
#### 🟢 P2 - Nice to Have ✅ COMPLETED
- [x] Update @types/react (19.0.0 → 19.2.7) and @types/react-dom (19.0.0 → 19.2.3)
- [x] Update Babel packages to latest patch versions (already at latest: 7.28.3/7.27.1)
### Out of Scope
- Major refactoring (that's later tasks)
- New features
- TSFixme cleanup (TASK-002)
- Storybook 9 migration (can be separate task)
- ESLint 9 migration (significant config changes required)
- Electron upgrade (31 → 39 requires separate planning)
- Express 5.x migration (breaking changes)
- Dugite 3.0 upgrade (breaking API changes)
## Technical Approach