Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports from fs/promises are broken #40

Open
cdauth opened this issue Oct 1, 2023 · 0 comments
Open

Imports from fs/promises are broken #40

cdauth opened this issue Oct 1, 2023 · 0 comments

Comments

@cdauth
Copy link

cdauth commented Oct 1, 2023

When I have an import fs from 'fs/promises'; or similar in my code base, this gets transpiled to import fs from "../../../promises";, causing an error such as this:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/cdauth/Documents/workspace/programming/web/osm/facilmap/promises' imported from /home/cdauth/Documents/workspace/programming/web/osm/facilmap/server/node_modules/.bin/esrun-1696190329627.tmp.mjs

The problems seems to be in this line:

				code = code
					.replace(
						/(?:^|;)import (.*?) from "..\//gm,
						'import $1 from "../../../',
					)
					.replace(/(?:^|;)import (.*?) from ".\//gm, 'import $1 from "../../');

Here, the ..\/ part in the regular expression matches the fs/. I believe to fix the issue, the ..\/ in the regular expression should become \.\.\/ and the .\/ in the other regular expression should become \.\/.

As a workaround, I can import from node:fs/promises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant