Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 28 13:20
    Bessonov commented #653
  • Jan 28 07:12
    GEMI commented #653
  • Jan 24 19:38
    johnnyreilly commented #1405
  • Jan 24 19:37
    markjm commented #1405
  • Jan 24 13:02
    AlexeyRyazanov commented #595
  • Jan 24 13:02
    AlexeyRyazanov commented #595
  • Jan 24 12:46
    AlexeyRyazanov commented #1382
  • Jan 24 05:11
    johnnyreilly commented #1405
  • Jan 23 22:41
    markjm commented #1405
  • Jan 23 08:37
    mirumirumi edited #1390
  • Jan 21 20:55
    dependabot[bot] labeled #1408
  • Jan 21 20:55

    dependabot[bot] on npm_and_yarn

    Bump log4js from 6.3.0 to 6.4.0… (compare)

  • Jan 21 20:55
    dependabot[bot] opened #1408
  • Jan 21 06:34
    johnnyreilly commented #1405
  • Jan 21 06:20
    markjm commented #1405
  • Jan 20 18:40
    etiennenoel closed #1407
  • Jan 20 18:40
    etiennenoel commented #1407
  • Jan 20 18:02
    etiennenoel opened #1407
  • Jan 20 06:49
    johnnyreilly commented #1405
  • Jan 19 23:58
    patrick99e99 opened #1406
Eric Anderson
@ericanderson
I think I'm losing my mind. This should work with TS 2.7.2 and esModuleInterop right? It just seems to ignore that setting
antch
@antch
Hi, I'm trying to get my project up and running with ts-loader/ts-lint/fork-ts-checker-webpack-plugin and I'm having a problem where the typechecking/linting doesn't seem to be honoring my include/exclude in tsconfig.json -- is there somewhere else that I'm supposed to set that stuff?
I can set include in tsconfig.json to a glob that matches nothing, and I still get type/lint output for every ts file underneath the webpack context root
antch
@antch
Same with watch, setting that to an invalid path still results in checking/linting for every file
antch
@antch
User error, I had "include" under "compilerOptions" in tsconfig.json
facepalm
Anton Ermak
@raymank26

HI! Guys, does anybody have a luck to work with "*.d.ts" files?

//globals.d.ts

declare module 'my-module' {
    class SomeClass {
        static foo(a: string): void
    }
    export = SomeClass;
}

//MyComponent.vue

 import bar = require('my-module');
....
bar.foo("baz");

Module not found: Error: Can't resolve 'my-module' in ...

//tsconfig.json

{
    "compilerOptions": {
        "outDir": "./built/",
        "sourceMap": true,
        "strict": true,
        "noImplicitReturns": true,
        "module": "amd",
        "moduleResolution": "node",
        "target": "es5",
        "experimentalDecorators": true,
        "strictPropertyInitialization": false
    },
    "include": [
        "./web/**/*"
    ]
}

Any ideas?

Semyon V
@uoziod
is anyone here?
Olmo del Corral
@olmobrutall
Maybe TS doesn’t find your Globals.d.ts
Have you tried adding a ///<reference comment ?
Rich Seviora
@richseviora
Wondering if anyone's ran into issues with ts-loader having trouble referencing modules with .d.ts files based on the module setting in tsconfig.json
In my scenario I have:
{
    "compilerOptions": {
        "target": "esnext",
        "module": "ESNext",
        "jsx": "preserve",
        "declaration": false,
        "outDir": "lib",
        "strict": true,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "emitDecoratorMetadata": false
    }
}
And this generates the error
ERROR in /Users/richardseviora/Projects/zhu-li/do/the/thing/IRootState.ts
[tsl] ERROR in /Users/richardseviora/Projects/zhu-li/do/the/thing/IRootState.ts(1,27)
      TS2307: Cannot find module 'immutable'.
However, if I set module to commonjs then it doesn't complain.
Webpack loader config:
      {
        test: /\.tsx?$/,
        loaders: ['babel-loader', 'ts-loader'],
        exclude: /node_modules/,
      },
Rich Seviora
@richseviora
Hmm. This might actually be a TypeScript issue. When I try executing yarn exec tsc -- -m ESNext -t ESNext /Users/richardseviora/Projects/zhu-li/do/the/thing/site.ts, it generates similar "cannot find module '$MODULE'" errors.
Rich Seviora
@richseviora
Ahhhhhh. So setting module to commonjs will set moduleResolution to node automatically, but module: ESNext doesn't do that.
So you have to explicitly set moduleResolution to node .
Thomas Havlik
@thavlik
Hi folks. I am working with a package that merely has an index.d.ts at its root (next to package.json) with "types": "./index.d.ts" in its package.json. tsc is able to compile this project just fine, and VSCode is able to pick up the .d.ts just fine, but ts-loader fails to find the module
Here is my webpack config:
const path = require("path");
const webpack = require("webpack");
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const tsConfigPath = path.resolve(__dirname, "../tsconfig.json");
const rootDir = path.resolve(__dirname, "../");
const outDir = path.resolve(rootDir, "cordova/www/js/");

console.log(`Using tsconfig.json from ${tsConfigPath}`);

module.exports = [{
    mode: "development",
    context: path.resolve(rootDir, "src"),
    entry: "./index.tsx",
    output: {
        path: outDir,
        filename: "bundle.js",
        globalObject: "window"
    },
    devtool: "source-map",
    module: {
        rules: [{
            test: /\.tsx?$/,
            loader: "ts-loader" // "happypack/loader?id=ts" // 
        }]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(), // enable HMR globally
        new webpack.NamedModulesPlugin()
    ],
    resolve: {
        extensions: [".tsx", ".ts", ".js"],
        plugins: [new TsconfigPathsPlugin({
            configFile: tsConfigPath
        })]
    },
    target: "node"
}];
additionally, I am actually trying to target "web". I have another project (a web server) that uses target: "node", adds the package in the exact same way, and compilation succeeds (just like compiling with tsc does)
Here is my tsconfig, which is the exact same as the server tsconfig:
{
    "compilerOptions": {
        "module": "commonjs",
        "esModuleInterop": true,
        "target": "es6",
        "noImplicitAny": false,
        "moduleResolution": "node",
        "preserveConstEnums": true,
        "sourceMap": true,
        "outDir": "dist",
        "baseUrl": ".",
        "jsx": "react"
    },
    "include": [
        "./src/**/*"
    ],
    "exclude": [
        "./dist/**/*",
        "./node_modules"
    ]
}
The error in question is Module not found: Error: Can't resolve 'my-type-definitions' in '<path>.ts'. I am importing the module as import Types from "my-type-definitions";
I kind of need this to be importable, so VSCode can get type info. With the way the declaration file is written, it is intended for import.
Thomas Havlik
@thavlik
changing my .d.ts to use export = MyLib; export as namespace MyLib; declare namespace MyLib { ... } still works with vs code and tsc, but doesn't work with ts-loader.
Thomas Havlik
@thavlik
Upon further investigation (errorDetails: true) the compiler is looking only for .ts or .tsx files
Adding index.ts containing only ///<reference path="./index.d.ts" /> seems to permit compilation... that's a suboptimal solution, though
antch
@antch
Any suggestions for linting through ts-loader alongside AngularCompilerPlugin?
Obviously the Angular compiler does tree shaking and emits JS itself, so I'm not sure if it's possible to run those TS files through ts-loader prior to that
I already use the forktschecker plugin for other .ts files so that would be ideal if possible
jestarray
@jestarray
how do i force ts-loader to build even if there's a typescript error ?
using a library that has 70% accurate typings file
and that 30% hits hard
Failing the build on TypeScript compilation error
The build should fail on TypeScript compilation errors as of webpack 2. If for some reason it does not, you can use the webpack-fail-plugin.

For more background have a read of this issue.
should also be reflected on docs on how to disable it
WanderWang
@WanderWang
hey guys ! Anything update about project reference ? TypeStrong/ts-loader#935
Rudi Jansen van Vuuren
@rudivuuren_gitlab
Does anyone know why I am getting Must use import to load ES Module when using webpack and ts-loader? I am targeting es2015 and commonjs module in tsconfig.
stweedie
@stweedie
is there any way to see the intermediate files generated?
I'm getting an error that seems to deal with the null assertion operator
Unexpected token: operator (!)
Pierre-Luc Auclair
@plauclair
Is anyone having any luck combining ts-loader with NormalModuleReplacement?
mukuluec
@mukuluec
Hi all, I need your help on a "Javascript heap out of memory" issue I am getting on compiling ts codebase with webpack, with ts-loader and fork-ts-checker-webpack-plugin. Not using fork-ts-checker-webpack-plugin fixes the issue, because that disables type-checking. The type checker is getting stuck for about 15-20 minutes, before it throws error. How can I see the logs from the type-checker, to find what files it is actually type-checking? Would be really grateful for your help.
Michael Wrock
@Daeluse

Hey guys, I'm running into an issue that hopefully someone will be able to shed light on. I have a VueJS monorepo using lerna. Everything builds fine, and declarations are being generated, but I notice that the declaration directory for a package will also contain declarations for sibling dependencies in the monorepo.

IE if I have two packages, core and common, the declaration directory for common package contains two folders named core and common, each having the respective declarations.

This is making out distributed packages slightly larger since types are being duplicated, so I would like to get it resolved if possible.

Matthew Hayden
@mrehayden1
Can I use ts-loader to load JSON files? If I try to include them in the test for ts-loader something tries to append '"use strict";' at the start of every file.
These are the rules I'm using:
rules: [{
      enforce: 'pre',
      test: /.ts$/,
      use: [ 'eslint-loader' ]
    }, {
      exclude: /node_modules/,
      test: /.(ts|json)$/,
      use: [ 'ts-loader' ]
    }, {
      test: /\.s?css$/,
      use: [
        'style-loader',
        'css-loader',
        'sass-loader'
      ]
    }, {
      test: /\.(eot|png|svg|ttf|woff2?)$/,
      use: [ 'file-loader' ]
    }]
and my tsconfig.json file:
{
  "compilerOptions": {
    "lib": [
      "DOM",
      "ESNext",
      "ScriptHost"
    ],
    "resolveJsonModule": true,
    "target": "ES5"
  }
}
Cutewarriorlover
@cutewarriorlover_gitlab
Is it possible for ts-loader to ignore declaration files?
Joshua V Sherman
@JoshuaVSherman

good morning, a coworker is trying to install and build my project and is getting this error, but I am not getting any errors (and I have cloned it into a completely new directory and everything, no error on build, please help). ERROR in ./src/index.tsx 8:2
Module parse failed: Unexpected token (8:2)
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
|
| ReactDOM.render(

<React.StrictMode>
| <App />,
| </React.StrictMode>,

Joshua V Sherman
@JoshuaVSherman
we figured out that we had different versions of npm was the issue