Skip to content

Commit 4d84e38

Browse files
DZakhclaude
andauthored
Migrate to ReScript 12 new build system (#1155)
* Migrate to ReScript 12 new build system Replace rescript-legacy with the new rescript build system across all packages. Rename deprecated rescript.json fields to the new format: bs-dependencies -> dependencies, bsc-flags -> compiler-flags. Remove unused version field from rescript.json (now rejected by new build system) and prune unused @rescript/react dep from test_codegen. https://claude.ai/code/session_01L49r1QXcBnnkymvLrDEowh * Add rescript-schema to init template deps The new ReScript build system requires packages declared in rescript.json dependencies to be directly installed in the project's node_modules. Without this, upward traversal fails to find rescript-schema when running the init template build in CI. https://claude.ai/code/session_01L49r1QXcBnnkymvLrDEowh * Drop rescript-schema from user-facing indexer codegen The Fuel codegen emitted typeXSchema definitions alongside type declarations, but nothing consumed them: fuel param schemas are resolved at runtime via Internal.fuelSupplyParamsSchema / fuelTransferParamsSchema or raw JSON passthrough for logData. Removing the dead schema generation lets us drop 'open RescriptSchema' from the generated Indexer.res entirely, which in turn removes rescript-schema from user project dependencies. https://claude.ai/code/session_01L49r1QXcBnnkymvLrDEowh * Remove dead Rust schema codegen machinery After dropping rescript-schema generation from Indexer.res, the to_rescript_schema impls on TypeDeclMulti, TypeDecl, TypeExpr and TypeIdent had no remaining call sites. The schema_code field on EntityRecordTypeTemplate and res_schema_code on field_types::Field were also set but never read. Removes the entire to_rescript_schema family, the SchemaMode enum, the dependencies() helpers (only used for schema topo-sort), and the now-unused fields and tests. https://claude.ai/code/session_01L49r1QXcBnnkymvLrDEowh * Remove further dead schema-codegen leftovers SelectedFieldTemplate carried a default_value_rescript field that was populated but never read (no callers, no template reference). Utils.BigInt.nativeSchema only existed to back SchemaMode::ForFieldSelection in the Rust codegen, which is gone — drop it too. https://claude.ai/code/session_01L49r1QXcBnnkymvLrDEowh --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6b7c2d7 commit 4d84e38

23 files changed

Lines changed: 45 additions & 591 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
Prefer Public module API for testing.
2929

30-
Verify that tests pass by running a compiler `pnpm rescript-legacy` and tests `pnpm vitest run`.
30+
Verify that tests pass by running a compiler `pnpm rescript` and tests `pnpm vitest run`.
3131

3232
## ReScript
3333

packages/build-envio/src/build-artifact.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ export function buildPackageJson(
9393
*/
9494
export function compileRescript(envioDir: string): void {
9595
console.log("Compiling ReScript...");
96-
// Use the rescript-legacy binary directly to avoid pnpm workspace detection issues.
96+
// Use the rescript binary directly to avoid pnpm workspace detection issues.
9797
// With pnpm's default isolated layout, the bin is in envio's own node_modules.
98-
execSync("./node_modules/.bin/rescript-legacy", {
98+
execSync("./node_modules/.bin/rescript", {
9999
cwd: envioDir,
100100
stdio: "inherit",
101101
});

packages/cli/src/config_parsing/entity_parsing.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
constants::project_paths::DEFAULT_SCHEMA_PATH,
1010
hbs_templating::codegen_templates::DerivedFieldTemplate,
1111
project_paths::{path_utils, ParsedProjectPaths},
12-
type_schema::{SchemaMode, TypeIdent},
12+
type_schema::TypeIdent,
1313
utils::{text::Capitalize, unique_hashmap},
1414
};
1515
use alloy_dyn_abi::DynSolType;
@@ -865,23 +865,15 @@ impl Field {
865865
FieldType::RegularField {
866866
field_type: gql_field_type,
867867
..
868-
} => {
869-
let res_type = self
870-
.field_type
871-
.to_rescript_type(schema)
872-
.context("Failed getting rescript type")?;
873-
874-
Ok(Some(PGField {
875-
field_name: self.name.clone(),
876-
field_type: gql_field_type.to_underlying_postgres_primitive(schema)?,
877-
is_array: gql_field_type.is_array(),
878-
is_index: self.is_indexed_field(entity),
879-
linked_entity: gql_field_type.get_linked_entity(schema)?,
880-
is_primary_key: self.is_primary_key(),
881-
is_nullable: gql_field_type.is_optional(),
882-
res_schema_code: res_type.to_rescript_schema(&SchemaMode::ForDb),
883-
}))
884-
}
868+
} => Ok(Some(PGField {
869+
field_name: self.name.clone(),
870+
field_type: gql_field_type.to_underlying_postgres_primitive(schema)?,
871+
is_array: gql_field_type.is_array(),
872+
is_index: self.is_indexed_field(entity),
873+
linked_entity: gql_field_type.get_linked_entity(schema)?,
874+
is_primary_key: self.is_primary_key(),
875+
is_nullable: gql_field_type.is_optional(),
876+
})),
885877
}
886878
}
887879

packages/cli/src/config_parsing/field_types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,4 @@ pub struct Field {
7272
pub is_nullable: bool,
7373
pub is_array: bool,
7474
pub field_type: Primitive,
75-
pub res_schema_code: String,
7675
}

packages/cli/src/hbs_templating/codegen_templates.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
persisted_state::{PersistedState, PersistedStateJsonString},
2020
project_paths::{path_utils::add_leading_relative_dot, ParsedProjectPaths},
2121
template_dirs::TemplateDirs,
22-
type_schema::{RecordField, SchemaMode, TypeExpr, TypeIdent},
22+
type_schema::{RecordField, TypeExpr, TypeIdent},
2323
utils::text::{Capitalize, CapitalizedOptions, CaseOptions},
2424
};
2525
use anyhow::{anyhow, Context, Result};
@@ -194,7 +194,6 @@ impl CompositeIndexFieldTemplate {
194194
pub struct EntityRecordTypeTemplate {
195195
pub name: CapitalizedOptions,
196196
pub type_code: String,
197-
pub schema_code: String,
198197
pub get_where_filter_code: String,
199198
pub postgres_fields: Vec<field_types::Field>,
200199
pub composite_indices: Vec<Vec<CompositeIndexFieldTemplate>>,
@@ -236,9 +235,7 @@ impl EntityRecordTypeTemplate {
236235
entity.name
237236
))?;
238237

239-
let type_expr = TypeExpr::Record(record_fields);
240-
let type_code = type_expr.to_string();
241-
let schema_code = type_expr.to_rescript_schema(&"t".to_string(), &SchemaMode::ForDb);
238+
let type_code = TypeExpr::Record(record_fields).to_string();
242239

243240
let postgres_fields = entity
244241
.get_fields()
@@ -292,7 +289,6 @@ impl EntityRecordTypeTemplate {
292289
name: entity.name.to_capitalized_options(),
293290
postgres_fields,
294291
type_code,
295-
schema_code,
296292
get_where_filter_code,
297293
derived_fields,
298294
composite_indices,
@@ -656,10 +652,8 @@ impl ContractTemplate {
656652
// template literal.
657653
format!(
658654
"let abi = FuelSDK.transpileAbi((await \
659-
Utils.importPathWithJson(`../{}`))[\"default\"])\n{}\n{}",
660-
abi.path_relative_to_root,
661-
all_abi_type_declarations,
662-
all_abi_type_declarations.to_rescript_schema(&SchemaMode::ForDb)
655+
Utils.importPathWithJson(`../{}`))[\"default\"])\n{}",
656+
abi.path_relative_to_root, all_abi_type_declarations,
663657
)
664658
}
665659
};
@@ -847,7 +841,6 @@ impl FieldSelection {
847841
block_field_templates.push(SelectedFieldTemplate {
848842
name: name.clone(),
849843
res_name,
850-
default_value_rescript: field.data_type.get_default_value_rescript(),
851844
ts_type: field.data_type.to_ts_type_string(),
852845
res_type: field.data_type.to_string(),
853846
});
@@ -865,7 +858,6 @@ impl FieldSelection {
865858
transaction_field_templates.push(SelectedFieldTemplate {
866859
name: name.clone(),
867860
res_name,
868-
default_value_rescript: field.data_type.get_default_value_rescript(),
869861
ts_type: field.data_type.to_ts_type_string(),
870862
res_type: field.data_type.to_string(),
871863
});
@@ -901,7 +893,6 @@ struct SelectedFieldTemplate {
901893
res_name: String,
902894
res_type: String,
903895
ts_type: String,
904-
default_value_rescript: String,
905896
}
906897

907898
#[derive(Serialize)]
@@ -1633,8 +1624,6 @@ type handlerContext = {{
16331624
//**CONTRACTS**
16341625
//*************
16351626
1636-
open RescriptSchema
1637-
16381627
module Transaction = {{
16391628
type t = {transaction_module_type}
16401629
}}

packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_generates_correct_types_and_values.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ expression: project_template.indexer_code
66
//**CONTRACTS**
77
//*************
88

9-
open RescriptSchema
10-
119
module Transaction = {
1210
type t = {
1311
@deprecated("Not selected for this event. To enable, add to config.yaml:\nevents:\n - event: global\n field_selection:\n transaction_fields:\n - transactionIndex")

packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_multiple_chains.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ expression: project_template.indexer_code
66
//**CONTRACTS**
77
//*************
88

9-
open RescriptSchema
10-
119
module Transaction = {
1210
type t = {
1311
@deprecated("Not selected for this event. To enable, add to config.yaml:\nevents:\n - event: global\n field_selection:\n transaction_fields:\n - transactionIndex")

0 commit comments

Comments
 (0)