Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack ts-loader error using TS 4.7 #48020

Closed
mjbvz opened this issue Feb 24, 2022 · 6 comments
Closed

webpack ts-loader error using TS 4.7 #48020

mjbvz opened this issue Feb 24, 2022 · 6 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Feb 24, 2022

Bug Report

🔎 Search Terms

  • webpack
  • ts-loader
  • @types

🕗 Version & Regression Information

  • This changed between versions TS 4.6-1-rc and 4.7.0-dev.20220223

💻 Code

Clone https://github.com/mjbvz/ts-47-webpack-error

In the project run:

npm i
npm run build

🙁 Actual behavior

The presence of @types/dompurify in the project triggers the following error:

ERROR in ./src/index.ts
Module build failed (from ./node_modules/ts-loader/index.js):
TypeError: path.indexOf is not a function
    at normalizeSlashes (/Users/matb/projects/san/ts-webpack/node_modules/typescript/lib/typescript.js:7691:26)
    at Object.combinePaths (/Users/matb/projects/san/ts-webpack/node_modules/typescript/lib/typescript.js:7757:28)
    at /Users/matb/projects/san/ts-webpack/node_modules/typescript/lib/typescript.js:41922:40
    at Object.firstDefined (/Users/matb/projects/san/ts-webpack/node_modules/typescript/lib/typescript.js:407:26)
    at primaryLookup (/Users/matb/projects/san/ts-webpack/node_modules/typescript/lib/typescript.js:41921:27)
    at Object.resolveTypeReferenceDirective (/Users/matb/projects/san/ts-webpack/node_modules/typescript/lib/typescript.js:41880:24)
    at /Users/matb/projects/san/ts-webpack/node_modules/ts-loader/dist/servicesHost.js:713:18
    at /Users/matb/projects/san/ts-webpack/node_modules/ts-loader/dist/servicesHost.js:128:141
    at Array.map (<anonymous>)
    at Object.resolveTypeReferenceDirectives (/Users/matb/projects/san/ts-webpack/node_modules/ts-loader/dist/servicesHost.js:128:124)

🙂 Expected behavior

This example builds under TS 4.6-rc and TS 4.5. I'm guessing something about the TS internal APIs that ts-loader depends on has changed

@mjbvz
Copy link
Contributor Author

mjbvz commented Feb 24, 2022

This seems to be caused by this directive at the top of @types/dompurify:

/// <reference types="trusted-types"/>

I can actually simplify this repo: it seems you just need any triple slash type reference in the project to cause the crash. I also see this when adding /// <reference types="node"/> to src/index.js

@fatcerberus
Copy link

Callstack looks the same as #47921, but that one was tagged External.

@RyanCavanaugh RyanCavanaugh added the External Relates to another program, environment, or user action which we cannot control. label Feb 24, 2022
@RyanCavanaugh
Copy link
Member

See e.g. TypeStrong/ts-node#1647

@RyanCavanaugh
Copy link
Member

Logged TypeStrong/ts-loader#1421

@johnnyreilly
Copy link

I've put together a speculative fix for this issue in ts-loader. @mjbvz would you care to give it a test? It appears to work, but my testing is purely based on your repro repo; I haven't encountered this issue directly myself.

TypeStrong/ts-loader#1422

@typescript-bot
Copy link
Collaborator

This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

5 participants