Use fs.readFileSync instead of require.resolve#2797
Merged
darrachequesne merged 2 commits intosocketio:masterfrom Jan 22, 2017
Merged
Use fs.readFileSync instead of require.resolve#2797darrachequesne merged 2 commits intosocketio:masterfrom
darrachequesne merged 2 commits intosocketio:masterfrom
Conversation
…equire.resolve if this fails.
Member
|
Hi, thanks for the PR! How about using the following: function resolvePath(file){
var filepath = path.resolve(__dirname, './../../', file);
if (exists(filepath)) {
return filepath;
}
return require.resolve(file);
}Can you confirm the client file gets properly served that way? (you can also disable serving the client file with |
Member
|
Else, brfs may be helpful here, if you actually want to serve the file. |
Contributor
Author
|
@darrachequesne I never heard of brfs before, I also reckon your first suggestion is the best one, much DRYer, and also it doesn't requires an additional dependency. Yes it works, nexe works great with socket.io with this change. |
c469daf to
63c28c0
Compare
Member
|
Thanks! |
Contributor
Author
|
Thanks too! Socket.io is great! |
|
Has this been released? I'm using socket.io 2.0.4 and is still plagued with "require.resolve" calls. |
|
I'm also getting this error.. |
dzad
pushed a commit
to dzad/socket.io
that referenced
this pull request
May 29, 2023
…ocketio#2797) Browserify doesn't support require.resolve, and as a consequence, makes nexe fail the compilation. This PR attempts to get the path of the socket.io-client file via path.resolve and falls back to the original require.resolve if this file cannot be found.
This was referenced Nov 28, 2023
This was referenced Nov 29, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The kind of change this PR does introduce
Current behaviour
Browserify doesn't supports require.resolve, and as a consequence, makes nexe fails the compilation :
New behaviour
This PR attempts to read the content of the socket.io-client file via fs.readFileSync and falls back to the original require.resolve if this file cannot be found.
Other information (e.g. related issues)
nexe/nexe#289