Skip to content

currentCallback is not a function #338

Closed
@yuzhouu

Description

os: win10
node: v8.5.0
source-map: 0.7.2

the below function will run into error currentCallback is not a function

function mergeSourcemap(
  sourceMapConsumer_1,
  sourceMapConsumer_2
) {
    sourceMapConsumer_2.eachMapping((mappingItem) => {
    const { source, column, line } = sourceMapConsumer_1.originalPositionFor({
      column: m.originalColumn,
      line: m.originalLine,
    });
  });
}

error stack:

TypeError: currentCallback is not a function
    at mapping_callback (D:\Workspace\js\sourcemap-composer\node_modules\source-map\lib\wasm.js:64:13)
    at <WASM UNNAMED> (<WASM>[30]+196)
    at BasicSourceMapConsumer_eachMapping._wasm.withMappingCallback (D:\Workspace\js\sourcemap-composer\node_modules\source-map\lib\source-map-consumer.js:404:30)
    at Object.withMappingCallback (D:\Workspace\js\sourcemap-composer\node_modules\source-map\lib\wasm.js:95:11)
    at BasicSourceMapConsumer_eachMapping [as eachMapping] (D:\Workspace\js\sourcemap-composer\node_modules\source-map\lib\source-map-consumer.js:388:16)

I guess it is caused by I invoke originnalPositionFor method of consumer_1 in the eachMapping method of consumer_2.

and for your reference
  • if I hoist the sourceMapConsumer_1.originalPositionFor from the eachMapping, this will work well
  • the same code work well in the source-map@0.5.6

thank you for your glance

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions