source_map_stack_trace 2.0.0

  • Readme
  • Changelog
  • Installing
  • 95

source_map_stack_trace is a package for converting stack traces generated by dart2js-compiled JavaScript code into readable native Dart stack traces using source maps. For example:

import 'package:source_map_stack_trace/source_map_stack_trace.dart';

void main() {
  var jsTrace = // Get a StackTrace generated by dart2js.
  var mapping = // Get a source map mapping the JS to the Dart source.

  // Convert jsTrace to refer to the Dart source instead.
  var dartTrace = mapStackTrace(jsTrace, sourceMap);

This can convert the following JavaScript trace:

expect_async_test.dart.browser_test.dart.js 2636:15   dart.wrapException
expect_async_test.dart.browser_test.dart.js 14661:15$0
expect_async_test.dart.browser_test.dart.js 18237:26$1
expect_async_test.dart.browser_test.dart.js 17905:23$0
expect_async_test.dart.browser_test.dart.js 17876:16  StackZoneSpecification._stack_zone_specification$_run$2
expect_async_test.dart.browser_test.dart.js 17899:26$1
expect_async_test.dart.browser_test.dart.js 6115:16   _rootRunUnary
expect_async_test.dart.browser_test.dart.js 8576:39   _CustomZone.runUnary$2
expect_async_test.dart.browser_test.dart.js 7135:57$0
expect_async_test.dart.browser_test.dart.js 7031:147  dart._Future.static._Future__propagateToListeners


dart:_internal/compiler/js_lib/js_helper.dart 1210:1          wrapException
test/frontend/expect_async_test.dart 24:5                     main.<fn>.<fn>
package:test/src/backend/declarer.dart 45:48                  Declarer.test.<fn>.<fn>
package:stack_trace/src/stack_zone_specification.dart 134:30  StackZoneSpecification.registerUnaryCallback.<fn>.<fn>
package:stack_trace/src/stack_zone_specification.dart 210:7   StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 135:5   StackZoneSpecification.registerUnaryCallback.<fn>
dart:async/zone.dart 904:14                                   _rootRunUnary
dart:async/zone.dart 806:3                                    _CustomZone.runUnary
dart:async/future_impl.dart 486:13                            _Future._propagateToListeners.handleValueCallback
dart:async/future_impl.dart 567:32                            _Future._propagateToListeners

2.0.0 #

Breaking Changes #

  • Removed dependency on package_resolver and changed the apis to accept a Map<String, Uri> which maps package names to the base uri to resolve the package: uris for those packages.
  • The sdkRoot argument must be an Uri. Use Uri.parse for use cases previously passing a String.
  • The deprecated packageRoot argument has been removed.

1.1.5 #

  • Set max SDK version to <3.0.0.

1.1.4 #

  • Support source maps that depend on the uri of the location to resolve spans correctly.

1.1.3 #

  • Add a missing dependency on path.

1.1.2 #

  • Fix a typo in the previous fix.

1.1.1 #

  • Don't crash if the SyncPackageResolver has no package information at all.

1.1.0 #

  • mapStackTrace() now uses a SyncPackageResolver object from the package_resolver package to recreate package: URIs.

  • Deprecation: the packageRoot parameter to mapStackTrace is deprecated in favor of the packageInfo parameter described above. It will be removed in a future release.

1.0.5 #

  • Add compatibility for member names that include named arguments.

1.0.4 #

  • Add compatibility for Dart 1.10-style name munging.

1.0.3 #

  • Prefer "dart:" URLs to "package:" URLs.

1.0.2 #

  • Fix an off-by-one bug that was causing line numbers to be slightly off.

1.0.1 #

  • Don't crash when mapping stack chains.

1.0.0 #

  • Initial release.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  source_map_stack_trace: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:source_map_stack_trace/source_map_stack_trace.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jun 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and source_map_stack_trace.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.

The package description is too short. (-9 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
path ^1.0.0 1.7.0
source_maps ^0.10.2 0.10.9
stack_trace ^1.0.0 1.9.3
Transitive dependencies
charcode 1.1.3
collection 1.14.12
meta 1.1.8
term_glyph 1.1.0
Dev dependencies
pedantic ^1.0.0
source_span ^1.6.0 1.7.0
test ^1.12.0