|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
796 bytes
|
| Line | |
|---|
| 1 | const { SourceMapGenerator } = require('source-map');
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Generates an identity source map from a source file.
|
|---|
| 5 | * @param {string} source The content of the source file.
|
|---|
| 6 | * @param {string} resourcePath The name of the source file.
|
|---|
| 7 | * @returns {import('source-map').RawSourceMap} The identity source map.
|
|---|
| 8 | */
|
|---|
| 9 | function getIdentitySourceMap(source, resourcePath) {
|
|---|
| 10 | const sourceMap = new SourceMapGenerator();
|
|---|
| 11 | sourceMap.setSourceContent(resourcePath, source);
|
|---|
| 12 |
|
|---|
| 13 | source.split('\n').forEach((line, index) => {
|
|---|
| 14 | sourceMap.addMapping({
|
|---|
| 15 | source: resourcePath,
|
|---|
| 16 | original: {
|
|---|
| 17 | line: index + 1,
|
|---|
| 18 | column: 0,
|
|---|
| 19 | },
|
|---|
| 20 | generated: {
|
|---|
| 21 | line: index + 1,
|
|---|
| 22 | column: 0,
|
|---|
| 23 | },
|
|---|
| 24 | });
|
|---|
| 25 | });
|
|---|
| 26 |
|
|---|
| 27 | return sourceMap.toJSON();
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | module.exports = getIdentitySourceMap;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.