-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(source map): handle source map in middle of file (#392)
Co-authored-by: Hiroki Osame <[email protected]>
- Loading branch information
1 parent
7676143
commit 497f69a
Showing
4 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { testSuite, expect } from 'manten'; | ||
import { stripSourceMap } from '../../src/source-map'; | ||
|
||
export default testSuite(({ describe }) => { | ||
describe('Source Map', ({ describe }) => { | ||
describe('stripSourceMap', ({ test }) => { | ||
test('end of file, no trailing newline', () => { | ||
const file = 'const foo = 1;\n//# sourceMappingURL=foo.js.map'; | ||
expect(stripSourceMap(file)).toBe('const foo = 1;'); | ||
}); | ||
|
||
test('end of file, with trailing newlines', () => { | ||
const file = 'const foo = 1;\n//# sourceMappingURL=foo.js.map\n'; | ||
expect(stripSourceMap(file)).toBe('const foo = 1;\n'); | ||
}); | ||
|
||
test('middle of file', () => { | ||
const file = 'const foo = 1;\n//# sourceMappingURL=foo.js.map\nconst bar = 2;'; | ||
expect(stripSourceMap(file)).toBe('const foo = 1;\nconst bar = 2;'); | ||
}); | ||
}); | ||
}); | ||
}); |