| 254 | } |
| 255 | |
| 256 | function addMapping(loc: Position, name: string | null = null) { |
| 257 | // we use the private property to directly add the mapping |
| 258 | // because the addMapping() implementation in source-map-js has a bunch of |
| 259 | // unnecessary arg and validation checks that are pure overhead in our case. |
| 260 | const { _names, _mappings } = context.map! |
| 261 | if (name !== null && !_names.has(name)) _names.add(name) |
| 262 | _mappings.add({ |
| 263 | originalLine: loc.line, |
| 264 | originalColumn: loc.column - 1, // source-map column is 0 based |
| 265 | generatedLine: context.line, |
| 266 | generatedColumn: context.column - 1, |
| 267 | source: filename, |
| 268 | name, |
| 269 | }) |
| 270 | } |
| 271 | |
| 272 | if (!__BROWSER__ && sourceMap) { |
| 273 | // lazy require source-map implementation, only in non-browser builds |