New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(es/minifier): Abort IIFE invoker on eval
#6478
Merged
Merged
Changes from 61 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
31a0dcd
Add tests
kdy1 49c810c
config.json: Correct
kdy1 bfe8bc4
Store correct output
kdy1 98e2454
config.json: Enable inline
kdy1 9160518
Remove needless
kdy1 9bf3be4
Remove needless
kdy1 07b7690
Remove trivial
kdy1 b651771
fmt
kdy1 5d075cc
fmt
kdy1 1a4b7cd
Update test refs (without buggy code)
kdy1 11e403b
Update test refs (correct)
kdy1 8054283
Remove
kdy1 207d90a
Remove
kdy1 a381c64
Remove
kdy1 fc5f698
Remove
kdy1 509c12b
Update test refs (working)
kdy1 236c824
fmt input
kdy1 224a301
Reduce
kdy1 019ae63
Reduce
kdy1 45142df
Reduce
kdy1 de086a9
Reduce
kdy1 9f3556d
Reduce
kdy1 7f216f5
Reduce
kdy1 d742e75
Reduce
kdy1 3cf92c1
Reduce
kdy1 6695c1f
Reduce
kdy1 fd6ec3c
Reduce
kdy1 48e8435
Reduce
kdy1 f2fc815
Reduce
kdy1 e513cb7
Reduce
kdy1 626aa73
Reduce
kdy1 812dcb4
Reduce
kdy1 8024a78
Reduce
kdy1 00f485b
Reduce
kdy1 c60e914
Reduce
kdy1 3fdb71e
Reduce
kdy1 b6c9652
Reduce
kdy1 4a728f7
Reduce
kdy1 068829c
Reduce
kdy1 d1f7667
Reduce
kdy1 ed708c2
Reduce
kdy1 e919122
Reduce
kdy1 b9579a0
fmt
kdy1 d2d4bab
Reduce input
kdy1 a925e49
Reduce input
kdy1 04f2417
Remove
kdy1 edfe4a5
Reduce input
kdy1 d6b2d7a
Reduce input
kdy1 0a6d5a4
Move
kdy1 b6366e6
Fix
kdy1 0ce8377
Update test refs
kdy1 27c6925
Update test refs
kdy1 9e1d73a
Reduce
kdy1 fb4f43e
Reduce
kdy1 bd907d7
Reduce
kdy1 84ce4a5
Reduce
kdy1 9e85f0d
Reduce
kdy1 5f5ab01
Update test refs
kdy1 150e2f7
Add mangle.json
kdy1 bb28f34
Ensure mangler
kdy1 ce6e0c7
Update test refs
kdy1 ac7dcb6
abort on eval
kdy1 7b695ba
Update test refs
kdy1 3e2cdf1
Merge branch 'main' into bug1
swc-bot File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_minifier/tests/fixture/next/43052/config.json
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,6 @@ | ||
{ | ||
"defaults": false, | ||
"toplevel": true, | ||
"passes": 2, | ||
"inline": true | ||
} |
37 changes: 37 additions & 0 deletions
37
crates/swc_ecma_minifier/tests/fixture/next/43052/input.js
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,37 @@ | ||
use((function (__unused_webpack_module, exports, __webpack_require__) { | ||
! function (e, t) { | ||
true ? t(exports, __webpack_require__(7294), __webpack_require__(1321)) : 0 | ||
}(this, (function (exports, React) { | ||
"use strict"; | ||
|
||
var index_production = { | ||
exports: {} | ||
}; | ||
(function (module, exports) { | ||
var t; | ||
t = function (exports) { | ||
function inquire(moduleName) { | ||
try { | ||
var mod = eval("quire".replace(/^/, "re"))(moduleName); | ||
if (mod && (mod.length || Object.keys(mod).length)) return mod | ||
} catch (e) { } | ||
return null | ||
} | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}) | ||
}, t(exports) | ||
})(index_production, index_production.exports); | ||
|
||
exports.chunkBlocks = index_production.exports.chunkBlocks, exports.encodeDirectory = index_production.exports.encodeDirectory, exports.encodeFile = index_production.exports.encodeFile, Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}) | ||
})); | ||
})); | ||
|
||
|
||
(function checkMangler() { | ||
const longName = 1; | ||
use(longName) | ||
}) |
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 @@ | ||
{} |
31 changes: 31 additions & 0 deletions
31
crates/swc_ecma_minifier/tests/fixture/next/43052/output.js
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,31 @@ | ||
use(function(__unused_webpack_module, exports, __webpack_require__) { | ||
var e, t; | ||
e = this, t = function(exports, React) { | ||
"use strict"; | ||
var index_production = { | ||
exports: {} | ||
}; | ||
(function(module, exports) { | ||
var t; | ||
t = function(exports) { | ||
function inquire(moduleName) { | ||
try { | ||
var mod = eval("quire".replace(/^/, "re"))(moduleName); | ||
if (mod && (mod.length || Object.keys(mod).length)) return mod; | ||
} catch (e) {} | ||
return null; | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}); | ||
}, t(exports); | ||
})(index_production, index_production.exports); | ||
exports.chunkBlocks = index_production.exports.chunkBlocks, exports.encodeDirectory = index_production.exports.encodeDirectory, exports.encodeFile = index_production.exports.encodeFile, Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}); | ||
}, t(exports, __webpack_require__(7294), __webpack_require__(1321)), true; | ||
}); | ||
(function e() { | ||
const e = 1; | ||
use(e); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kinda surprised we allow any further modifications in the presence of eval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eval
is used by some libraries, so I thought we should only give up if it's going to be problematic. (e.g. name mangler aborts)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm not sure about this. Do you think it's better to abort completely on
eval
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, yah, I would. Looking at terser,
eval
deopts:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it and checked other passes, too. Thank you!