Skip to content

Commit

Permalink
Use slowEmit when the file doesn't exist yet
Browse files Browse the repository at this point in the history
fastEmit does a getFIle itself, en when the file doesn't exist
it throws an error. It expects that the file has been added or updated
before running the fastEmit.

In the case where files are required using the require.context glob, the
situation above happens, so we need to use the slowEmit path.
  • Loading branch information
ThaNarie committed Jul 11, 2016
1 parent dc7c216 commit a40d2e2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ async function compiler(webpack: IWebPack, text: string): Promise<void> {
let resultText;
let resultSourceMap = null;

if (state.options.declaration) {
// can't use fastEmit with declaration generation
// can't use fastEmit with declaration generation
// fastEmit gives error when used in webpack using require.context
// so first check if the file exists
const slowEmit = state.options.declaration || !state.getFile(fileName);

if (slowEmit) {

let output = state.emit(fileName);
let result = helpers.findResultFor(output, fileName);
Expand Down

0 comments on commit a40d2e2

Please sign in to comment.