Ts-loader: [Question] Build webpack with module in node_modules still typescript

Created on 16 Nov 2018  路  3Comments  路  Source: TypeStrong/ts-loader

I build fail when I updated to use ts-loader@5 with webpack4 (ts-loader@3 with webpack3 build success)

I use rushjs.io, it will helps us to to link library in local,
I write library in ts and not build its to js. In main app, I import ts library to use and webpack cannot build link module.

Eg:

libraries: my-utilities and package.json/main => "src/index.ts"
app/: import { functionA } from 'my-utilities';

ERROR in /Users/abc/Desktop/project/libraries/my-utilities/src/index.ts
Module build failed (from /Users/abc/Desktop/project/common/temp/node_modules/ts-loader/index.js):
Error: TypeScript emitted no output for /Users/abc/Desktop/project/libraries/my-utilities/src/index.ts.
wontfix

Most helpful comment

@kimthangatm I guess you'd probably figured it out by now, since it's in the documentation. But for people in the future finding this issue:
In you webpack config:

  {
    test: /\.ts$/,
    loader: 'ts-loader',
    options: { allowTsInNodeModules: true }
  }

And in you tsconfig file:

 {
    "include": [
      "node_modules/whitelisted_module.ts"
    ],
    "files": [
      "node_modules/my_module/whitelisted_file.ts"
    ]
  }

All 3 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@kimthangatm I guess you'd probably figured it out by now, since it's in the documentation. But for people in the future finding this issue:
In you webpack config:

  {
    test: /\.ts$/,
    loader: 'ts-loader',
    options: { allowTsInNodeModules: true }
  }

And in you tsconfig file:

 {
    "include": [
      "node_modules/whitelisted_module.ts"
    ],
    "files": [
      "node_modules/my_module/whitelisted_file.ts"
    ]
  }

Closing as stale. Please reopen if you'd like to work on this further.

Was this page helpful?
0 / 5 - 0 ratings