-
-
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.
fix: only add client entry to web targets (#1775)
- Loading branch information
1 parent
58d1682
commit cf4d0d0
Showing
7 changed files
with
266 additions
and
14 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
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,48 @@ | ||
'use strict'; | ||
|
||
const request = require('supertest'); | ||
const helper = require('./helper'); | ||
const config = require('./fixtures/universal-compiler-config/webpack.config'); | ||
|
||
describe('UniversalCompiler', () => { | ||
let server; | ||
let req; | ||
beforeAll((done) => { | ||
server = helper.start(config, { inline: true }, done); | ||
req = request(server.app); | ||
}); | ||
|
||
afterAll(helper.close); | ||
|
||
it('client bundle should have the inlined the client runtime', (done) => { | ||
req | ||
.get('/client.js') | ||
.expect('Content-Type', 'application/javascript; charset=UTF-8') | ||
.expect(200) | ||
.end((err, res) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
expect(res.text).toContain('Hello from the client'); | ||
expect(res.text).toContain('webpack-dev-server/client'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('server bundle should NOT have the inlined the client runtime', (done) => { | ||
// we wouldn't normally request a server bundle | ||
// but we'll do it here to check the contents | ||
req | ||
.get('/server.js') | ||
.expect('Content-Type', 'application/javascript; charset=UTF-8') | ||
.expect(200) | ||
.end((err, res) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
expect(res.text).toContain('Hello from the server'); | ||
expect(res.text).not.toContain('webpack-dev-server/client'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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'; | ||
|
||
console.log('Hello from the client'); |
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'; | ||
|
||
console.log('Hello from the server'); |
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,25 @@ | ||
'use strict'; | ||
|
||
module.exports = [ | ||
{ | ||
mode: 'development', | ||
context: __dirname, | ||
entry: './client.js', | ||
output: { | ||
path: '/', | ||
filename: 'client.js', | ||
}, | ||
node: false, | ||
}, | ||
{ | ||
mode: 'development', | ||
context: __dirname, | ||
target: 'node', | ||
entry: './server.js', | ||
output: { | ||
path: '/', | ||
filename: 'server.js', | ||
}, | ||
node: false, | ||
}, | ||
]; |