Next.js Discord

Discord Forum

Build fails due to npm package with sourcemaps

Unanswered
Mrigal carp posted this in #help-forum
Open in Discord
Mrigal carpOP
Error
○ Compiling /instrumentation ...
⨯ ../../node_modules/<redacted>/common-data-types/build/model/rule/RuleDescriptor.d.ts.map
Module parse failed: Unexpected token (1:10)
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

Description
I have a private npm package, which I'd like to use to initialize a kafka consumer in instrumentation.ts.
The package has a file ScanRule with a function which dynamically requires other .js modules, but that's not used in our context, it's just present there.
I suppose, due to the presence of that dynamic require, webpack tries to parse every other file in that folder including .d.ts.map sourcemaps

Questions
Is there any way to work that out?
Is instrumentation.ts the right place to init my kafka consumers?

(screenshots below)

1 Reply

Mrigal carpOP
1. Part of npm package that dynamically requires stuff
2. Webpack import trace from compilation error