Skip to content

Commit e318df5

Browse files
committed
chore: bundle the root package.json as an installable package
1 parent bde3fbc commit e318df5

File tree

13 files changed

+195
-141
lines changed

13 files changed

+195
-141
lines changed

.circleci/src/workflows/workflows/@main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ linux-x64:
55
- equal: [ develop, << pipeline.git.branch >> ]
66
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
77
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
8-
- equal: [ 'chore/merge_gql_package_w_data_context', << pipeline.git.branch >> ]
8+
- equal: [ 'chore/bundle_package_root', << pipeline.git.branch >> ]
99
- matches:
1010
pattern: /^release\/\d+\.\d+\.\d+$/
1111
value: << pipeline.git.branch >>

.circleci/workflows.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,7 +3718,7 @@ workflows:
37183718
- update-v8-snapshot-cache-on-develop
37193719
- << pipeline.git.branch >>
37203720
- equal:
3721-
- chore/merge_gql_package_w_data_context
3721+
- chore/bundle_package_root
37223722
- << pipeline.git.branch >>
37233723
- matches:
37243724
pattern: /^release\/\d+\.\d+\.\d+$/
@@ -3775,7 +3775,7 @@ workflows:
37753775
- update-v8-snapshot-cache-on-develop
37763776
- << pipeline.git.branch >>
37773777
- equal:
3778-
- chore/merge_gql_package_w_data_context
3778+
- chore/bundle_package_root
37793779
- << pipeline.git.branch >>
37803780
- matches:
37813781
pattern: /^release\/\d+\.\d+\.\d+$/
@@ -3843,7 +3843,7 @@ workflows:
38433843
- update-v8-snapshot-cache-on-develop
38443844
- << pipeline.git.branch >>
38453845
- equal:
3846-
- chore/merge_gql_package_w_data_context
3846+
- chore/bundle_package_root
38473847
- << pipeline.git.branch >>
38483848
- matches:
38493849
pattern: /^release\/\d+\.\d+\.\d+$/
@@ -4331,7 +4331,7 @@ workflows:
43314331
- update-v8-snapshot-cache-on-develop
43324332
- << pipeline.git.branch >>
43334333
- equal:
4334-
- chore/merge_gql_package_w_data_context
4334+
- chore/bundle_package_root
43354335
- << pipeline.git.branch >>
43364336
- matches:
43374337
pattern: /^release\/\d+\.\d+\.\d+$/
@@ -5168,7 +5168,7 @@ workflows:
51685168
- update-v8-snapshot-cache-on-develop
51695169
- << pipeline.git.branch >>
51705170
- equal:
5171-
- chore/merge_gql_package_w_data_context
5171+
- chore/bundle_package_root
51725172
- << pipeline.git.branch >>
51735173
- matches:
51745174
pattern: /^release\/\d+\.\d+\.\d+$/

.cursor/BUGBOT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Essential rules for reviewing code changes in the Cypress monorepo.
131131
- Focus: Scaffolding logic, template accuracy, project initialization
132132

133133
### Utility Packages (Lower Priority)
134-
- **@packages/root**: Root package (dummy package)
134+
- **@packages/root**: Root package
135135
- Focus: Monorepo setup, package coordination
136136
- **@packages/example**: Example project
137137
- Focus: Example accuracy, documentation quality, test examples

guides/esm-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
- [x] packages/reporter ✅ **COMPLETED**
5656
- [ ] packages/resolve-dist **PARTIAL** - entry point is JS
5757
- [ ] packages/rewriter **PARTIAL** - entry point is JS
58-
- [ ] packages/root
58+
- [x] packages/root
5959
- [x] packages/runner ✅ **COMPLETED**
6060
- [ ] packages/scaffold-config **PARTIAL** - entry point is JS
6161
- [ ] packages/server **PARTIAL** - many source/test files in JS. highest priority

packages/root/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
index.js
2+
index.mjs

packages/root/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Purpose
2+
3+
Bundles the monorepo root `package.json` as an installable package, allowing `@packages/root` to be installed in any context without having a absolute reference ot the root `package.json`
4+
5+
In order to accomplish this, `rollup` is used bundle the `package.json`, as packages may be interpreted in place or be installed inside the `node_modules` directory. This package builds an `index.mjs` file for packages using `vite`/ ES Modules and an `index.js` file for any CommonJS entrypoints.

packages/root/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/root/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pkg from '../../package.json'
2+
3+
export default pkg

packages/root/package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
{
22
"name": "@packages/root",
33
"version": "0.0.0-development",
4-
"description": "dummy package pointing at the root package",
4+
"description": "bundles the root package.json as an installable package",
55
"main": "index.js",
6+
"scripts": {
7+
"build": "yarn build:cjs && yarn build:esm",
8+
"build:cjs": "rimraf index.js && rollup -c rollup.config.mjs -f cjs -o index.js",
9+
"build:esm": "rimraf index.mjs && rollup -c rollup.config.mjs -f esm -o index.mjs",
10+
"build:prod": "yarn build"
11+
},
12+
"devDependencies": {
13+
"@rollup/plugin-json": "^6.1.0",
14+
"rimraf": "^6.0.1",
15+
"rollup": "^4.52.0",
16+
"typescript": "^5.6.3"
17+
},
18+
"module": "index.mjs",
619
"nx": {}
720
}

packages/root/rollup.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import json from '@rollup/plugin-json'
2+
3+
export default {
4+
input: 'index.ts',
5+
// inlines the root package.json into the bundle
6+
plugins: [json()],
7+
}

0 commit comments

Comments
 (0)