mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix crash on duplicate files in a package
Adding the same file twice in the same package is now an error. Previously, this could either lead to the file being included multiple times (eg, JS), or to a build time crash (eg, client-side assets).
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
* Plugins should not process files whose names match the extension exactly (with
|
||||
no extra dot). #3985
|
||||
|
||||
* Adding the same file twice in the same package is now an error. Previously,
|
||||
this could either lead to the file being included multiple times, or to a
|
||||
build time crash.
|
||||
|
||||
|
||||
## `meteor` command-line tool
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ function PackageAPI (options) {
|
||||
|
||||
self.buildingIsopackets = !!options.buildingIsopackets;
|
||||
|
||||
// source files used
|
||||
// source files used. Map arch -> relPath -> {relPath, fileOptions}
|
||||
self.sources = {};
|
||||
|
||||
// symbols exported
|
||||
@@ -90,7 +90,7 @@ function PackageAPI (options) {
|
||||
self.implies = {};
|
||||
|
||||
_.each(compiler.ALL_ARCHES, function (arch) {
|
||||
self.sources[arch] = [];
|
||||
self.sources[arch] = {};
|
||||
self.exports[arch] = [];
|
||||
self.uses[arch] = [];
|
||||
self.implies[arch] = [];
|
||||
@@ -301,14 +301,26 @@ _.extend(PackageAPI.prototype, {
|
||||
return files.convertToPosixPath(p, true);
|
||||
});
|
||||
|
||||
var errors = [];
|
||||
_.each(paths, function (path) {
|
||||
forAllMatchingArchs(arch, function (a) {
|
||||
if (_.has(self.sources[a], path)) {
|
||||
errors.push("Duplicate source file: " + path);
|
||||
return;
|
||||
}
|
||||
var source = {relPath: path};
|
||||
if (fileOptions)
|
||||
source.fileOptions = fileOptions;
|
||||
self.sources[a].push(source);
|
||||
self.sources[a][path] = source;
|
||||
});
|
||||
});
|
||||
|
||||
// Spit out all the errors at the end, where the number of stack frames to
|
||||
// skip is just 1 instead of something like 7 from forAllMatchingArchs and
|
||||
// _.each. Avoid using _.each here to keep stack predictable.
|
||||
for (var i = 0; i < errors.length; ++i) {
|
||||
buildmessage.error(errors[i], { useMyCaller: true });
|
||||
}
|
||||
},
|
||||
|
||||
// Use this release to resolve unclear dependencies for this package. If
|
||||
|
||||
@@ -974,7 +974,7 @@ _.extend(PackageSource.prototype, {
|
||||
// and then continue.
|
||||
api.sources = {};
|
||||
_.each(compiler.ALL_ARCHES, function (arch) {
|
||||
api.sources[arch] = [];
|
||||
api.sources[arch] = {};
|
||||
});
|
||||
|
||||
fileAndDepLoader = null;
|
||||
@@ -1103,7 +1103,7 @@ _.extend(PackageSource.prototype, {
|
||||
arch: arch,
|
||||
uses: api.uses[arch],
|
||||
implies: api.implies[arch],
|
||||
getSourcesFunc: function () { return api.sources[arch]; },
|
||||
getSourcesFunc: function () { return _.values(api.sources[arch]); },
|
||||
declaredExports: api.exports[arch],
|
||||
watchSet: watchSet
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user