Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add getResolve method to loader context
with allows to pass options
- Loading branch information
Showing
5 changed files
with
46 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,7 @@ | ||
it("should be possible to create resolver with different options", () => { | ||
const result = require("./loader!"); | ||
expect(result).toEqual({ | ||
one: "index.js", | ||
two: "index.xyz" | ||
}); | ||
}) |
Empty file.
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 @@ | ||
const path = require("path"); | ||
module.exports = async function() { | ||
const resolve1 = this.getResolve(); | ||
const resolve2 = this.getResolve({ | ||
extensions: [".xyz", ".js"] | ||
}); | ||
return `module.exports = ${JSON.stringify({ | ||
one: path.basename(await resolve1(__dirname, "./index")), | ||
two: path.basename(await resolve2(__dirname, "./index")), | ||
})}`; | ||
}; |