Skip to content

Commit 660cab3

Browse files
Complete workspace migration: move tests, scripts, and babel config
**File Moves:** - Move node_package/tests/* -> packages/react-on-rails/tests/ - Move node_package/scripts/* -> packages/react-on-rails/scripts/ - Move node_package/babel.config.js -> packages/react-on-rails/babel.config.cjs - Remove empty node_package/ directory **Path Updates:** - Updated all test import paths from ../../packages/react-on-rails/src -> ../src - Updated jest.setup.js mock paths to use relative imports - Updated Jest config setupFiles and moduleNameMapper paths - Updated Knip babel config and ignore file paths - Updated root package.json release script paths - Updated script/convert for new workspace structure **Configuration Fixes:** - Renamed babel.config.js to babel.config.cjs for ES module compatibility - Added React and TypeScript presets to babel config - Fixed workspace package test command to run from root **Result:** - Workspace package is now fully self-contained with src/, tests/, scripts/, lib/ - All tests pass when run from root: yarn test - Git history preserved for all moved files - Build output goes to packages/react-on-rails/lib/ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 3250a03 commit 660cab3

28 files changed

+53
-49
lines changed

jest.config.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export default {
1313
},
1414
}),
1515
testEnvironment: 'jsdom',
16-
setupFiles: ['<rootDir>/node_package/tests/jest.setup.js'],
16+
setupFiles: ['<rootDir>/packages/react-on-rails/tests/jest.setup.js'],
1717
// React Server Components tests require React 19 and only run with Node version 18 (`newest` in our CI matrix)
1818
moduleNameMapper:
1919
nodeVersion < 18
2020
? {
21-
'react-on-rails-rsc/client': '<rootDir>/node_package/tests/emptyForTesting.js',
22-
'^@testing-library/dom$': '<rootDir>/node_package/tests/emptyForTesting.js',
23-
'^@testing-library/react$': '<rootDir>/node_package/tests/emptyForTesting.js',
21+
'react-on-rails-rsc/client': '<rootDir>/packages/react-on-rails/tests/emptyForTesting.js',
22+
'^@testing-library/dom$': '<rootDir>/packages/react-on-rails/tests/emptyForTesting.js',
23+
'^@testing-library/react$': '<rootDir>/packages/react-on-rails/tests/emptyForTesting.js',
2424
}
2525
: {},
2626
};

knip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ const config: KnipConfig = {
2626
'!packages/react-on-rails/lib/**',
2727
],
2828
babel: {
29-
config: ['node_package/babel.config.js'],
29+
config: ['packages/react-on-rails/babel.config.cjs'],
3030
},
3131
ignore: [
32-
'node_package/tests/emptyForTesting.js',
32+
'packages/react-on-rails/tests/emptyForTesting.js',
3333
// Build output directories that should be ignored
3434
'packages/react-on-rails/lib/**',
3535
// Pro features exported for external consumption

node_package/babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
"lint": "nps eslint",
6969
"check": "yarn run lint && yarn run test && yarn run type-check",
7070
"type-check": "yarn workspace react-on-rails type-check",
71-
"release:patch": "node_package/scripts/release patch",
72-
"release:minor": "node_package/scripts/release minor",
73-
"release:major": "node_package/scripts/release major",
71+
"release:patch": "packages/react-on-rails/scripts/release patch",
72+
"release:minor": "packages/react-on-rails/scripts/release minor",
73+
"release:major": "packages/react-on-rails/scripts/release major",
7474
"postinstall": "test -f .lefthook.yml && test -d .git && command -v bundle >/dev/null 2>&1 && bundle exec lefthook install || true"
7575
},
7676
"repository": {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }],
4+
'@babel/preset-react',
5+
'@babel/preset-typescript',
6+
],
7+
};

packages/react-on-rails/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "yarn run clean && yarn run tsc --declaration",
99
"build-watch": "yarn run clean && yarn run tsc --watch",
1010
"clean": "rm -rf ./lib",
11-
"test": "cd ../.. && jest node_package/tests",
11+
"test": "cd ../.. && jest packages/react-on-rails/tests",
1212
"type-check": "yarn run tsc --noEmit --noErrorTruncation"
1313
},
1414
"repository": {
File renamed without changes.

node_package/tests/Authenticity.test.js renamed to packages/react-on-rails/tests/Authenticity.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ReactOnRails from '../../packages/react-on-rails/src/ReactOnRails.client.ts';
1+
import ReactOnRails from '../src/ReactOnRails.client.ts';
22

33
const testToken = 'TEST_CSRF_TOKEN';
44

node_package/tests/ComponentRegistry.test.js renamed to packages/react-on-rails/tests/ComponentRegistry.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import * as React from 'react';
77
import * as createReactClass from 'create-react-class';
88

9-
import * as ComponentRegistry from '../../packages/react-on-rails/src/pro/ComponentRegistry.ts';
9+
import * as ComponentRegistry from '../src/pro/ComponentRegistry.ts';
1010

1111
const onPageLoadedCallbacks = [];
1212
const onPageUnloadedCallbacks = [];
1313

14-
jest.mock('../../packages/react-on-rails/src/pageLifecycle.ts', () => ({
14+
jest.mock('../src/pageLifecycle.ts', () => ({
1515
onPageLoaded: jest.fn((cb) => {
1616
onPageLoadedCallbacks.push(cb);
1717
cb();
@@ -22,7 +22,7 @@ jest.mock('../../packages/react-on-rails/src/pageLifecycle.ts', () => ({
2222
}),
2323
}));
2424

25-
jest.mock('../../packages/react-on-rails/src/context.ts', () => ({
25+
jest.mock('../src/context.ts', () => ({
2626
getRailsContext: () => ({ componentRegistryTimeout: 100 }),
2727
}));
2828

0 commit comments

Comments
 (0)