ts-loader: Webpack 2.0 - Cannot read property 'unsafeCache' of undefined

Please read right to the bottom of this thread for an approach that seems to work.

Using webpack@2.1.0-beta.23:

ERROR in ./src/index.tsx
Module build failed: TypeError: Cannot read property 'unsafeCache' of undefined
    at makeResolver (/Users/foo/node_modules/ts-loader/resolver.js:35:57)
    at ensureTypeScriptInstance (/Users/foo/node_modules/ts-loader/index.js:207:20)
    at Object.loader (/Users/foo/node_modules/ts-loader/index.js:387:14)

Used as:

export const tsLoader = {
  test: /\.ts(x?)$/,
  loader: `ts-loader?silent=true`
};

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 7
  • Comments: 16 (9 by maintainers)

Most upvoted comments

I tried awesome-typescript-loader and couldn’t get it working so I decided to take a stab at figuring out how to fix this.

@r-park @johnnyreilly @donaldpipowitch @josiah1888 by console.loging in the place the error occured, I found that the options is actually the options from the LoaderOptionsPlugin. By doing this:

new LoaderOptionsPlugin({
  debug: false,
  options: {
    resolve: {}
  }
})

Everything runs again.