-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: master
Are you sure you want to change the base?
Conversation
lib/loaders/entry-loader.js
Outdated
const apiPath = path.join(__dirname, 'api.js'); | ||
|
||
var apiPath = path.join(__dirname, 'api.js') | ||
if(/win32/gi.test(process.platform)){ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
fix the path on windows
I have the same problem. Is this repo still maintained? Or we should fork? |
How is it going now? |
It is not going. I think Webpack 5 has this out of the box anyway, doesn't it? |
I had fixed it,by this pr after fork the project. |
A Windows path problem.
#L3
It should be
apiPath.replace(/\\/ig,'\\\\')
.Otherwise,the program will transformE:\code\app.js
intoE:codeapp.js
at line 11 because of the template code.Just make a judgement it'll runs ok!