-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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): Make AST compressor respect toplevel
#6775
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2725f0d
Move
kdy1 f959f7b
Add tests
kdy1 67b240a
Update test refs
kdy1 bc3b505
Check top level
kdy1 49a75f0
Fix
kdy1 d15c922
Update test refs
kdy1 0a033c6
config.json
kdy1 957bc15
Fix
kdy1 41c502f
Update test refs
kdy1 aa11c37
Remove comments
kdy1 ed25fe6
Reduce input
kdy1 e782490
Update test refs
kdy1 2793655
Move down
kdy1 6e64e03
Merge branch 'main' into minifier-top-unused
swc-bot 099720d
Update test refs
kdy1 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
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
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/4386/1/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,4 @@ | ||
{ | ||
"defaults": true, | ||
"toplevel": false | ||
} |
24 changes: 24 additions & 0 deletions
24
crates/swc_ecma_minifier/tests/fixture/issues/4386/1/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,24 @@ | ||
var application; | ||
(() => { | ||
var __webpack_require__ = {}; | ||
(() => { | ||
__webpack_require__.d = (exports, definition) => { | ||
}; | ||
})(); | ||
(() => { | ||
__webpack_require__.o = (obj, prop) => { }; | ||
})(); | ||
(() => { | ||
__webpack_require__.r = (exports) => { | ||
}; | ||
})(); | ||
var __webpack_exports__ = {}; | ||
__webpack_require__.r(__webpack_exports__); | ||
__webpack_require__.d(__webpack_exports__, { | ||
"bootstrap": () => (bootstrap) | ||
}); | ||
function bootstrap() { | ||
alert(); | ||
} | ||
application = __webpack_exports__; | ||
})(); |
12 changes: 12 additions & 0 deletions
12
crates/swc_ecma_minifier/tests/fixture/issues/4386/1/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,12 @@ | ||
var application; | ||
(()=>{ | ||
var __webpack_require__ = {}; | ||
__webpack_require__.d = (exports, definition)=>{}, __webpack_require__.o = (obj, prop)=>{}, __webpack_require__.r = (exports)=>{}; | ||
var __webpack_exports__ = {}; | ||
function bootstrap() { | ||
alert(); | ||
} | ||
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, { | ||
bootstrap: ()=>bootstrap | ||
}), application = __webpack_exports__; | ||
})(); |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/4386/2/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,4 @@ | ||
{ | ||
"defaults": true, | ||
"toplevel": true | ||
} |
24 changes: 24 additions & 0 deletions
24
crates/swc_ecma_minifier/tests/fixture/issues/4386/2/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,24 @@ | ||
var application; | ||
(() => { | ||
var __webpack_require__ = {}; | ||
(() => { | ||
__webpack_require__.d = (exports, definition) => { | ||
}; | ||
})(); | ||
(() => { | ||
__webpack_require__.o = (obj, prop) => { }; | ||
})(); | ||
(() => { | ||
__webpack_require__.r = (exports) => { | ||
}; | ||
})(); | ||
var __webpack_exports__ = {}; | ||
__webpack_require__.r(__webpack_exports__); | ||
__webpack_require__.d(__webpack_exports__, { | ||
"bootstrap": () => (bootstrap) | ||
}); | ||
function bootstrap() { | ||
alert(); | ||
} | ||
application = __webpack_exports__; | ||
})(); |
11 changes: 11 additions & 0 deletions
11
crates/swc_ecma_minifier/tests/fixture/issues/4386/2/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,11 @@ | ||
(()=>{ | ||
var __webpack_require__ = {}; | ||
__webpack_require__.d = (exports, definition)=>{}, __webpack_require__.o = (obj, prop)=>{}, __webpack_require__.r = (exports)=>{}; | ||
var __webpack_exports__ = {}; | ||
function bootstrap() { | ||
alert(); | ||
} | ||
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, { | ||
bootstrap: ()=>bootstrap | ||
}); | ||
})(); |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/projects/next/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,4 @@ | ||
{ | ||
"defaults": true, | ||
"toplevel": true | ||
} |
4 changes: 2 additions & 2 deletions
4
..._ecma_minifier/tests/terser/compress/collapse_vars/side_effect_free_replacement/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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
var b; | ||
x(b); | ||
var b, a; | ||
a = b, x(a); |
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
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'll reduce this file