Unable to get ts-loader to compile files in node_modules.
My Webpack config has this:
{
test: /\.tsx?$/,
include: [/src\//, /node_modules\/@scope\/some-package/],
loader: 'ts-loader',
options: {
transpileOnly: true,
allowTsInNodeModules: true,
configFile: '../../tsconfig.json',
},
},
and the configFile at the root of my project has:
"include": ["src/**/*", "node_modules/@scope/some-package/src/util/**/*"]
And then my source does
import {SomeThing} from '@scope/some-package/src/util/SomeThing'
Expected Behaviour
It should work
Actual Behaviour
Webpack says something like
ERROR in ../node_modules/@scope/some-package/src/tiles/SomeThing.worker.ts 46:7
Module parse failed: Unexpected token (46:7)
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
| // because xmldom tries to access "window.DOMParser". See webpack.config (here
| // or in other utils).
> ;(self as any).DOMParser = require('xmldom').DOMParser
|
| const textDecoder = new TextDecoder()
The as any is TypeScript that ts-loader isn't handling.
Did I miss something in the configuration?
Steps to Reproduce the Problem
I have a private repo. Willing to sign an NDA (if I can get one)?
Location of a Minimal Repository that Demonstrates the Issue.
^^^
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing as stale. Please reopen if you'd like to work on this further.
Having exactly same situation. So desperately want to find a solution T_T
Related: https://github.com/TypeStrong/ts-loader/issues/278
mee too, I'm getting the same
https://www.npmjs.com/package/ts-loader#allowtsinnodemodules ?