-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(client): add default fallback for client #2015
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2015 +/- ##
=======================================
Coverage 92.77% 92.77%
=======================================
Files 29 29
Lines 1149 1149
Branches 327 327
=======================================
Hits 1066 1066
Misses 79 79
Partials 4 4 Continue to review full report at Codecov.
|
client-src/default/socket.js
Outdated
// this SockJSClient is here as a default fallback, in case inline mode | ||
// is off or the client is not injected. This will be switched to | ||
// WebsocketClient when it becomes the default | ||
const SockJSClient = require('../clients/SockJSClient'); |
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.
Move to L19
We should release as a patch version asap. Thanks. |
@evilebottnawi Looks good? |
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.
Good job, some notes and question
client-src/default/socket.js
Outdated
// eslint-disable-next-line global-require | ||
const SockJSClient = require('../clients/SockJSClient'); | ||
Client = SockJSClient; | ||
} |
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.
Maybe more simple? Like:
const Client = typeof __webpack_dev_server_client__ !== 'undefined' ? __webpack_dev_server_client__ : require('../clients/SockJSClient');
lib/utils/addEntries.js
Outdated
@@ -20,7 +20,7 @@ function addEntries(config, options, server) { | |||
const sockPath = options.sockPath ? `&sockPath=${options.sockPath}` : ''; | |||
const sockPort = options.sockPort ? `&sockPort=${options.sockPort}` : ''; | |||
const clientEntry = `${require.resolve( | |||
'../../client/' | |||
'../../client/default/' |
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.
Breaking change, some packages can use this directly, so changing path can break these apps
package.json
Outdated
@@ -25,7 +25,7 @@ | |||
"test": "npm run test:coverage", | |||
"pretest": "npm run lint", | |||
"prepare": "rimraf ./ssl/*.pem && npm run build:client", | |||
"build:client:default": "babel client-src/default --out-dir client --ignore \"./client-src/default/*.config.js\"", | |||
"build:client:default": "babel client-src/default --out-dir client/default --ignore \"./client-src/default/*.config.js\"", |
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.
Breaking change, as i written above
@evilebottnawi any ideas how to make |
@Loonride hm, we already keep clients in difference directory, can't see problem |
The problem is the directory organization of When And we need both to work, because it needs to be functional in the babel transpiled |
Good catch, i think we can change location and create
What do you think? |
That is a good idea, let me push an alternative solution that I just made though which may be simpler and we can compare. |
8c90abb
@evilebottnawi my idea is to use |
@evilebottnawi thoughts? |
@evilebottnawi @hiroppy Could you take a look so we can resolve this issue? |
@@ -33,5 +34,11 @@ module.exports = { | |||
to: path.resolve(__dirname, '../../client/live.html'), | |||
}, | |||
]), | |||
new webpack.NormalModuleReplacementPlugin(/\/clients\//, (resource) => { |
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.
memo: We will delete this plugin at the next major version because we can change the directory structure.
I'll release today. thanks! |
We should do regexp more strictly now all clients directories in requests rewrites in all modules, i.e. if package use clients directory we rewrite their import/require too, it is very very very big problem, I have many issues about this in DM gutter and other channels and I don't access to fix it right now, please guys take care about it asap, it is incredibly high priority |
@evilebottnawi Would you want to revert? We should add the state actually used by userland to the test. |
@evilebottnawi Sorry about that, I did not think it would impact other modules. @hiroppy I say revert, then we follow the other method that @evilebottnawi suggested |
For Bugs and Features; did you add new tests?
Not yet, probably should resolve asap
Motivation / Use-Case
Fixes #2006 by providing a default fallback in case
__webpack_dev_server_client__
is undefined.I moved the
default
client sources toclient/default
so that the file path structure is the same, allowingsocket.js
torequire('../clients/SockJSClient')
in bothclient
andclient-src
Breaking Changes
None
Additional Info
We still need to figure out how to insert
__webpack_dev_server_client__
variable intolive
mode.