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

Unable to Access Host File System for Read/Write Operations in SWC Plugin #10084

Closed
zhangtao25 opened this issue Feb 23, 2025 · 4 comments
Closed

Comments

@zhangtao25
Copy link

zhangtao25 commented Feb 23, 2025

Describe the feature

Issue Background:
While developing a SWC plugin, the environment you're working in is a virtual environment, but you need to create new files as you traverse each JavaScript file. The issue you're encountering is that you're unable to directly access the host's file system for read and write operations.

Specific Problem:

  • You want to perform file system operations like reading and writing to the host machine's file system within the SWC plugin.
  • The SWC plugin runs in a virtualized environment, which prevents direct access to the host file system for read/write operations.
  • Therefore, you need a method to access the host's file system in order to create new files while processing each JS file.

Desired Solution:

  • You are looking for a mechanism or extension from SWC that would allow your plugin to access the host file system for read and write operations, particularly to create new files during the file traversal process.

Babel plugin or link to the feature description

No response

Additional context

No response

@kwonoj
Copy link
Member

kwonoj commented Feb 23, 2025

This is intended design and also not entirely true, there's limited filesystem access supported.

@kwonoj kwonoj closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2025
@zhangtao25
Copy link
Author

So can I only send out the data through http request?

@kwonoj
Copy link
Member

kwonoj commented Feb 23, 2025

The reason I said there's a limited fs system is, there's a mounted /cwd for the wasi plugin which allows to access to the current working dir. If plugin want unlimited access to the host filesystem, that's not supported.

@zhangtao25
Copy link
Author

Thank you very much, I understand.

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

No branches or pull requests

2 participants