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

fix: apipath fix on windows platform #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zhazhaxia
Copy link

@zhazhaxia zhazhaxia commented Feb 23, 2020

A Windows path problem.
#L3
It should be apiPath.replace(/\\/ig,'\\\\').Otherwise,the program will transform E:\code\app.js into E:codeapp.js at line 11 because of the template code.
Just make a judgement it'll runs ok!

@liximomo
Copy link
Owner

image

const apiPath = path.join(__dirname, 'api.js');

var apiPath = path.join(__dirname, 'api.js')
if(/win32/gi.test(process.platform)){
Copy link
Owner

@liximomo liximomo Feb 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using loaderUtils.stringifyRequest to stringify the module path, it will cover more edge cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good advise ! I'll commit the code later.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using loaderUtils.stringifyRequest to stringify the module path, it will cover more edge cases.

I'd tried to use loaderUtils.stringifyRequest,the following code

loaderUtils.stringifyRequest(this,path.join(__dirname, 'api.js'))
// return 
// \"e:/a.js\"

It seems still can't resolve it.
What's your opinion?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested it in a Windows machine?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested it in a Windows machine?

yeah,i had tested it in my windows machine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested it in a Windows machine?

The transform result on windows is require('!!"E:/api.js"') .
loaderUtils.stringifyRequest just like JSON.stringify to parse the string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using loaderUtils.stringifyRequest to stringify the module path, it will cover more edge cases.

Hi,I had tried another way to fix the problem. Look at the commit fb7a4aa8a38856ab99796a2486d4c44d43af31b4. It works on my windows and mac machine.

@lmiller1990
Copy link

I have the same problem. Is this repo still maintained? Or we should fork?

@Clarkkkk
Copy link

Clarkkkk commented Jul 1, 2021

How is it going now?

@lmiller1990
Copy link

It is not going.

I think Webpack 5 has this out of the box anyway, doesn't it?

@zhazhaxia
Copy link
Author

I had fixed it,by this pr after fork the project.

@Clarkkkk
Copy link

Clarkkkk commented Jul 5, 2021

I had fixed it,by this pr after fork the project.

@liximomo Can you merge this pr and release a new version? My project is not going to migrate to webpack 5 in the near future.

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

Successfully merging this pull request may close these issues.

None yet

4 participants