-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support unresolved loader resolve calls (#396)
- Loading branch information
Showing
11 changed files
with
89 additions
and
7 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
1 change: 1 addition & 0 deletions
1
tests/fixtures/loader-custom-resolve-request-missing-change/fab.js
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 @@ | ||
bar |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/loader-custom-resolve-request-missing-change/fib.js
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 @@ | ||
module.exports = function(n) { | ||
return n + (n > 0 ? n - 2 : 0); | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/loader-custom-resolve-request-missing-change/index.js
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 @@ | ||
var fib = require('./loader!./fib'); | ||
|
||
console.log(fib(3)); |
9 changes: 9 additions & 0 deletions
9
tests/fixtures/loader-custom-resolve-request-missing-change/loader.js
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,9 @@ | ||
module.exports = function(source) { | ||
this.cacheable && this.cacheable(); | ||
const done = this.async(); | ||
new Promise( | ||
(f, e) => this.resolve(this.context, './fab', (er, v) => (er ? e(er) : f(v))) | ||
) | ||
.then(v => JSON.stringify(v)) | ||
.then(v => done(null, v), done); | ||
}; |
18 changes: 18 additions & 0 deletions
18
tests/fixtures/loader-custom-resolve-request-missing-change/webpack.config.js
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 @@ | ||
var HardSourceWebpackPlugin = require('../../..'); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: './index.js', | ||
output: { | ||
path: __dirname + '/tmp', | ||
filename: 'main.js', | ||
}, | ||
plugins: [ | ||
new HardSourceWebpackPlugin({ | ||
cacheDirectory: 'cache', | ||
environmentHash: { | ||
root: __dirname + '/../../..', | ||
}, | ||
}), | ||
], | ||
}; |
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 @@ | ||
module.exports = function(n) { | ||
return n + (n > 0 ? n - 2 : 0); | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/loader-custom-resolve-request-missing/index.js
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 @@ | ||
var fib = require('./loader!./fib'); | ||
|
||
console.log(fib(3)); |
9 changes: 9 additions & 0 deletions
9
tests/fixtures/loader-custom-resolve-request-missing/loader.js
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,9 @@ | ||
module.exports = function(source) { | ||
this.cacheable && this.cacheable(); | ||
const done = this.async(); | ||
new Promise( | ||
(f, e) => this.resolve(this.context, './fab', (er, v) => (er ? f('unresolved') : f(v))) | ||
) | ||
.then(v => JSON.stringify(v)) | ||
.then(v => done(null, v), done); | ||
}; |
18 changes: 18 additions & 0 deletions
18
tests/fixtures/loader-custom-resolve-request-missing/webpack.config.js
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 @@ | ||
var HardSourceWebpackPlugin = require('../../..'); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: './index.js', | ||
output: { | ||
path: __dirname + '/tmp', | ||
filename: 'main.js', | ||
}, | ||
plugins: [ | ||
new HardSourceWebpackPlugin({ | ||
cacheDirectory: 'cache', | ||
environmentHash: { | ||
root: __dirname + '/../../..', | ||
}, | ||
}), | ||
], | ||
}; |
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