mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Strip unnecessary imports for packages with no modules.
Note that even an empty package needs to define Package[name] = {}, so
that other packages can tell at runtime whether it's installed.
Fixes #7927.
This commit is contained in:
@@ -1002,6 +1002,21 @@ export var fullLink = Profile("linker.fullLink", function (inputFiles, {
|
||||
return [];
|
||||
}
|
||||
|
||||
// If none of the prelinkedFiles contain any code, then the only
|
||||
// possible purpose of this package is to re-export imported symbols, so
|
||||
// we filter the set of imported symbols according to declaredExports.
|
||||
// When there are no declaredExports, this effectively slims the package
|
||||
// bundle down to just Package[name] = {}.
|
||||
if (prelinkedFiles.every(file => ! file.source)) {
|
||||
const newImports = {};
|
||||
declaredExports.forEach(name => {
|
||||
if (_.has(imports, name)) {
|
||||
newImports[name] = imports[name]
|
||||
}
|
||||
});
|
||||
imports = newImports;
|
||||
}
|
||||
|
||||
// Otherwise we're making a package and we have to actually combine the files
|
||||
// into a single scope.
|
||||
var header = getHeader({
|
||||
|
||||
Reference in New Issue
Block a user