Skip to content

Commit

Permalink
Disable errors for duplicate emitted file names (#3175)
Browse files Browse the repository at this point in the history
* Disable errors for duplicate emitted file names

And add a test to make sure such emits no longer error spuriously.

Issue #3174

* * Make sure test is red with original code
* Add test description
* Describe better in the TODO comment what the ultimate intention is
  • Loading branch information
marijnh authored and lukastaegert committed Oct 20, 2019
1 parent f99c7e4 commit 06fb16a
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 64 deletions.
6 changes: 2 additions & 4 deletions src/utils/FileEmitter.ts
Expand Up @@ -10,7 +10,6 @@ import {
errAssetSourceAlreadySet,
errChunkNotGeneratedForFileName,
errFailedValidation,
errFileNameConflict,
errFileReferenceIdNotFoundForFilename,
errInvalidRollupPhaseForChunkEmission,
errNoAssetSourceSet,
Expand Down Expand Up @@ -49,9 +48,8 @@ function generateAssetFileName(
}

function reserveFileNameInBundle(fileName: string, bundle: OutputBundleWithPlaceholders) {
if (fileName in bundle) {
return error(errFileNameConflict(fileName));
}
// TODO this should warn if the fileName is already in the bundle,
// but until #3174 is fixed, this raises spurious warnings and is disabled
bundle[fileName] = FILE_PLACEHOLDER;
}

Expand Down
15 changes: 15 additions & 0 deletions test/chunking-form/samples/emit-same-file/_config.js
@@ -0,0 +1,15 @@
module.exports = {
description:
'does not throw an error if multiple files with the same name are emitted (until #3174 is fixed)',
options: {
input: 'main.js',
plugins: [
{
generateBundle() {
this.emitFile({ type: 'asset', fileName: 'myfile', source: 'abc' });
this.emitFile({ type: 'asset', fileName: 'myfile', source: 'abc' });
}
}
]
}
};
@@ -0,0 +1,9 @@
define(['exports'], function (exports) { 'use strict';

function hi() { return 2 }

exports.hi = hi;

Object.defineProperty(exports, '__esModule', { value: true });

});
@@ -0,0 +1 @@
abc
@@ -0,0 +1,7 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function hi() { return 2 }

exports.hi = hi;
@@ -0,0 +1 @@
abc
@@ -0,0 +1,3 @@
function hi() { return 2 }

export { hi };
@@ -0,0 +1 @@
abc
12 changes: 12 additions & 0 deletions test/chunking-form/samples/emit-same-file/_expected/system/main.js
@@ -0,0 +1,12 @@
System.register([], function (exports) {
'use strict';
return {
execute: function () {

exports('hi', hi);

function hi() { return 2 }

}
};
});
@@ -0,0 +1 @@
abc
1 change: 1 addition & 0 deletions test/chunking-form/samples/emit-same-file/main.js
@@ -0,0 +1 @@
export function hi() { return 2 }

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 06fb16a

Please sign in to comment.