-
-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug: fs/promises breaks ESM usage (runVbsScript)
Setup:
- Node version: 20
- Guidepup version: 0.22
- OS Platform: mac
- OS Release: sonoma
Details
When trying to use VSR in a Storybook story I got the following error when importing virtual via import { virtual } from '@guidepup/virtual-screen-reader';. I only had the import statement and did not implement virtual in the file.
✘ [ERROR] Could not read from file: /Users/scottnath/development/profile-components/node_modules/node-stdlib-browser/cjs/mock/empty.js/promises
node_modules/@guidepup/guidepup/lib/windows/runVbsScript.js:5:27:
5 │ const promises_1 = require("node:fs/promises");
╵ ~~~~~~~~~~~~~~~~~~
Unhandled promise rejection: Error: Build failed with 1 error:
node_modules/@guidepup/guidepup/lib/windows/runVbsScript.js:5:27: ERROR: Could not read from file: /Users/scottnath/development/profile-components/node_modules/node-stdlib-browser/cjs/mock/empty.js/promises
Searching led me to this issue in virtual-screen-reader. After a lot of experiments, I found that the usage of fs/promises' for an import in lib/windows/runVbsScript.js` was causing the error. If I change that file to be:
import { join, sep } from "path";
import { promises } from "node:fs";
import { execFile } from "child_process";
import { tmpdir } from "os";
const { mkdtemp, realpath, rm, writeFile } = promises;
then the compile step changes the output from
const promises_1 = require("node:fs/promises");
const child_process_1 = require("child_process");
const os_1 = require("os");
to:
const node_fs_1 = require("node:fs");
const child_process_1 = require("child_process");
const os_1 = require("os");
const { mkdtemp, realpath, rm, writeFile } = node_fs_1.promises;
This change stops the error when used by VSR in my stories files.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working