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

Fix repeated re-emission of files emitted from a transform hook #2936

Merged
merged 1 commit into from Jun 13, 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
17 changes: 14 additions & 3 deletions src/Module.ts
Expand Up @@ -217,7 +217,7 @@ export default class Module {
private graph: Graph;
private magicString!: MagicString;
private namespaceVariable: NamespaceVariable = undefined as any;
private transformDependencies!: string[];
private transformDependencies: string[] | null = null;
private transitiveReexports?: string[];

constructor(graph: Graph, id: string, moduleSideEffects: boolean, isEntry: boolean) {
Expand Down Expand Up @@ -526,13 +526,24 @@ export default class Module {
originalSourcemap,
resolvedIds,
sourcemapChain,
transformAssets,
transformChunks,
transformDependencies
}: TransformModuleJSON) {
}: TransformModuleJSON & {
transformAssets?: Asset[] | undefined;
transformChunks?: EmittedChunk[] | undefined;
}) {
this.code = code;
this.originalCode = originalCode;
this.originalSourcemap = originalSourcemap;
this.sourcemapChain = sourcemapChain as RawSourceMap[];
this.transformDependencies = transformDependencies as string[];
if (transformAssets) {
this.transformAssets = transformAssets;
}
if (transformChunks) {
this.transformChunks = transformChunks;
}
this.transformDependencies = transformDependencies;
this.customTransformCache = customTransformCache;
if (typeof moduleSideEffects === 'boolean') {
this.moduleSideEffects = moduleSideEffects;
Expand Down
3 changes: 2 additions & 1 deletion src/ModuleLoader.ts
Expand Up @@ -7,6 +7,7 @@ import {
ExternalOption,
GetManualChunk,
IsExternal,
ModuleJSON,
ModuleSideEffectsOption,
PureModulesOption,
ResolvedId,
Expand Down Expand Up @@ -348,7 +349,7 @@ export class ModuleLoader {
}
return transform(this.graph, sourceDescription, module);
})
.then((source: TransformModuleJSON) => {
.then((source: TransformModuleJSON | ModuleJSON) => {
module.setSource(source);
this.modulesById.set(id, module);

Expand Down
4 changes: 2 additions & 2 deletions src/rollup/types.d.ts
Expand Up @@ -88,8 +88,8 @@ export interface TransformModuleJSON {
export interface ModuleJSON extends TransformModuleJSON {
dependencies: string[];
id: string;
transformAssets: Asset[] | void;
transformChunks: EmittedChunk[] | void;
transformAssets: Asset[] | undefined;
transformChunks: EmittedChunk[] | undefined;
}

export interface EmittedChunk {
Expand Down