Questions tagged [ts-loader]

214 questions
89
votes
7 answers

Webpack cant resolve TypeScript modules

I build a relay small webpack and typescript demo to play with. If i run webpack with the webpack.config.js i get this error: ERROR in ./js/app.ts Module not found: Error: Can't resolve './MyModule' in…
Timo Paul
  • 905
  • 1
  • 7
  • 8
62
votes
4 answers

Webpack cant compile ts 3.7 (Optional Chaining, Nullish Coalescing)

I try to use typescript 3.7 features like Optional Chaining, Nullish Coalescing. But webpack gives me an error while transpaling. app: Module parse failed: Unexpected token (50:40) app: File was processed with these loaders: app: *…
Edgaras Karka
  • 7,400
  • 15
  • 61
  • 115
59
votes
1 answer

Why use babel-loader with ts-loader?

There is a TypeScript, Babel, React, and Karma Sample. The Webpack config contains babel-loader with ts-loader for .tsx? files. Please explain why it is needed? Why isn't ts-loader enough?
Yuriy
  • 1,370
  • 4
  • 14
  • 30
34
votes
6 answers

Webpack ts-loader : change tsconfig filename

I have 2 tsconfigs, one for my dev build and one for my prod build. I choose the tsconfig with the -p flag : tsc -p dev.tsconfig.json Ts-loader is looking for a tsconfig.json file. How can I specify another filename with the…
gr3g
  • 2,866
  • 5
  • 28
  • 52
26
votes
4 answers

Module build failed: Error: Typescript emitted no output for

When I try to compile a .ts file I get the following error: Module build failed: Error: Typescript emitted no output for C:\xampp\htdocs\node-api\src\js\server.ts. at successLoader…
SuperDJ
  • 7,488
  • 11
  • 40
  • 74
26
votes
2 answers

Module not found: Error: Can't resolve 'ts-loader'

Following is my webpack.config.js var webpack = require('webpack'), path = require('path'), yargs = require('yargs'); var libraryName = 'MyLib', plugins = [], outputFile; if (yargs.argv.p) { plugins.push(new…
MARKAND Bhatt
  • 2,428
  • 10
  • 47
  • 80
24
votes
1 answer

WebPack ts-loader compiling all files when I only want it to run in one folder/file

I found a problem in my app structure and build process using WebPack, TypeScript, and TS-Loader that I thought was caused by TypeScript 2.1.4, but apparently was there the whole time. You can see all the details from my other post: TypeScript 2.1.4…
user358089
20
votes
1 answer

ts-loader vs babel-loader in Typescript using webpack

So I was trying to compare the output compiled code by these 2 combinations. ts-loader { test: /\.tsx?$/, use: 'ts-loader', } babel-loader use: { loader: 'babel-loader', options: { presets: [ …
fjplaurr
  • 1,818
  • 3
  • 19
  • 36
16
votes
6 answers

Webpack: import TypeScript module both "normally" and as raw string

Using webpack ^v2.2.1, I would like to import a TypeScript module as text, in addition to importing the same module "normally". I've figured that I probably should use the raw-loader. But it isn't working out. Some example code: import DemoComponent…
Shahar 'Dawn' Or
  • 2,713
  • 1
  • 26
  • 38
12
votes
1 answer

webpack-dev-server & ts-loader not reloads when interface changed

I'm using webpack@4.16.1, webpack-dev-server@3.1.4 and ts-loader@4.4.2. I use Interface/index.ts to manage imports, to organize multiple interface imports. But When I change interface file, webpack-dev-server(or ts-loader, I don`t know) not reload &…
kuroneko0441
  • 415
  • 5
  • 14
12
votes
3 answers

Typescript declaration file created with alias instead of relative path

Edit 1: Added GitHub URL to project Edit 2: Removing baseUrl from tsconfig.json fixes all problems and using relative imports works fine. Link: Github How do I generate a typescript declaration file with relative paths instead of alias? I am…
12
votes
1 answer

How to include untyped node modules with Typescript 1.8?

Typescript 1.8 now supports untyped JS files. To enable this feature, just add the compiler flag --allowJs or add "allowJs": true to compilerOptions in tsconfig.json via…
Frozen Crayon
  • 5,172
  • 8
  • 36
  • 71
9
votes
0 answers

Ts-loader/webpack - how to resolve files outside of working folder with webpack

I have a project which happens to be a vs code extension, but I think that's not too relevant. I have the following structure: ./package.json ./tsconfig.json --> references [ ./client, ./server, ./interfaces] ./client package.json …
Kir
  • 2,905
  • 2
  • 27
  • 44
9
votes
0 answers

Emit TypeScript modules as separate JavaScript files

I'm authoring a library and I want to provide both a bundle (where all files are compiled together) and a js folder where each module is emitted separately with its .d.ts file next to it. My goal is to allow: Using separate files as TS modules from…
dodov
  • 5,206
  • 3
  • 34
  • 65
9
votes
1 answer

What's the most efficient way to emit type declarations?

What's the most efficient way to emit type declarations for a Typescript project (library) along with code transpiling and bundling? I'm using webpack, ts-loader and fork-ts-checker-webpack-plugin. In one build cycle (build command) I'm trying to…
webpepper
  • 131
  • 5
1
2 3
14 15