Skip to content

Commit

Permalink
webpack-loader: revert plugging-in webpack's fs to the service
Browse files Browse the repository at this point in the history
it appears the inputFileSystem is not up to date on watch events, even though webpack passes in the "new" source to the loader.
should fix watch mode issues.
  • Loading branch information
AviVahl committed Feb 13, 2019
1 parent c8a3c22 commit ff71180
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions packages/webpack-loader/src/typescript-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { dirname, join, normalize } from 'path'
import ts from 'typescript'
import { TypeScriptService, ITranspilationOptions } from '@ts-tools/service'
import { resolvedModulesTransformer } from '@ts-tools/robotrix'
Expand All @@ -9,8 +8,6 @@ const { sys } = ts
const externalSourceMapPrefix = `//# sourceMappingURL=`
const platformHasColors = !!sys && !!sys.writeOutputIsTTY && sys.writeOutputIsTTY()

const defaultLibsDirectory = dirname(ts.getDefaultLibFilePath({}))

/**
* Loader options which can be provided via webpack configuration
* or a specific request query string
Expand Down Expand Up @@ -109,20 +106,7 @@ export const typescriptLoader: loader.Loader = function(/* source */) {
tsconfigFileName: loaderOptions.tsconfigFileName,
getCustomTransformers(_baseHost, compilerOptions) {
return compilerOptions && compilerOptions.baseUrl ? { after: [resolvedModulesTransformer] } : undefined
},
getCustomFs: () => ({
// normalize paths because typescript uses linux-like path representation in Windows
// while webpack uses native paths
readFileSync: (path, encoding = 'utf8') => this.fs.readFileSync(normalize(path)).toString(encoding),
statSync: path => this.fs.statSync(normalize(path)),
readdirSync: path => this.fs.readdirSync(normalize(path)),
realpathSync: sys && sys.realpath,
dirname,
join,
normalize,
defaultLibsDirectory,
caseSensitive: !!sys && sys.useCaseSensitiveFileNames
})
}
}

// transpile using `this.resourcePath`, ignoring the `source` provided to loader.
Expand Down

0 comments on commit ff71180

Please sign in to comment.