buildcompilationdartdart-pubdart2js

How do i keep dart names (variables, constants, objects ) using dart2js commands?


I'm trying to compile a dart project by using the command

pub build

However, this will generate random identifiers for all objects, which will ruin all logging information when it prints the object name.

For example, "Object = K1" is printed instead of "Object = Mirror".

Is there a way to keep all dart names, while compiling to .js?

I also tried:

pub build --mode=debug

...but the downside is that for production builds, debug mode is now allowed.

Is there any production build approach for this issue?


Solution

  • You can disable minification in pubspec.yaml:

    transformers:
    - $dart2js:
      minify: false
    

    See here for more details about the pub transformer.