Skip to content

Error: Transformation map 0 must have exactly one source file #85

Closed
@milahu

Description

@milahu

please explain this error

Error: Transformation map 0 must have exactly one source file.
Did you specify these with the most recent transformation maps first?

this is required for all but the last/oldest sourcemap (index -1)

i mean, why must maps 0 to -2 have only one source file?
this looks more like 'not implemented' than 'error'

put differently:
why does remapper not support convergent transform chains?
= multiple input files + single output file, arranged in a tree structure

also, if i recall right, only the first entry of maps[-1].sources
is propagated to result.sources. doesnt that break sourcesIdx values?

reproduce
const remapper = require('@ampproject/remapping');

// segment =
//     [ columnIdx_gen ]
//   | [ columnIdx_gen, sourcesIdx, lineIdx, columnIdx ]
//   | [ columnIdx_gen, sourcesIdx, lineIdx, columnIdx, namesIdx ]

const trigger_error = 1;

const sourcemapList = [
  // map 0
  {
    version: 3,
    sources: trigger_error
      ? [
          'file-3', // src 0
          'file-4', // src 1
        ]
      : [
          'file-3',
        ],
    names: [],
    mappings: [
      trigger_error
      ? [
          [0, 0, 0, 0], // col 0 = src 0
          [1, 1, 0, 0], // col 1 = src 1
        ]
      : [
          [0, 0, 0, 0],
        ]
    ]
  },
  // map 1
  {
    version: 3,
    sources: [
      'file-1', // src 0
      'file-2', // src 1
    ],
    names: [],
    mappings: [
      [
        [0, 0, 0, 0], // col 0 = src 0
        [1, 1, 0, 0], // col 1 = src 1
      ]
    ]
  }
];

const sourcemap = remapper(
  sourcemapList,
  function loader(file) {
    return null;
  }
);
console.dir(sourcemap);

actual result with trigger_error = 0:

    sources: [
      'file-1', // src 0 of map 1
    ],

expected result:

    sources: [
      'file-1',
      'file-2',
      'file-3',
      'file-4',
    ],

Metadata

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