Skip to content

Commit

Permalink
Merge pull request #23 from p0ise/master
Browse files Browse the repository at this point in the history
fix case where uglify turns file.key into identifiers when using alias
  • Loading branch information
goto-bus-stop authored Aug 2, 2024
2 parents 4ce1aee + 2c4e86c commit c5801b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ module.exports = function (src) {
return acc;
}, {});
var row = {
id: file.key.value,
id: file.key.type === 'Literal'
? file.key.value
: file.key.name,
source: src.slice(start, end),
deps: deps
};
Expand Down
2 changes: 1 addition & 1 deletion test/files/uglified.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/uglified.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ var fs = require('fs');
var src = fs.readFileSync(__dirname + '/files/uglified.js', 'utf8');

test('uglified', function (t) {
t.plan(3);
t.plan(4);
t.doesNotThrow(function() {
var p = pack({ raw: true });
var rows = unpack(src);
t.equal(rows.length, 3, 'should unpack 3 rows');
t.ok(rows[2].hasOwnProperty('id'), 'third row should have an id property');
}, 'should not throw');

t.deepEquals(deps(src), ['./foo.js', 'gamma']);
Expand Down

0 comments on commit c5801b4

Please sign in to comment.