We have a bunch of 1p(First party) JS packages which are used across web and mobile (React Native App). One thing we have noticed is the source map only works for the base package and not for the 1p packages as those are node dependencies added at compile time.
The 1p node modules are not captured as part of the source maps how do we enable for our packages alone? I tried using https://www.npmjs.com/package/source-map-loader but it dosent work and gives error at compile time .
Setup
ERROR in (webpack)-dev-server/client?http://localhost:8080
Module build failed (from ./node_modules/source-map-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
at Object.loader
WebPack Config
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
enforce: "pre",
use: ["source-map-loader"],
},
{
test : /\.scss$/,
use: {
loader: 'sass-loader',
options: {
includePaths: ["./node_modules"]
}
}
},
{
test: /\.js$/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
}
]
},
Edit 1
//https://www.typescriptlang.org/docs/handbook/compiler-options.html
{
"compilerOptions": {
"lib": ["es2016", "es6", "es5", "dom"],
"declaration": true,
"target": "es5",
"module": "commonjs",
"jsx": "react",
// Report errors for fallthrough cases in switch statement.
"noFallthroughCasesInSwitch": true,
// Report errors on unused locals.
"noUnusedLocals": true,
// Report errors on unused parameters.
"noUnusedParameters": false,
"moduleResolution": "node",
// enabled to skip annoying issue with @types/react-native conflict with @types/node
"skipLibCheck": true,
"outDir": "es5",
"experimentalDecorators": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "."
},
"include": ["src/**/*", "tst/**/*"],
"exclude": ["build", "dist", "node_modules/**/*", "tst/**/*"]
}