-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: empty and multiple entries support (#2920)
- Loading branch information
1 parent
4b48017
commit 45f6592
Showing
12 changed files
with
246 additions
and
533 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
'use strict'; | ||
|
||
const testBin = require('../helpers/test-bin'); | ||
const isWebpack5 = require('../helpers/isWebpack5'); | ||
|
||
describe('DevServer', () => { | ||
const webpack5Test = isWebpack5 ? it : it.skip; | ||
|
||
it('should add devServer entry points to a single entry point', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/default-config.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('client/default/index.js?'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should add devServer entry points to a multi entry point object', (done) => { | ||
testBin( | ||
'--config ./test/fixtures/dev-server/multi-entry.js --stats=verbose' | ||
) | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('client/default/index.js?'); | ||
expect(output.stderr).toContain('foo.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
webpack5Test('should supports entry as descriptor', (done) => { | ||
testBin( | ||
'--config ./test/fixtures/entry-as-descriptor/webpack.config --stats detailed' | ||
) | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('foo.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should only prepends devServer entry points to "web" target', (done) => { | ||
testBin( | ||
'--config ./test/fixtures/dev-server/default-config.js --target web' | ||
) | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('client/default/index.js?'); | ||
expect(output.stderr).toContain('foo.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should not prepend devServer entry points to "node" target', (done) => { | ||
testBin( | ||
'--config ./test/fixtures/dev-server/default-config.js --target node' | ||
) | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).not.toContain('client/default/index.js?'); | ||
expect(output.stderr).toContain('foo.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should prepends the hot runtime to "node" target as well', (done) => { | ||
testBin( | ||
'--config ./test/fixtures/dev-server/default-config.js --target node --hot' | ||
) | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('webpack/hot/dev-server'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('does not use client.path when default', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/client-default-path-config.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).not.toContain('&path=/ws'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should use client.path when custom', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/client-custom-path-config.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('&path=/custom/path'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
webpack5Test( | ||
'should prepend devServer entry points depending on targetProperties', | ||
(done) => { | ||
testBin('--config ./test/fixtures/dev-server/target-config.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('client/default/index.js'); | ||
done(); | ||
}) | ||
.catch(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('I am bar'); |
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,18 @@ | ||
'use strict'; | ||
|
||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
entry: resolve(__dirname, './foo.js'), | ||
devServer: { | ||
client: { | ||
path: '/custom/path', | ||
}, | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
}, | ||
}; |
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,18 @@ | ||
'use strict'; | ||
|
||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
entry: resolve(__dirname, './foo.js'), | ||
devServer: { | ||
client: { | ||
path: '/ws', | ||
}, | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
}, | ||
}; |
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,18 @@ | ||
'use strict'; | ||
|
||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
entry: resolve(__dirname, './foo.js'), | ||
devServer: { | ||
client: { | ||
path: '/custom/path', | ||
}, | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
}, | ||
}; |
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('I am foo'); |
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,19 @@ | ||
'use strict'; | ||
|
||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
context: __dirname, | ||
entry: { | ||
foo: resolve(__dirname, './foo.js'), | ||
bar: resolve(__dirname, './bar.js'), | ||
}, | ||
devServer: { | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
}, | ||
}; |
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,24 @@ | ||
'use strict'; | ||
|
||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
entry: resolve(__dirname, './foo.js'), | ||
target: ['web', 'webworker'], | ||
output: { | ||
chunkLoading: false, | ||
wasmLoading: false, | ||
workerChunkLoading: false, | ||
}, | ||
devServer: { | ||
client: { | ||
path: '/custom/path', | ||
}, | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.