-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use built version os
sockjs-client
(#1148)
`webpack-dev-server` bundles `sockjs-client` from source. `sockjs-client` sources assume a node environment however, and will fail to run if `global` is not available. By bundling `sockjs-client` from source, the node environment requirement from `sockjs-client` will also be required of the app being served and thus it is not possible to have `node.global = false` in the user app being bundled. This fix uses the built `sockjs-client` instead of the sources. Fix #1147
- Loading branch information
1 parent
32412bb
commit 06df2f4
Showing
6 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# CLI - node false | ||
|
||
```shell | ||
node ../../bin/webpack-dev-server.js --open | ||
``` | ||
|
||
## What should happen | ||
|
||
In the app you should see "It's working." |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
document.write("It's working."); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="bundle.js" type="text/javascript" charset="utf-8"></script> | ||
</head> | ||
<body> | ||
<h1>Example: CLI - node false</h1> | ||
</body> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: './app.js', | ||
node: false | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ module.exports = { | |
output: { | ||
filename: 'bundle.js', | ||
path: '/' | ||
} | ||
}, | ||
node: false | ||
}; |
06df2f4
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.
@filipesilva This change (line 3 in client/socket.js) prevents my app from building as there's no
dist
directory in the publishedsocketjs-client
package. The directory is ignored for npm. Am I missing something?https://github.com/sockjs/sockjs-client/blob/master/.npmignore
06df2f4
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.
But not 💯 if that works like I assume. Could you clean the npm cache, delete the lockfile and install afresh ?
06df2f4
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.
@slate71 what version of
sockjs-client
are you using?1.1.4
seems to have it published: https://unpkg.com/sockjs-client@1.1.4/dist/sockjs.js06df2f4
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.
Ah, yes, that is correct, v1.1.4 does have a
dist
directory. Yet, after cleaning the cache and installing afresh (and confirming thedist
directory is there with the built files) I get this error.06df2f4
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.
@slate71 what's the dir structure of
node_modules/sockjs-client
look like?06df2f4
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.
06df2f4
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.
It is there, using a relative path
const SockJS = require('../../sockjs-client/dist/sockjs');
, will find the module. Don't yet understand whyconst SockJS = require('sockjs-client/dist/sockjs');
will not.I think the issue is on my side, though, and not with this commit.
06df2f4
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.
that looks like windows cmd output. here's hoping it's not a platform issue.
06df2f4
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.
Ha, no I'm on a mac.
06df2f4
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'm on windows myself, and I haven't observed odd cross platform behaviour (on this).
I wonder if it is related to the webpack configuration though? The resolve entries. Although that shouldn't have worked before either then... Unless you have several versions of sockjs, and only the topmost is being found?
06df2f4
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.
Figured it out. It was indeed on our side. We had an alias in our webpack config for
sockjs-client
I was unaware of and didn't think to check for.No
dist
directory there.06df2f4
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 wonder why that was there. Perhaps for a similar reason as this PR?