Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Incorrect path resolving on Windows with multiple disks #9

Open
itoys opened this issue Jul 27, 2017 · 5 comments
Open

Incorrect path resolving on Windows with multiple disks #9

itoys opened this issue Jul 27, 2017 · 5 comments

Comments

@itoys
Copy link

itoys commented Jul 27, 2017

Hello!
When executable code and sources located on separate disk(i.e C:/ and D:/) method
require('source-map-resolve").resolveSync works incorrect.
It strips off disk letter(urix package) and after when it trying read from disk, it catch error.
For example:
server running on disk C:, sources located on disk D:

let filePath = 'D:\\projects\\test\\index.js';
sourceMapResolve.resolveSync(someCode, filePath, fs.readFileSync);

I have error:
ENOENT: no such file or directory, open 'C:\projects\test\build\index.js.map'
Because map file located on disk D:

@lydell
Copy link
Owner

lydell commented Jul 28, 2017

Could you show input, actual output and expected output?

@lydell
Copy link
Owner

lydell commented Apr 19, 2020

Idea: Maybe source-map-resolve shouldn’t try to be smart with URL-to-path conversion at all, and leave it completely up to the read parameter to do any necessary conversions. Then it’ll be up to the users of source-map-resolve to use whatever is needed for their use case.

@jens-duttke
Copy link

I have same issue, is there a chance to get that fixed?

Maybe source-map-resolve shouldn’t try to be smart with URL-to-path conversion at all, and leave it completely up to the read parameter to do any necessary conversions

For my usecase, that would be the perfect solution.

@lydell
Copy link
Owner

lydell commented Sep 25, 2020

@jens-duttke I really dislike this package, so don’t expect anything. Try to use a different dependency if you can. I might accept a PR, but last time I said that I ended up merging it to another branch then left it hanging 😢 #20

@jens-duttke
Copy link

@jens-duttke I really dislike this package, so don’t expect anything. Try to use a different dependency if you can. I might accept a PR, but last time I said that I ended up merging it to another branch then left it hanging 😢 #20

Do you have any recommendations? I tried different packages, but this one works best and is easy to use.

The workaround I've implemented in my code now, is:

const result = sourceMapResolve.resolveSync(code, codePath, (sourceMapFilePath) => {
	if ((/^[a-z]:/ui).test(codePath)) {
		sourceMapFilePath= `${codePath.substr(0, 2)}${sourceMapFilePath}`;
	}

	return compiler.outputFileSystem.readFileSync(sourceMapFilePath, 'utf8');
});

Anyhow, it would be good to get rid of this hack.

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

No branches or pull requests

4 participants
@lydell @itoys @jens-duttke and others