-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b93e15b
commit 79861c1
Showing
17 changed files
with
242 additions
and
151 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
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
File renamed without changes.
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,11 @@ | ||
export default (compiler) => { | ||
return new Promise((resolve, reject) => { | ||
compiler.run((error, stats) => { | ||
if (error) { | ||
return reject(error); | ||
} | ||
|
||
return resolve(stats); | ||
}); | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import path from 'path'; | ||
|
||
import webpack from 'webpack'; | ||
import memfs from 'memfs'; | ||
|
||
export default (fixture, loaderOptions = {}, config = {}) => { | ||
const fullConfig = { | ||
mode: 'development', | ||
devtool: config.devtool || false, | ||
context: path.resolve(__dirname, '../fixtures'), | ||
entry: path.resolve(__dirname, '../fixtures', fixture), | ||
output: { | ||
path: path.resolve(__dirname, '../outputs'), | ||
filename: '[name].bundle.js', | ||
chunkFilename: '[name].chunk.js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/i, | ||
rules: [ | ||
{ | ||
loader: path.resolve(__dirname, '../../src'), | ||
options: loaderOptions || {}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [], | ||
...config, | ||
}; | ||
|
||
const compiler = webpack(fullConfig); | ||
|
||
if (!config.outputFileSystem) { | ||
const outputFileSystem = memfs; | ||
|
||
outputFileSystem.vol.reset(); | ||
// Todo remove when we drop webpack@4 support | ||
outputFileSystem.join = path.join.bind(path); | ||
|
||
compiler.outputFileSystem = outputFileSystem; | ||
} | ||
|
||
return compiler; | ||
}; |
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,6 @@ | ||
import compile from './compile'; | ||
import getCompiler from './getCompiler'; | ||
import normalizeErrors from './normalizeErrors'; | ||
import readAsset from './readAsset'; | ||
|
||
export { compile, getCompiler, normalizeErrors, readAsset }; |
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 @@ | ||
function removeCWD(str) { | ||
const isWin = process.platform === 'win32'; | ||
let cwd = process.cwd(); | ||
|
||
if (isWin) { | ||
// eslint-disable-next-line no-param-reassign | ||
str = str.replace(/\\/g, '/'); | ||
// eslint-disable-next-line no-param-reassign | ||
cwd = cwd.replace(/\\/g, '/'); | ||
} | ||
|
||
return str.replace(new RegExp(cwd, 'g'), ''); | ||
} | ||
|
||
export default (errors) => { | ||
return errors.map((error) => | ||
removeCWD( | ||
error | ||
.toString() | ||
.split('\n') | ||
.slice(0, 2) | ||
.join('\n') | ||
) | ||
); | ||
}; |
Oops, something went wrong.