I cannot for the life of me figure out how to import readFileSync
and writeFileSync
from the rw
module, specifically from its dash
"submodule".
I have tried the following
import {readFileSync, writeFileSync} from 'rw/dash';
which gives me error: Could not resolve "rw/dash"
.
I can access the functions I need with import {dash} from 'rw';
and dash.readFileSync
, but I'd rather import the functions directly.
I also tried other things like
import {
dash.readFileSync as readFileSync,
dash.writeFileSync as writeFileSync
} from 'rw';
but dots don't seem to be allowed like this.
Any pointers are much appreciated. Or if this is against the "spirit" of javascript let me know.
If you don't mind adding a second line, you can do this:
import {dash} from 'rw';
const {readFileSync, writeFileSync} = dash;
The reason you can't import it with from 'rw/dash'
is due to how that library does it's exports.