1

I followed this tutorial and then this tutorial as I am trying to use webpack with typescript. Everything was running fine after I finished the first tutorial (webpack w/out typescript).

However once I followed the second tutorial and ran npm run build I am getting this error:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.resolve.extensions[0] should not be empty.

I have not been able to find a solution to this anywhere.

Here is my webpack.config.js file:

module.exports = {
  entry: './main.ts',
  output: {
    filename: './bundle.js'
  },
  resolve: {
    extensions: ['', '.ts']
  },
  module: {
    loaders: [
      { test: /.ts$/, loader: 'awesome-typescript-loader' }
    ]
  }
};

Any help?

1 Answer 1

4

The latest versions of webpack don't permit passing empty string to module.resolve.extensions array like you are doing, just remove the empty string or replace it with some extension you want to support

module.exports = {
  entry: './main.ts',
  output: {
    filename: './bundle.js'
  },
  resolve: {
    extensions: ['.ts'] // don't specify the empty string, add '.js' if you want to import plain javascript files into typescript 
  },
  module: {
    loaders: [ // should use 'rules' instead of 'loaders', 'loaders' is retained for backward compatability only
      { test: /.ts$/, loader: 'awesome-typescript-loader' }
    ]
  }
};
Sign up to request clarification or add additional context in comments.

5 Comments

I just figured this out right before I saw your answer. I'll mark this as right answer once I can. thank you
Also, module.loaders is the legacy field, it should be module.rules instead for the latest version
@krummens I did actually
Oh sorry. Didn't see that. Thanks.
Do you know why webpack examples passed in empty strings in the first place?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.