Skip to content

Mention which package was not found in the build state. #7696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions rescript.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"name": "rescript",
"bs-dependencies": [
"@tests/gentype-react-example"
]
"@tests/gentype-react-example",
"@tests/rescript-react",
"@tests/analysis",
"@tests/generic-jsx-transform",
"@tests/reanalyze-deadcode",
"@tests/incremental-typechecking",
"@tests/reanalyze-termination"
],
"jsx": { "version": 4 }
}
7 changes: 6 additions & 1 deletion rewatch/src/build/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ fn clean_source_files(build_state: &BuildState, root_package: &packages::Package
.values()
.filter_map(|module| match &module.source_type {
SourceType::SourceFile(source_file) => {
let package = build_state.packages.get(&module.package_name).unwrap();
let package = build_state.packages.get(&module.package_name).unwrap_or_else(|| {
panic!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to bubble this up as a Result instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To what end, I wonder? This is a configuration error or cli argument error. Feels fine to fail her in my opinion.
We should, of course, communicate why it failed.

"Could not find package for \"{}\" in build state.\nMaybe you forgot to add the relative path to your root rescript.config.json file?",
&module.package_name
)
});
Some(
root_package
.config
Expand Down
7 changes: 6 additions & 1 deletion rewatch/src/build/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,13 @@ pub fn read_config(package_dir: &Path) -> Result<config::Config> {

if Path::new(&rescript_json_path).exists() {
config::Config::new(&rescript_json_path)
} else {
} else if Path::new(&bsconfig_json_path).exists() {
config::Config::new(&bsconfig_json_path)
} else {
Err(anyhow!(
"Could not find rescript.json or bsconfig.json in package directory: {}",
package_dir.to_string_lossy()
))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test-generic-jsx-transform",
"name": "@tests/generic-jsx-transform",
"sources": [
{
"dir": "src",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@@config({
flags: ["-bs-jsx", "4", "-bs-jsx-module", "GenericJsx"],
})

// <div
// ^com

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test-generic-jsx-transform",
"name": "@tests/incremental-typechecking",
"sources": [
{
"dir": "src",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
let x = Js.Json.Array()
// ^com
// let x = Js.Json.Array()
// ^com
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ module WithVariant = {
type t = One({miss: bool}) | Two(bool)
}

let x = WithVariant.One()
// ^com
// let x = WithVariant.One()
// ^com
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests-reanalyze/deadcode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clean": "rescript clean"
},
"dependencies": {
"@rescript/react": "link:../../../dependencies/rescript-react",
"@tests/rescript-react": "link:../../../dependencies/rescript-react",
"rescript": "workspace:^"
}
}
4 changes: 2 additions & 2 deletions tests/analysis_tests/tests-reanalyze/deadcode/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"unsuppress": [],
"transitive": true
},
"name": "sample-typescript-app",
"name": "@tests/reanalyze-deadcode",
"jsx": { "version": 4 },
"bs-dependencies": ["@rescript/react"],
"bs-dependencies": ["@tests/rescript-react"],
"sources": [
{
"dir": "src",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"suppress": [],
"unsuppress": []
},
"name": "arnold",
"name": "@tests/reanalyze-termination",
"bs-dependencies": [],
"sources": [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis_tests/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"private": true,
"scripts": {
"build": "rescript legacy build",
"clean": "rescript clean"
"clean": "rescript clean ../../.."
},
"dependencies": {
"@rescript/react": "link:../../dependencies/rescript-react",
"@tests/rescript-react": "link:../../dependencies/rescript-react",
"rescript": "workspace:^"
}
}
4 changes: 2 additions & 2 deletions tests/analysis_tests/tests/rescript.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test",
"name": "@tests/analysis",
"reanalyze": {
"analysis": ["dce"]
},
Expand All @@ -10,7 +10,7 @@
}
],
"bsc-flags": ["-w -33-44-8"],
"bs-dependencies": ["@rescript/react"],
"bs-dependencies": ["@tests/rescript-react"],
"jsx": { "version": 4 },
"suffix": ".res.js",
"editor": {
Expand Down
2 changes: 1 addition & 1 deletion tests/dependencies/rescript-react/rescript.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@rescript/react",
"name": "@tests/rescript-react",
"jsx": {
"version": 4,
"mode": "classic"
Expand Down
2 changes: 1 addition & 1 deletion tests/gentype_tests/typescript-react-example/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"name": "@tests/gentype-react-example",
"bsc-flags": [],
"jsx": { "version": 4 },
"bs-dependencies": ["@rescript/react"],
"bs-dependencies": ["@tests/rescript-react"],
"sources": [
{
"dir": "src",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* TypeScript file generated from NestedTuples.res by genType. */

/* eslint-disable */
/* tslint:disable */

import * as NestedTuplesJS from './NestedTuples.res.js';

export type coord = [number, number, (undefined | number)];

export type coord2 = [number, number, (null | undefined | number)];

export type person = { readonly name: string; readonly age: number };

export type couple = [person, person];

export const testTuple: (param:[number, number]) => number = NestedTuplesJS.testTuple as any;

export const origin: [number, number, (undefined | number)] = NestedTuplesJS.origin as any;

export const computeArea: (param:[number, number, (undefined | number)]) => number = NestedTuplesJS.computeArea as any;

export const computeAreaWithIdent: (param:coord) => number = NestedTuplesJS.computeAreaWithIdent as any;

export const computeAreaNoConverters: (param:[number, number]) => number = NestedTuplesJS.computeAreaNoConverters as any;

export const coord2d: <T1,T2,T3>(x:T1, y:T2) => [T1, T2, (undefined | T3)] = NestedTuplesJS.coord2d as any;

export const getFirstName: (param:couple) => string = NestedTuplesJS.getFirstName as any;

export const marry: (first:person, second:person) => couple = NestedTuplesJS.marry as any;

export const changeSecondAge: (param:couple) => couple = NestedTuplesJS.changeSecondAge as any;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/* TypeScript file generated from NestedTypes.res by genType. */

/* eslint-disable */
/* tslint:disable */

import * as NestedTypesJS from './NestedTypes.res.js';

import type {Json_t as Js_Json_t} from '../../src/shims/Js.shim';

import type {List_t as Belt_List_t} from '../../src/shims/Belt.shim';

import type {M_t__ as TypeNameSanitize_M_t__} from '../../src/TypeNameSanitize.gen';

import type {list} from '../../src/shims/RescriptPervasives.shim';

import type {t_ as TypeNameSanitize_t_} from '../../src/TypeNameSanitize.gen';

import type {t as Location_t} from '../../src/location/location.gen';

export type t = number;

export type typeWithVars<x,y,z> =
{ TAG: "A"; _0: x; _1: y }
| { TAG: "B"; _0: z };

export type tree = {
readonly label: string;
readonly left?: tree;
readonly right?: tree
};

export type selfRecursive = { readonly self: selfRecursive };

export type mutuallyRecursiveA = { readonly b: mutuallyRecursiveB };

export type mutuallyRecursiveB = { readonly a: mutuallyRecursiveA };

export abstract class opaqueVariant { protected opaque!: any }; /* simulate opaque types */

export type twice<a> = [a, a];

export type genTypeMispelled = number;

export type dictString = {[id: string]: string};

export type nullOrString = (null | string);

export type nullOrString2 = (null | string);

export type nullOrString3 = (null | string);

export type nullOrString4 = (null | string);

export type nullableOrString = (null | undefined | string);

export type nullableOrString2 = (null | undefined | string);

export type nullableOrString3 = (null | undefined | string);

export type nullableOrString4 = (null | undefined | string);

export type undefinedOrString = (undefined | string);

export type undefinedOrString2 = (undefined | string);

export type undefinedOrString3 = (undefined | string);

export type undefinedOrString4 = (undefined | string);

export type record = { readonly i: number; readonly s: string };

export type decorator<a,b> = (_1:a) => b;

export type marshalFields = {
readonly _rec: string;
readonly _switch: string;
readonly switch: string;
readonly __: string;
readonly ___: string;
readonly foo__: string;
readonly _foo__: string;
readonly _Uppercase: string;
readonly _Uppercase__: string
};

export type marshalMutableField = { _match: number };

export type ocaml_array<a> = a[];

export type someRecord = { readonly id: number };

export type instantiateTypeParameter = ocaml_array<someRecord>;

export type vector<a> = [a, a];
export type Vector<a> = vector<a>;

export type date = Date;

export type ObjectId_t = number;

export type tPrimed = [TypeNameSanitize_t_, TypeNameSanitize_M_t__];

export const someIntList: list<number> = NestedTypesJS.someIntList as any;

export const map: <T1,T2>(_1:Belt_List_t<T1>, _2:((_1:T1) => T2)) => Belt_List_t<T2> = NestedTypesJS.map as any;

export const swap: (tree:tree) => tree = NestedTypesJS.swap as any;

export const selfRecursiveConverter: (param:selfRecursive) => selfRecursive = NestedTypesJS.selfRecursiveConverter as any;

export const mutuallyRecursiveConverter: (param:mutuallyRecursiveA) => mutuallyRecursiveB = NestedTypesJS.mutuallyRecursiveConverter as any;

export const testFunctionOnOptionsAsArgument: <T1,a>(a:(undefined | a), foo:((_1:(undefined | a)) => T1)) => T1 = NestedTypesJS.testFunctionOnOptionsAsArgument as any;

export const stringT: string = NestedTypesJS.stringT as any;

export const jsStringT: string = NestedTypesJS.jsStringT as any;

export const jsString2T: string = NestedTypesJS.jsString2T as any;

export const jsonStringify: (_1:Js_Json_t) => string = NestedTypesJS.jsonStringify as any;

export const testConvertNull: (x:(null | record)) => (null | record) = NestedTypesJS.testConvertNull as any;

export const testConvertLocation: (x:Location_t) => Location_t = NestedTypesJS.testConvertLocation as any;

export const testMarshalFields: marshalFields = NestedTypesJS.testMarshalFields as any;

export const setMatch: (x:marshalMutableField) => void = NestedTypesJS.setMatch as any;

export const testInstantiateTypeParameter: (x:instantiateTypeParameter) => instantiateTypeParameter = NestedTypesJS.testInstantiateTypeParameter as any;

export const currentTime: Date = NestedTypesJS.currentTime as any;

export const optFunction: (undefined | (() => number)) = NestedTypesJS.optFunction as any;
Loading
Loading