Skip to content
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

Disable errors for duplicate emitted file names #3175

Merged
merged 2 commits into from Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.