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

Generate sourcemaps but omit the comment #3120

Merged
merged 5 commits into from Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion src/rollup/index.ts
Expand Up @@ -402,7 +402,9 @@ function writeOutputFile(
url = `${basename(outputFile.fileName)}.map`;
writeSourceMapPromise = writeFile(`${fileName}.map`, outputFile.map.toString());
}
source += `//# ${SOURCEMAPPING_URL}=${url}\n`;
if (outputOptions.sourcemap !== 'hidden') {
source += `//# ${SOURCEMAPPING_URL}=${url}\n`;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/rollup/types.d.ts
Expand Up @@ -475,7 +475,7 @@ export interface OutputOptions {
outro?: string | (() => string | Promise<string>);
paths?: OptionsPaths;
preferConst?: boolean;
sourcemap?: boolean | 'inline';
sourcemap?: boolean | 'inline' | 'hidden';
sourcemapExcludeSources?: boolean;
sourcemapFile?: string;
sourcemapPathTransform?: (sourcePath: string) => string;
Expand Down
13 changes: 13 additions & 0 deletions test/cli/samples/sourcemap-hidden/_config.js
@@ -0,0 +1,13 @@
const fs = require('fs');
const assert = require('assert');

module.exports = {
description: 'adds a newline after the sourceMappingURL comment (#756)',
command: 'rollup -i main.js -f es -m hidden -o output.js',
test() {
const output = fs.readFileSync('output.js', 'utf-8');
assert.equal(output.trim(), 'console.log( 42 );');
fs.unlinkSync('output.js');
fs.unlinkSync('output.js.map');
}
};
1 change: 1 addition & 0 deletions test/cli/samples/sourcemap-hidden/main.js
@@ -0,0 +1 @@
console.log( 42 );
7 changes: 7 additions & 0 deletions test/form/samples/sourcemaps-hidden/_config.js
@@ -0,0 +1,7 @@
module.exports = {
description: 'correct sourcemaps are written (separate file) without comment',
skipIfWindows: true,
options: {
output: { sourcemap: 'hidden' }
}
};
16 changes: 16 additions & 0 deletions test/form/samples/sourcemaps-hidden/_expected/amd.js
@@ -0,0 +1,16 @@
define(function () { 'use strict';

function foo () {
console.log( 'hello from foo.js' );
}

function bar () {
console.log( 'hello from bar.js' );
}

console.log( 'hello from main.js' );

foo();
bar();

});
1 change: 1 addition & 0 deletions test/form/samples/sourcemaps-hidden/_expected/amd.js.map

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

14 changes: 14 additions & 0 deletions test/form/samples/sourcemaps-hidden/_expected/cjs.js
@@ -0,0 +1,14 @@
'use strict';

function foo () {
console.log( 'hello from foo.js' );
}

function bar () {
console.log( 'hello from bar.js' );
}

console.log( 'hello from main.js' );

foo();
bar();
1 change: 1 addition & 0 deletions test/form/samples/sourcemaps-hidden/_expected/cjs.js.map

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

12 changes: 12 additions & 0 deletions test/form/samples/sourcemaps-hidden/_expected/es.js
@@ -0,0 +1,12 @@
function foo () {
console.log( 'hello from foo.js' );
}

function bar () {
console.log( 'hello from bar.js' );
}

console.log( 'hello from main.js' );

foo();
bar();
1 change: 1 addition & 0 deletions test/form/samples/sourcemaps-hidden/_expected/es.js.map

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

17 changes: 17 additions & 0 deletions test/form/samples/sourcemaps-hidden/_expected/iife.js
@@ -0,0 +1,17 @@
(function () {
'use strict';

function foo () {
console.log( 'hello from foo.js' );
}

function bar () {
console.log( 'hello from bar.js' );
}

console.log( 'hello from main.js' );

foo();
bar();

}());
1 change: 1 addition & 0 deletions test/form/samples/sourcemaps-hidden/_expected/iife.js.map

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

21 changes: 21 additions & 0 deletions test/form/samples/sourcemaps-hidden/_expected/system.js
@@ -0,0 +1,21 @@
System.register([], function () {
'use strict';
return {
execute: function () {

function foo () {
console.log( 'hello from foo.js' );
}

function bar () {
console.log( 'hello from bar.js' );
}

console.log( 'hello from main.js' );

foo();
bar();

}
};
});

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

19 changes: 19 additions & 0 deletions test/form/samples/sourcemaps-hidden/_expected/umd.js
@@ -0,0 +1,19 @@
(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
factory();
}(function () { 'use strict';

function foo () {
console.log( 'hello from foo.js' );
}

function bar () {
console.log( 'hello from bar.js' );
}

console.log( 'hello from main.js' );

foo();
bar();

}));
1 change: 1 addition & 0 deletions test/form/samples/sourcemaps-hidden/_expected/umd.js.map

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

3 changes: 3 additions & 0 deletions test/form/samples/sourcemaps-hidden/bar.js
@@ -0,0 +1,3 @@
export default function bar () {
console.log( 'hello from bar.js' );
}
3 changes: 3 additions & 0 deletions test/form/samples/sourcemaps-hidden/foo.js
@@ -0,0 +1,3 @@
export default function foo () {
console.log( 'hello from foo.js' );
}
7 changes: 7 additions & 0 deletions test/form/samples/sourcemaps-hidden/main.js
@@ -0,0 +1,7 @@
import foo from './foo';
import bar from './bar';

console.log( 'hello from main.js' );

foo();
bar();