Skip to content

Commit

Permalink
Merge pull request #5 from rollup/master
Browse files Browse the repository at this point in the history
Sync Fork from Upstream Repo
  • Loading branch information
sthagen committed Mar 13, 2020
2 parents 7675295 + e019ea0 commit c66cab0
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 9 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,14 @@
# rollup changelog

## 2.0.6
*2020-03-13*

### Bug Fixes
* Do not use file names from different outputs when generating sourcemaps using the `dir` option (#3440)

### Pull Requests
* [#3440](https://github.com/rollup/rollup/pull/3440): Use correct file names when writing sourcemaps for multiple outputs (@lukastaegert)

## 2.0.5
*2020-03-12*

Expand Down
2 changes: 1 addition & 1 deletion docs/05-plugin-development.md
Expand Up @@ -413,7 +413,7 @@ resolveImportMeta(property, {moduleId}) {
Note that since this hook has access to the filename of the current chunk, its return value will not be considered when generating the hash of this chunk.

#### `writeBundle`
Type: `( bundle: { [fileName: string]: AssetInfo | ChunkInfo }) => void`<br>
Type: `(options: OutputOptions, bundle: { [fileName: string]: AssetInfo | ChunkInfo }) => void`<br>
Kind: `async, parallel`<br>
Previous Hook: [`generateBundle`](guide/en/#generatebundle)<br>
Next Hook: If it is called, this is the last hook of the output generation phase and may again be followed by [`outputOptions`](guide/en/#outputoptions) if another output is generated.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "2.0.5",
"version": "2.0.6",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/es/rollup.js",
Expand Down
7 changes: 4 additions & 3 deletions src/Chunk.ts
Expand Up @@ -509,6 +509,7 @@ export default class Chunk {
) {
timeStart('render format', 3);

const chunkId = this.id!;
const format = options.format as string;
const finalise = finalisers[format];
if (options.dynamicImportFunction && format !== 'es') {
Expand Down Expand Up @@ -602,12 +603,12 @@ export default class Chunk {

let file: string;
if (options.file) file = resolve(options.sourcemapFile || options.file);
else if (options.dir) file = resolve(options.dir, this.id!);
else file = resolve(this.id!);
else if (options.dir) file = resolve(options.dir, chunkId);
else file = resolve(chunkId);

const decodedMap = magicString.generateDecodedMap({});
map = collapseSourcemaps(
this,
this.graph,
file,
decodedMap,
this.usedModules,
Expand Down
5 changes: 2 additions & 3 deletions src/utils/collapseSourcemaps.ts
@@ -1,5 +1,4 @@
import { DecodedSourceMap, SourceMap } from 'magic-string';
import Chunk from '../Chunk';
import Graph from '../Graph';
import Module from '../Module';
import {
Expand Down Expand Up @@ -200,14 +199,14 @@ function getCollapsedSourcemap(
}

export function collapseSourcemaps(
bundle: Chunk,
graph: Graph,
file: string,
map: DecodedSourceMap,
modules: Module[],
bundleSourcemapChain: DecodedSourceMapOrMissing[],
excludeContent: boolean | undefined
) {
const linkMap = getLinkMap(bundle.graph);
const linkMap = getLinkMap(graph);
const moduleSources = modules
.filter(module => !module.excludeFromSourcemap)
.map(module =>
Expand Down
4 changes: 4 additions & 0 deletions test/cli/samples/config-multiple-source-maps/_config.js
@@ -0,0 +1,4 @@
module.exports = {
description: 'correctly generates sourcemaps for multiple outputs',
command: 'rollup -c'
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/cli/samples/config-multiple-source-maps/main.js
@@ -0,0 +1 @@
assert.equal( ANSWER, 42 );
17 changes: 17 additions & 0 deletions test/cli/samples/config-multiple-source-maps/rollup.config.js
@@ -0,0 +1,17 @@
export default {
input: 'main.js',
output: [
{
format: 'cjs',
dir: '_actual',
entryFileNames: '[name]-[format].js',
sourcemap: true,
},
{
format: 'es',
dir: '_actual',
entryFileNames: '[name]-[format].js',
sourcemap: true
}
]
};

0 comments on commit c66cab0

Please sign in to comment.