Skip to content

Commit

Permalink
feat: Cargo.tomal watch (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
lencx committed Aug 19, 2021
1 parent 7f9f6c0 commit 16d697a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"webAssembly"
],
"dependencies": {
"@iarna/toml": "^2.2.5",
"chalk": "^4.1.0",
"chokidar": "^3.5.0",
"debug": "^4.3.2",
Expand Down
6 changes: 6 additions & 0 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import chokidar from 'chokidar';
import { readFileSync } from 'fs';
import { spawnSync, exec } from 'child_process';
import type { ViteDevServer } from 'vite';
import TOML from '@iarna/toml';

import fmtRustError from './rserr';
import { wpCmd, npmCmd, debugRsw, sleep, getCrateName, checkMtime } from './utils';
Expand Down Expand Up @@ -169,6 +170,11 @@ export function rswWatch(config: RswPluginOptions, root: string, serve: ViteDevS
path.resolve(root, name, 'Cargo.toml'),
], (_path) => {
rswCompile({ config, root, crate: name, serve, filePath: _path, cratePathMap });
const tomlFile = readFileSync(_path, { encoding: 'utf-8' });
const tomlData = TOML.parse(tomlFile);

// TODO: local path - watch tomal dependencies
// console.log('«173» /vite-plugin-rsw/src/compiler.ts ~> ', _path, tomlData);
});
})
}
Expand Down

0 comments on commit 16d697a

Please sign in to comment.