Skip to content

Package do not mesh well with TSC and allowJs #437

@kant2002

Description

@kant2002

Package Version: 2.2.3

To Reproduce
Steps to reproduce the behavior:

  1. npm init
  2. npm install @azure/ms-rest-js ts-loader webpack webpack-cli
  3. Create index.ts
  4. Create webpack.config.js
  5. Create tsconfig.json
  6. Run npx webpack

index.js

import * as msRest from "@azure/ms-rest-js";

console.log(msRest);

webpack.config.js*

const webpack = require('webpack');
const bundleOutputDir = './dist';

module.exports = (env) => {
    return [{
        entry: {
            'index': './index',
        },
        resolve: {
            extensions: ['.ts']
        },
        output: {
            path: path.join(__dirname, bundleOutputDir),
            filename: '[name].js',
        },
        module: {
            rules: [
                {
                    test: /\.js|.ts?$/, loader: 'ts-loader'
                }
            ],
        },
    }];
};

tsconfig.json

Make sure that allowJs set to true

{
    "compilerOptions": {
      "moduleResolution": "node",
      "target": "ES2019",
      "strict": true,
      "module": "commonjs",
      "allowJs": true, 
    },
    "exclude": [
      "node_modules",
      "dist",
      "webpack.config.js"
    ]
  }

package.json

{
  "name": "msrestjs",
  "version": "1.0.0",
  "main": "index.ts",
  "scripts": {
    "test": "webpack"
  },
  "dependencies": {
    "@azure/ms-rest-js": "2.2.3",
    "ts-loader": "8.0.17",
    "webpack": "5.24.2",
    "webpack-cli": "4.5.0"
  }
}

** Error output **

ERROR in ...\node_modules\@azure\ms-rest-js\es\lib\msRest.js
./node_modules/@azure/ms-rest-js/es/lib/msRest.js 3:21-37
[tsl] ERROR in ...\node_modules\@azure\ms-rest-js\es\lib\msRest.js(3,22)
      TS6053: File '.../node_modules/@azure/ms-rest-js/es/dom-shim.d.ts' not found.

Expected behavior
Compilation without errors

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions