TypeStrong / TypeStrong/ts-loader

ts-loader can't load Typescript with any version > 5.0.4

Open
#1,635 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.5k
Forks
439
Avg merge
17h 17m
Merged PRs (30d)
2

Description

This is the webpack config file I am using :

var webpack = require('webpack');
var path = require('path');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  mode: 'production',
  entry: './src/index.ts',
  target: 'node',
  output: {
    filename: 'app.js',
    libraryTarget: 'commonjs2',
    path: path.resolve(__dirname, 'dist'),
  },
  devtool: 'source-map',
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin()],
  },
  resolve: {
    extensions: ['.ts', '.js'],
  },
  module: {
    rules: [
      // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
      { test: /\.tsx?$/, loader: 'ts-loader' },
    ],
  },
};

Expected Behaviour

Running webpack --config ./webpack.config.js with any Typescript version > 5.0.4 should pass

Actual Behaviour

This is what I get when I try running webpack with any Typescript version > 5.0.4 :

Error: Could not load TypeScript. Try installing with yarn add typescript or npm install typescript. If TypeScript is installed globally, try using yarn link typescript or npm link typescript.

However, this works with any version <= 5.0.4, so, I am not sure what would be the workaround for this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using the webpack.config.js shown in the issue, with TypeScript newer than 5.0.4, and compare it with a working version. Trace ts-loader's TypeScript loading path and verify the webpack command completes successfully with the newer TypeScript versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.