Skip to content

Commit 6b328c9

Browse files
committed
Add buildArgs configuration option for ReScript plugin
1 parent 1902715 commit 6b328c9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default defineConfig({
7575
suffix: '.mjs',
7676
},
7777
silent: false,
78+
buildArgs: '-warn-error +32+27+26+110',
7879
}),
7980
],
8081
});

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ type ReScriptProcess = {
1717
async function launchReScript(
1818
watch: boolean,
1919
silent: boolean,
20+
buildArgs: string,
2021
): Promise<ReScriptProcess> {
21-
const cmd = watch ? 'rescript watch' : 'rescript build';
22-
22+
const cmd = (watch ? 'rescript watch' : 'rescript build') + ' ' + buildArgs;
2323
// https://github.com/rescript-lang/rescript/blob/9676953f5b5ce96ade6909af3f23a77cd69645e9/rewatch/src/watcher.rs#L246-L258
2424
const finishSignal = 'Finished initial compilation';
2525

@@ -71,6 +71,7 @@ interface Config {
7171
suffix?: string;
7272
};
7373
silent?: boolean;
74+
buildArgs?: string;
7475
}
7576

7677
export default function createReScriptPlugin(config?: Config): Plugin {
@@ -83,6 +84,7 @@ export default function createReScriptPlugin(config?: Config): Plugin {
8384
const suffix = config?.loader?.suffix ?? '.bs.js';
8485
const suffixRegex = new RegExp(`${suffix.replace('.', '\\.')}$`);
8586
const silent = config?.silent ?? false;
87+
const buildArgs = config?.buildArgs ?? '';
8688

8789
return {
8890
name: '@jihchi/vite-plugin-rescript',
@@ -106,7 +108,7 @@ export default function createReScriptPlugin(config?: Config): Plugin {
106108
const watch = !isLocked && (command === 'serve' || Boolean(build.watch));
107109

108110
if (needReScript) {
109-
childProcessReScript = await launchReScript(watch, silent);
111+
childProcessReScript = await launchReScript(watch, silent, buildArgs);
110112
}
111113
},
112114
config: (userConfig) => ({

0 commit comments

Comments
 (0)