direflow icon indicating copy to clipboard operation
direflow copied to clipboard

"emitSourceMap": true. generatesempty source map file

Open merajcal opened this issue 4 years ago • 2 comments

Describe the bug
"emitSourceMap": true does not emit soure map

source map file has following incorrect content

{"version":3,"sources":[],"names":[],"mappings":"","file":"direflowBundle.js","sourceRoot":""}

demo application https://github.com/merajcal/direflow-lit-example/tree/master/direflow-lit

To reproduce
Steps to reproduce the behavior:

  1. Install '...'
  2. Open '....'
  3. Build '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Package Manager:
To install Direflow, I used... (npm / yarn / something else)

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

merajcal avatar Dec 04 '20 09:12 merajcal

https://github.com/Silind-Software/direflow/blob/990016cf1569f628f7771729ffbb3cac31f52014/packages/direflow-scripts/src/config/config-overrides.ts#L122

The sourceMap option was only configured as true in development environment, so we got an empty souce map file after build.

zeratul1 avatar Aug 23 '21 03:08 zeratul1

This issue still happens to me especially since this project hasn't been updated in a while. A workaround I found in my .NET Core app with DireflowBundle as a web-component is that if you edit the `webpack-config.js file to this:

const { webpackConfig } = require("direflow-scripts");
const { env } = require("process");

module.exports = (config, env) => ({
  ...webpackConfig(config, env, {
    react: '/cdn/react.js',
    reactDOM: 'cdn/react-dom.js',
  }),
  mode: 'development',
  devtool: 'inline-source-map',
  optimization:{
    minimize: false
  }
});

Where you add the mode, devtool, and optimization options...it'll generate an inline source map though the cost is that the file size will go from ~800kb to ~12mb. So don't use it in anything besides dev environments!

Hope this helps if you're reading this from the future ;)

surenzz avatar Apr 26 '23 19:04 surenzz