1616
1717** If you modify package.json, package-scripts.yml, or build configs:**
1818
19- 1 . ** Test the prepack script: **
19+ ### Step 1: ALWAYS Test Clean Install First
2020
21- ``` bash
22- yarn run prepack
23- # Should succeed without errors
24- ```
21+ This is the ** MOST CRITICAL** test - it's what CI does first, and installation failures block everything else.
2522
26- 2 . ** Test yalc publish (CRITICAL):**
23+ ``` bash
24+ # Remove node_modules to simulate CI environment
25+ rm -rf node_modules
2726
28- ``` bash
29- yarn run yalc.publish
30- # Should publish successfully
31- ```
27+ # Test the exact command CI uses
28+ yarn install --frozen-lockfile
3229
33- 3 . ** Verify build artifacts exist at expected paths:**
30+ # If this fails, STOP and fix it before testing anything else
31+ ```
3432
35- ``` bash
36- # Check the path referenced in package-scripts.yml
37- ls -la lib/ReactOnRails.full.js
33+ ** Why this matters:** Your local ` node_modules ` may mask dependency issues. CI starts fresh, so you must too.
3834
39- # If package-scripts.yml references packages/*, check that too
40- ls -la packages/* /lib/* .js
41- ```
35+ ### Step 2: Test Build Scripts
4236
43- 4 . ** Test clean install:**
44- ``` bash
45- rm -rf node_modules
46- yarn install
47- # Should install without errors
48- ```
37+ ``` bash
38+ # Build all packages
39+ yarn run build
40+
41+ # Should succeed without errors
42+ ```
43+
44+ ### Step 3: Test Package-Specific Scripts
45+
46+ ``` bash
47+ # Test prepack/prepare scripts work
48+ yarn nps build.prepack
49+
50+ # Test yalc publish (CRITICAL for local development)
51+ yarn run yalc:publish
52+
53+ # Should publish all workspace packages successfully
54+ ```
55+
56+ ### Step 4: Verify Build Artifacts
57+
58+ ``` bash
59+ # Check that build outputs exist at expected paths
60+ ls -la packages/react-on-rails/lib/ReactOnRails.full.js
61+ ls -la packages/react-on-rails-pro/lib/ReactOnRails.full.js
62+ ls -la packages/react-on-rails-pro-node-renderer/lib/ReactOnRailsProNodeRenderer.js
63+
64+ # If any are missing, investigate why
65+ ```
66+
67+ ### Step 5: Run Linting
68+
69+ ``` bash
70+ # Ruby linting
71+ bundle exec rubocop
72+
73+ # JS/TS formatting
74+ yarn start format.listDifferent
75+ ```
4976
5077## When Directory Structure Changes
5178
@@ -56,10 +83,72 @@ If you rename/move directories that contain build artifacts:
56833 . ** Test in a fresh clone to ensure no local assumptions**
57844 . ** Consider adding a CI job to validate artifact paths**
5885
59- ## Real Example: What Went Wrong
86+ ## Workspace Dependencies: Yarn Classic vs Yarn Berry
87+
88+ ** CRITICAL: This project uses Yarn Classic (v1.x), not Yarn Berry (v2+)**
89+
90+ Check
` package.json ` for:
` "packageManager": "[email protected] " ` 91+
92+ ### Correct Workspace Dependency Syntax
93+
94+ For Yarn Classic workspaces:
95+
96+ ``` json
97+ {
98+ "dependencies" : {
99+ "react-on-rails" : " *"
100+ }
101+ }
102+ ```
103+
104+ ** DO NOT USE:**
60105
61- In Sep 2024, we moved ` node_package/ ` → ` packages/react-on-rails/ ` . The path in
106+ - ` "workspace:*" ` - This is Yarn Berry v2+ syntax, will cause installation errors
107+ - ` "file:../react-on-rails" ` - This bypasses workspace resolution
108+
109+ ### Why ` * ` Works
110+
111+ In Yarn Classic workspaces:
112+
113+ - ` "*" ` tells Yarn to resolve to the local workspace package
114+ - Yarn automatically links to the workspace version
115+ - This is the official Yarn v1 workspace syntax
116+
117+ ### Testing Workspace Changes
118+
119+ When modifying workspace dependencies in package.json:
120+
121+ ``` bash
122+ # 1. Remove node_modules to test fresh install
123+ rm -rf node_modules
124+
125+ # 2. Test CI command - this will fail immediately if syntax is wrong
126+ yarn install --frozen-lockfile
127+
128+ # 3. Verify workspace linking worked
129+ yarn workspaces info
130+
131+ # 4. Test that packages can import each other
132+ yarn run build
133+ ```
134+
135+ ## Real Examples: What Went Wrong
136+
137+ ### Example 1: Path Reference Issue (Sep 2024)
138+
139+ We moved ` node_package/ ` → ` packages/react-on-rails/ ` . The path in
62140package-scripts.yml was updated to ` packages/react-on-rails/lib/ReactOnRails.full.js ` .
63141Later, the structure was partially reverted to ` lib/ ` at root, but package-scripts.yml
64142wasn't updated. This broke yalc publish silently for 7 weeks. Manual testing of
65143` yarn run yalc.publish ` would have caught this immediately.
144+
145+ ### Example 2: Workspace Protocol Issue (Nov 2024)
146+
147+ Changed workspace dependencies from ` "*" ` to ` "workspace:*" ` without testing clean install.
148+ This caused CI to fail with: ` Couldn't find any versions for "react-on-rails" that matches "workspace:*" `
149+
150+ ** Root cause:** Assumed ` workspace:* ` was standard, but it's only supported in Yarn Berry v2+.
151+ This project uses Yarn Classic v1.x which requires ` "*" ` for workspace dependencies.
152+
153+ ** Lesson:** ALWAYS test ` yarn install --frozen-lockfile ` after modifying workspace dependencies.
154+ Your local node_modules masked the issue - CI starts fresh and caught it immediately.
0 commit comments