feat(npm-aqua-compiler): create package (#401)

* Add npm-aqua-compiler package

* Release new package

* Remove noUncheckedIndexedAccess from tsconfig.json

* Fix a test script

* Fix length checks

* Fix

* Update error description

* Try to choose a nicer err message

* New import format and API

* Fix error message

* Improve test

* Don't add empty string key when globalImports prop is empty

* Fix exports
This commit is contained in:
Akim
2023-12-15 23:14:07 +07:00
committed by GitHub
parent ac407c204d
commit d6008110cf
49 changed files with 1653 additions and 154 deletions

View File

@ -14,7 +14,6 @@
* limitations under the License.
*/
import assert from "assert";
import { readFile } from "fs/promises";
import { join } from "path";
@ -86,7 +85,7 @@ export function recursiveRenameLaquaProps(obj: JSONValue): unknown {
// Last part of the property separated by "_" is a correct name
const refinedProperty = prop.split("_").pop();
if (refinedProperty == null) {
if (refinedProperty === undefined) {
throw new Error(`Bad property name: ${prop}.`);
}
@ -95,11 +94,15 @@ export function recursiveRenameLaquaProps(obj: JSONValue): unknown {
}
}
assert(accessProp in obj);
const laquaProp = obj[accessProp];
if (laquaProp === undefined) {
return acc;
}
return {
...acc,
[accessProp]: recursiveRenameLaquaProps(obj[accessProp]),
[accessProp]: recursiveRenameLaquaProps(laquaProp),
};
}, {});
}