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

Failed to resolve xxx in project root error occurred while using inputFileSystem #5091

Open
MrToy opened this issue Dec 21, 2023 · 21 comments
Open
Labels
A-resolver Area: resolver bug Something isn't working pr welcome
Milestone

Comments

@MrToy
Copy link
Collaborator

MrToy commented Dec 21, 2023

System Info

System:
OS: macOS 14.0
CPU: (12) arm64 Apple M2 Max
Memory: 387.53 MB / 64.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 19.9.0 - ~/.nvm/versions/node/v19.9.0/bin/node
npm: 9.6.3 - ~/.nvm/versions/node/v19.9.0/bin/npm
pnpm: 7.15.0 - ~/.nvm/versions/node/v19.9.0/bin/pnpm
Browsers:
Chrome: 120.0.6099.109
Safari: 17.0
npmPackages:
@rspack/core: ^0.4.4 => 0.4.4

Details

I'm trying to bundle my project using a virtual file system.

Here is my code.

import { rspack } from "@rspack/core";
import { Volume, createFsFromVolume } from "memfs";
  const files = {
    "/index.tsx": `
    import React from 'react';
    import ReactDOM from 'react-dom';
    ReactDOM.render(<div></div> , document.getElementById("root"));`,
  };
  const val = Volume.fromJSON(files);
  const fs = createFsFromVolume(val);
  const compiler = rspack({
    mode: "production",
    entry: "/index.tsx",
    output: {
      filename: "/ouput.js",
    }
  });
  compiler.inputFileSystem = fs;
  compiler.intermediateFileSystem = fs;
  //@ts-ignore
  compiler.outputFileSystem = fs;

  compiler.run((err, result) => {
    const files = val.toJSON();
    console.log(err, result, files);
  });

Here is error message

ERROR in × Failed to resolve /index.tsx in project root

Reproduce link

No response

Reproduce Steps

It can be reproduced by running the code I provided.

@MrToy MrToy added bug Something isn't working pending triage The issue/PR is currently untouched. labels Dec 21, 2023
@hardfist
Copy link
Contributor

hardfist commented Dec 21, 2023

@Boshen does oxc_resolver supports passing custom filesystem now?

It seems oxc_resolver supports filesystem, but Rspack resolve options doesn't support pass filesystem to oxc_resolver yet

@hardfist hardfist added A-resolver Area: resolver and removed pending triage The issue/PR is currently untouched. labels Dec 21, 2023
@Boshen
Copy link
Contributor

Boshen commented Dec 21, 2023

To support this use case, Rspack needs to implement ResolverGeneric from oxc_resolver with its own implementation of FileSystem, and expose the relevant APIs to the JS side.

@xc2
Copy link
Collaborator

xc2 commented Dec 21, 2023

The last time I tried to work with inputFileSystem, I realized that rspack only use .purge method of it.

therefore I think rspack hasn't been ready for inputFileSystem. pls correct me if i got the thing wrong.

@hardfist
Copy link
Contributor

The last time I tried to work with inputFileSystem, I realized that rspack only use .purge method of it.

therefore I think rspack hasn't been ready for inputFileSystem. pls correct me if i got the thing wrong.

since inputFileSystem is a public API, other Rspack|Webpck plugin may use other method in it.

@xc2
Copy link
Collaborator

xc2 commented Dec 21, 2023

The last time I tried to work with inputFileSystem, I realized that rspack only use .purge method of it.
therefore I think rspack hasn't been ready for inputFileSystem. pls correct me if i got the thing wrong.

since inputFileSystem is a public API, other Rspack|Webpck plugin may use other method in it.

i mean that rspack doesn't utilize inputFileSystem for reading file system.

Previously, i used to create memfs as inputFileSystem and outputFileSystem for unit testing purposes. This allowed me to avoid generating numerous fixture files in my repository or pay effort at cleaning up test artifacts after testing

However, when I attempted to do the same with rspack, I noticed that the outputFileSystem worked as expected while the inputFileSystem didn't

@hardfist
Copy link
Contributor

hardfist commented Dec 21, 2023

because Rspack read outputFilesystem and not read inputFilesystem in Rust side yet, see https://github.com/web-infra-dev/rspack/blob/main/crates/node_binding/src/lib.rs#L68

@xc2
Copy link
Collaborator

xc2 commented Dec 21, 2023

because Rspack read outputFilesystem and not read inputFilesystem in Rust side yet, see https://github.com/web-infra-dev/rspack/blob/main/crates/node_binding/src/lib.rs#L68

i see - i believe this issue is also this thing.

@hardfist
Copy link
Contributor

@xc2 do you want to give it a try to implement this feature?

@xc2
Copy link
Collaborator

xc2 commented Dec 21, 2023

@xc2 do you want to give it a try to implement this feature?

hard to promise as i'm quite new to rust. previous i had a hard time to impl module.noParse, still being blocked by a runtime panic to do with the js function call in rust.

i will still give it a try but it is supposed to be long.

@hardfist
Copy link
Contributor

It's not an urgent feature, so take your time, and if you met problems when contributing to Rspack, feel free to ping us

Copy link

stale bot commented Feb 19, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Feb 19, 2024
@xc2
Copy link
Collaborator

xc2 commented Feb 20, 2024

bump

@stale stale bot removed the stale label Feb 20, 2024
@hardfist hardfist mentioned this issue Mar 29, 2024
2 tasks
Copy link

stale bot commented May 28, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label May 28, 2024
@zackarychapple
Copy link
Collaborator

bump

@stale stale bot removed the stale label Jun 18, 2024
Copy link

stale bot commented Aug 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Aug 17, 2024
@Justinidlerz
Copy link

bump

@jackw
Copy link

jackw commented Sep 4, 2024

Bump. I have a feeling this might be related to me not being able to use the webpack-virtual-modules plugin with Rspack.

I've since found the rspack virtual module plugin.

@stale stale bot removed the stale label Sep 4, 2024
@hardfist hardfist added this to the 1.1.0 milestone Sep 5, 2024
Copy link

stale bot commented Nov 5, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the stale label Nov 5, 2024
@hardfist
Copy link
Contributor

hardfist commented Nov 5, 2024

bump

@stale stale bot removed the stale label Nov 5, 2024
@nilptr
Copy link
Contributor

nilptr commented Nov 29, 2024

seems this issue does not have update for a while, may I take it?

@zackarychapple
Copy link
Collaborator

go for it @nilptr :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolver Area: resolver bug Something isn't working pr welcome
Projects
None yet
Development

No branches or pull requests

8 participants