swc-project / pkgs

node.js packages for SWC
59 stars 19 forks source link

swc-loader: How to get sourceMaps to get generated? #51

Open Crismon96 opened 2 months ago

Crismon96 commented 2 months ago

I would like to generate sourceMaps for my bundling when running src-loader. The config allows to specify the sourceMaps option but it's just not generated. This is my web pack configuration:

baseConfig {
  entry: '/Users/christophgriehl/code/predium/apps/backend/src/main.ts',
  devtool: false,
  target: 'node',
  output: { filename: 'main.js' },
  ignoreWarnings: [ /^(?!CriticalDependenciesWarning$)/ ],
  externals: [ [Function (anonymous)] ],
  externalsPresets: { node: true },
  module: { rules: [ [Object] ] },
  resolve: {
    extensions: [ '.tsx', '.ts', '.js' ],
    plugins: [ [TsconfigPathsPlugin] ]
  },
  mode: 'production',
  optimization: { minimize: true, minimizer: [ [TerserPlugin] ] },
  node: { __dirname: false, __filename: false },
  plugins: [
    IgnorePlugin {
      options: [Object],
      checkIgnore: [Function: bound checkIgnore]
    }
  ],
  cache: {
    type: 'filesystem',
    cacheDirectory: '/Users/christophgriehl/code/predium/apps/backend/.build_cache',
    allowCollectingMemory: true
  }
}

The bundle is correctly generated and runs smoothly but there are just no source maps even though they are specified:

baseConfig.module.rules[0].use.options {
  test: /\.tsx?$/u,
  use: {
    loader: 'swc-loader',
    options: { sourceMaps: true, module: [Object], jsc: [Object], minify: true }
  },
  exclude: /(node_modules)/u
}

I am looking for a working solution of someone to make sourceMaps work with swc-loader.