This repository was archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 513
fix(index): remove empty assets #746
Merged
michael-ciniawsky
merged 3 commits into
webpack-contrib:next
from
lili21:fix/empty-chunk
Mar 19, 2018
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,2 @@ | ||
require('./a.txt'); | ||
require('./b.txt'); | ||
This file contains hidden or 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 @@ | ||
a |
This file contains hidden or 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,2 @@ | ||
require('./b.txt'); | ||
require('./c.txt'); |
This file contains hidden or 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 @@ | ||
b |
This file contains hidden or 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 @@ | ||
c |
This file contains hidden or 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 @@ | ||
a |
This file contains hidden or 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,16 @@ | ||
require('./a.txt'); | ||
|
||
require.ensure( | ||
[], | ||
() => { | ||
require('./a.js'); | ||
}, | ||
'async-chunk-a', | ||
); | ||
require.ensure( | ||
[], | ||
() => { | ||
require('./b.js'); | ||
}, | ||
'async-chunk-b', | ||
); |
This file contains hidden or 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,22 @@ | ||
import ExtractTextPlugin from '../../../src/index'; | ||
|
||
module.exports = { | ||
entry: './index', | ||
optimization: { | ||
splitChunks: { | ||
cacheGroups: { | ||
common: { | ||
name: 'common', | ||
chunks: 'async', | ||
test: /async-chunk-(a|b)/, | ||
}, | ||
}, | ||
}, | ||
runtimeChunk: true | ||
}, | ||
plugins: [ | ||
new ExtractTextPlugin({ | ||
filename: '[name].css' | ||
}), | ||
], | ||
}; |
This file contains hidden or 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,6 +6,7 @@ | |
import fs from 'fs'; | ||
import path from 'path'; | ||
import webpack from 'webpack'; | ||
import glob from 'glob'; | ||
import ExtractTextPlugin from '../src'; | ||
|
||
const cases = process.env.CASES | ||
|
@@ -47,24 +48,20 @@ describe('Webpack Integration Tests', () => { | |
require(testFile)(suite); | ||
} | ||
const expectedDirectory = path.join(testDirectory, 'expected'); | ||
fs.readdirSync(expectedDirectory).forEach((file) => { | ||
const filePath = path.join(expectedDirectory, file); | ||
const actualPath = path.join(outputDirectory, file); | ||
expect(readFileOrEmpty(actualPath)).toEqual( | ||
readFileOrEmpty(filePath) | ||
); | ||
expect(readFileOrEmpty(actualPath)).toMatchSnapshot(); | ||
}); | ||
|
||
glob | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why need glob here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to get all files in a directory recursively. I can do it without glob, but why not ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
.sync('**/*.@(txt|css)', { cwd: outputDirectory }) | ||
.forEach((file) => { | ||
const filePath = path.join(expectedDirectory, file); | ||
const actualPath = path.join(outputDirectory, file); | ||
expect(fs.existsSync(filePath)).toBeTruthy(); | ||
expect(fs.readFileSync(actualPath, 'utf-8')).toEqual( | ||
fs.readFileSync(filePath, 'utf-8') | ||
); | ||
expect(fs.readFileSync(actualPath, 'utf-8')).toMatchSnapshot(); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
function readFileOrEmpty(filePath) { | ||
try { | ||
return fs.readFileSync(filePath, 'utf-8'); | ||
} catch (e) { | ||
return ''; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add
\n
in end of file 👍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.
👌