ts-loader icon indicating copy to clipboard operation
ts-loader copied to clipboard

Not working with TypeScript 5.0.2

Open dbartholomae opened this issue 1 year ago • 4 comments

Expected Behaviour

After updating the project to TypeScript 5.0.2, it should build.

Actual Behaviour

It throws errors like this:

Module build failed (from ../../common/temp/node_modules/.pnpm/ts- [email protected][email protected][email protected]/node_modules/ts-loader/index.js): TypeError: ts.createTemplateHead is not a function

Steps to Reproduce the Problem

Update to TypeScript 5.0.2 in a project using ts-loader.

Location of a Minimal Repository that Demonstrates the Issue.

Will add this in case this is an unexpected issue.

dbartholomae avatar Mar 23 '23 11:03 dbartholomae

interesting - createTemplateHead doesn't appear to be an API ts-loader uses

johnnyreilly avatar Mar 23 '23 12:03 johnnyreilly

In addition it doesn't work anymore when loading other compiler like ttypescript. The reason for this is that ts-loader can't find it anymore.

Baumgaer avatar Mar 26 '23 17:03 Baumgaer

Interesting. So https://github.com/TypeStrong/ts-loader#compiler doesn't work with 5.0? I wonder if that's linked to the (major) changes to the internals of TypeScript that happened as part of 5.0

johnnyreilly avatar Mar 26 '23 18:03 johnnyreilly

As I mentioned in another issue, after upgrade all tooling, latest webpack, latest ts-loader, all works fine with Typescript 5.0.x.

My ts-loader configuration for webpack is pretty simple

rules: [
                {
                    test: /\.tsx?$/,
                    use: [
                        "babel-loader",
                        {
                            loader: "ts-loader",
                            options: {
                                onlyCompileBundledFiles: true,
                            },
                        },
                    ],
                },
        ]

MirKml avatar Apr 03 '23 14:04 MirKml