-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(terser): support .map files in directory inputs (#1250)
- Loading branch information
1 parent
5e43e18
commit dfefc11
Showing
7 changed files
with
96 additions
and
15 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
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,27 @@ | ||
const fs = require('fs'); | ||
const sm = require('source-map'); | ||
const path = require('path'); | ||
const {runfiles} = require('build_bazel_rules_nodejs/internal/linker'); | ||
|
||
describe('terser on a directory with map files', () => { | ||
it('should produce an output for each input', () => { | ||
const out = runfiles.resolvePackageRelative('dir.min'); | ||
expect(fs.existsSync(out + '/src1.js')).toBeTruthy(); | ||
}); | ||
|
||
it('should produce a sourcemap output', async () => { | ||
const out = runfiles.resolvePackageRelative('dir.min'); | ||
const file = require.resolve(out + '/src1.js.map'); | ||
const rawSourceMap = JSON.parse(fs.readFileSync(file, 'utf-8')); | ||
await sm.SourceMapConsumer.with(rawSourceMap, null, consumer => { | ||
const pos = consumer.originalPositionFor( | ||
// position of MyClass in terser_minified output src1.min.js | ||
// depends on DEBUG flag | ||
!process.env['DEBUG'] ? {line: 1, column: 18} : {line: 3, column: 5}); | ||
expect(pos.source).toBe('src1.ts'); | ||
expect(pos.line).toBe(2); | ||
expect(pos.column).toBe(14); | ||
expect(pos.name).toBe('MyClass'); | ||
}); | ||
}); | ||
}); |
File renamed without changes.