Webpack warnings from typescript definition file

Viewed 1286

Struggling with this and can't seem to find the root cause. I keep getting this error from webpack builds. What's wrong and how can I fix these warning? Why does it look to pick up the typescript definition file?

Compiling with just typescript compiler doesn't output any warning. It is just webpack or ts-loader I guess.

WARNING in ./node_modules/aws-lambda-router/lib/EventProcessor.d.ts 1:7
Module parse failed: Unexpected token (1:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> export interface EventProcessor<TConfig = any, TEvent = any, TContext = any, TOutput = any> {
|     process: ProcessMethod<TConfig, TEvent, TContext, TOutput>;
| }
 @ ./node_modules/aws-lambda-router/lib sync ^\.\/.*$ ./EventProcessor.d.ts
 @ ./node_modules/aws-lambda-router/index.js
 @ ./src/lambdas/es_manager.ts

WARNING in ./node_modules/aws-lambda-router/lib/s3.d.ts 3:7
Module parse failed: Unexpected token (3:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import { Context, S3Event as awsS3Event, S3EventRecord } from 'aws-lambda';
| import { ProcessMethod } from './EventProcessor';
> export declare type S3Event = awsS3Event;
| export interface S3Route {
|     bucketName?: string | RegExp;
 @ ./node_modules/aws-lambda-router/lib sync ^\.\/.*$ ./s3.d.ts
 @ ./node_modules/aws-lambda-router/index.js
 @ ./src/lambdas/es_manager.ts

WARNING in ./node_modules/aws-lambda-router/lib/sns.d.ts 3:7
Module parse failed: Unexpected token (3:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import { Context, SNSEvent, SNSMessage, SNSEventRecord } from 'aws-lambda';
| import { ProcessMethod } from './EventProcessor';
> export declare type SnsEvent = SNSEvent;
| export interface SnsRoute {
|     subject: RegExp;
 @ ./node_modules/aws-lambda-router/lib sync ^\.\/.*$ ./sns.d.ts
 @ ./node_modules/aws-lambda-router/index.js
 @ ./src/lambdas/es_manager.ts

WARNING in ./node_modules/aws-lambda-router/lib/sqs.d.ts 3:7
Module parse failed: Unexpected token (3:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import { Context, SQSEvent, SQSRecord } from 'aws-lambda';
| import { ProcessMethod } from './EventProcessor';
> export declare type SqsEvent = SQSEvent;
| export interface SqsRoute {
|     source: string | RegExp;
 @ ./node_modules/aws-lambda-router/lib sync ^\.\/.*$ ./sqs.d.ts
 @ ./node_modules/aws-lambda-router/index.js
 @ ./src/lambdas/es_manager.ts

WARNING in ./node_modules/aws-lambda-router/lib/proxyIntegration.d.ts 3:8
Module parse failed: Unexpected token (3:8)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import { APIGatewayEventRequestContext, APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
| import { ProcessMethod } from './EventProcessor';
> declare type ProxyIntegrationParams = {
|     paths?: {
|         [paramId: string]: string;
 @ ./node_modules/aws-lambda-router/lib sync ^\.\/.*$ ./proxyIntegration.d.ts
 @ ./node_modules/aws-lambda-router/index.js
 @ ./src/lambdas/es_manager.ts
  adding: main.js (deflated 75%)

The webpack config is like this

const path = require('path');
const fs = require('fs');

module.exports = {
    entry: path.join(__dirname, "src/lambdas", "es_manager.ts"),
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          use: {
            loader: 'ts-loader',
          },  
          exclude: /node_modules/
        }
      ]
    },
    resolve: {
      extensions: ['.tsx', '.ts', '.js' ]
    },
    output: {
      libraryTarget: 'commonjs',
      filename: '[name].js',
      path: path.resolve(__dirname, 'dist')
    },
    target: 'node',
    mode: 'production'
};

tsconfig.json is like this

{
  "compilerOptions": {
    "target": "es2017",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    "noEmitOnError": true,
    "allowJs": true,                       /* Allow javascript files to be compiled. */
    "sourceMap": false,                     /* Generates corresponding '.map' file. */
    "outDir": "./dist",                        /* Redirect output structure to the directory. */
    "strict": true,                           /* Enable all strict type-checking options. */
    "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
    "rootDirs": ["./src"],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
    "typeRoots": ["node_modules/@types"],                       /* List of folders to include type definitions from. */
    "types": ["node"],                           /* Type declaration files to be included in compilation. */
    "esModuleInterop": true,                   /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
  },
  "exclude": [
    "node_modules",
    "**/*.test.ts"
  ],
}

1 Answers
Related