-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webpack-cli): add --no-hot flag
- Loading branch information
Showing
7 changed files
with
80 additions
and
0 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,48 @@ | ||
'use strict'; | ||
const { run } = require('../utils/test-utils'); | ||
const { stat, readFile } = require('fs'); | ||
const { resolve } = require('path'); | ||
describe('no-hot flag', () => { | ||
it('shoul,d be successful when --no-hot is passed', (done) => { | ||
const { stderr, stdout } = run(__dirname, ['--no-hot']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(stdout).not.toContain('webpack/runtime/hot module replacement'); | ||
|
||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { | ||
expect(err).toBe(null); | ||
// check for absence of special functions invoked by HMR plugin only | ||
expect(data).not.toContain('/* webpack/runtime/hot module replacement */'); | ||
expect(data).not.toContain('function hotApply'); | ||
expect(data).toContain('no-hot test'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should warn --no-hot when --hot and --no-hot both are passed', (done) => { | ||
const { stderr, stdout } = run(__dirname, ['--hot', '--no-hot']); | ||
expect(stderr).toContain( | ||
'[webpack-cli] You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', | ||
); | ||
expect(stdout).toBeTruthy(); | ||
|
||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { | ||
expect(err).toBe(null); | ||
// check for absence of special functions invoked by HMR plugin only | ||
expect(data).not.toContain('/* webpack/runtime/hot module replacement */'); | ||
expect(data).not.toContain('function hotApply'); | ||
expect(data).toContain('no-hot test'); | ||
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 @@ | ||
console.log('no-hot test'); |
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,4 @@ | ||
module.exports = { | ||
mode: 'development', | ||
stats: 'verbose', | ||
}; |
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