I have a library (simple helper functions) that is bundled with esbuild:
esbuild.js
esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
sourcemap: true,
minify: true,
out: 'dist',
format: 'cjs',
target: ['es6']
})
With the above, i see
/dist
/user
profile.d.ts
settings.d.ts
history.d.ts
/invoice
latest.d.ts
quarter.d.ts
index.d.ts
index.js
index.js.map
In my consuming app, i able able to import and use the above lib functions just fine. However debugging in the browser, the library code is minified/hard to read.
I am trying to get the consuming apps webpack.config to load either the raw src code from the lib or sourcemaps.
webpack.config.js:
module.exports = (env, argv) = {
return {
devtool: 'source-map',
module: {
rules: [
{
// Match js, jsx, ts & tsx files
test: /.[jt]sx?$/,
loader: 'esbuild-loader',
options: {
// JavaScript version to compile to
loader: 'tsx',
target: 'es2015',
sourcemap: true
}
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx']
},
target: ['web', 'es5'],
optimization: {
minimizer: [
new ESBuildMinifyPlugin({
target: 'es2015'
})
]
}
}
}