Skip to content

Commit

Permalink
header-gen: Remove node-ts & configure TS for NodeNext modules. (#9)
Browse files Browse the repository at this point in the history
* header-gen: Remove node-ts & update cli script.

* header-gen: Configure TS to use NodeNext modules.
  • Loading branch information
microbit-carlos authored Sep 5, 2024
1 parent c5e7fd9 commit fed0924
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 126 deletions.
43 changes: 35 additions & 8 deletions header-gen/package-lock.json

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

3 changes: 1 addition & 2 deletions header-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
},
"scripts": {
"start": "ts-node --project tsconfig.cli.json src/cli.ts",
"start": "npm run build && node built/cli.js",
"test": "jest",
"prepare": "tsc",
"build": "tsc"
Expand All @@ -26,7 +26,6 @@
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
}
}
8 changes: 5 additions & 3 deletions header-gen/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { headerData } from "./inputdata";
import { generateBlob, generateCArray, generateDsHexLiteral } from "./main";
import process from 'process';
import { pathToFileURL } from 'url';
import { headerData } from "./inputdata.js";
import { generateBlob, generateCArray, generateDsHexLiteral } from "./main.js";

if (require.main === module) {
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
const headerBlob = generateBlob(headerData);
console.log('Blob:', headerBlob);
console.log(`\nC code:\n${generateCArray(headerBlob)}`);
Expand Down
2 changes: 1 addition & 1 deletion header-gen/src/inputdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: MIT
*/
import { MlModelHeader } from './MlModelHeader';
import { MlModelHeader } from './MlModelHeader.js';

export const headerData: MlModelHeader = {
samples_period: 25,
Expand Down
2 changes: 1 addition & 1 deletion header-gen/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* const ml_header_action_t actions[0];
* } ml_model_header_t;
*/
import { MlModelHeader } from './MlModelHeader';
import { MlModelHeader } from './MlModelHeader.js';

const HEADER_MAGIC = 0x4D4F444C;
const CONST_SIZES = {
Expand Down
109 changes: 0 additions & 109 deletions header-gen/tsconfig.cli.json

This file was deleted.

4 changes: 2 additions & 2 deletions header-gen/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "ESNext", /* Specify what module code is generated. */
"module": "NodeNext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
Expand Down

0 comments on commit fed0924

Please sign in to comment.