-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip unused imports, dead modules, and debug modules from prod builds
- Loading branch information
Showing
15 changed files
with
78 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,40 @@ | ||
var path = require('path'); | ||
|
||
function removeImports() { | ||
let importDeclarationsToRemove; | ||
let filteredImports; | ||
|
||
return { | ||
name: 'remove-filtered-imports', | ||
visitor: { | ||
Program: { | ||
enter: function(_, state) { | ||
filteredImports = state.opts instanceof Array ? state.opts : (state.opts ? [state.opts] : []); | ||
importDeclarationsToRemove = []; | ||
}, | ||
exit: function() { | ||
importDeclarationsToRemove.forEach(function(declaration) { | ||
declaration.remove(); | ||
}); | ||
|
||
importDeclarationsToRemove = undefined; | ||
} | ||
}, | ||
|
||
ImportDeclaration: function(path) { | ||
const name = path.node.source.value; | ||
|
||
if (filteredImports.indexOf(name) !== -1) { | ||
importDeclarationsToRemove.push(path); | ||
} | ||
} | ||
|
||
} | ||
}; | ||
} | ||
|
||
removeImports.baseDir = function() { | ||
return path.join(__dirname, '../../'); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
}; | ||
|
||
module.exports = removeImports; |
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 causes all of ember-data to be considered as a cache key, but really this is more of an in-repo node_modules. I know that this is all kinda strange, we should likely explore how to improve the ergonomics...
fixed -> #4943