Skip to content

Remove sourceMappingURL from output #12

@jbrantly

Description

@jbrantly

Reported by @schlaup in #8. Opening as a new issue here.

From @schlaup:

Ok, thanks, I just discovered an additional problem:

Typescript places its own "//# sourceMappingURL=SomeFile.ts" in the JavaScript output.

So the bundle.js files ends up with multiple "# sourceMappingURL" declarations. (Of course, only the last "# sourceMappingURL=bundle.js.map" is valid)

It seems that Chrome does not care, but other tools do. (For example "NPM source-map-support")

The solution is to remove the redundant and incorrect "sourceMappingURL" declaration.

I added another line:

if (options.sourceMap) {
    var sourceFilename = loaderUtils.getRemainingRequest(this);
    var current = loaderUtils.getCurrentRequest(this);
    sourceMap = JSON.parse(output.outputFiles[0].text);
    sourceMap.sources = [sourceFilename];
    sourceMap.file = current;
    sourceMap.sourcesContent = [contents];
    contents = output.outputFiles[1].text;

This line here:

    contents = contents.replace("# sourceMappingURL=", " ");
}

This solves the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions