From b4f6698bfbaec75889523818389ff14d04f1b553 Mon Sep 17 00:00:00 2001 From: Alex Dilley Date: Wed, 29 Jan 2020 19:50:46 +0000 Subject: [PATCH 1/3] respect sourcemapExcludeSources when constructing map --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index cb9acb7..4d08652 100644 --- a/index.js +++ b/index.js @@ -292,7 +292,7 @@ module.exports = function svelte(options = {}) { return compiled.js; }); }, - generateBundle() { + generateBundle({ sourcemapExcludeSources }) { if (css) { // write out CSS file. TODO would be nice if there was a // a more idiomatic way to do this in Rollup @@ -309,7 +309,7 @@ module.exports = function svelte(options = {}) { if (chunk.map) { const i = sources.length; sources.push(chunk.map.sources[0]); - sourcesContent.push(chunk.map.sourcesContent[0]); + sourcesContent.push(sourcemapExcludeSources ? null : chunk.map.sourcesContent[0]); const decoded = decode(chunk.map.mappings); From 2efd8eb75ed9ca7aa9c252b938aa08315e957bb9 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Mon, 19 Oct 2020 21:23:02 -0700 Subject: [PATCH 2/3] chore: update `sourcemapExcludeSources` expectant --- test/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/index.js b/test/index.js index 90ba29e..0ffd7d5 100644 --- a/test/index.js +++ b/test/index.js @@ -117,7 +117,7 @@ test('can generate a CSS sourcemap – a la Rollup config', async () => { plugin({ css: value => { css = value; - css.write('test/sourcemap-test/dist/bundle.css'); + css.write('bundle.css'); } }) ], @@ -190,7 +190,7 @@ test('respects `sourcemapExcludeSources` Rollup option', async () => { plugin({ css: value => { css = value; - css.write('test/sourcemap-test/dist/bundle.css'); + css.write('bundle.css'); } }) ], @@ -207,8 +207,9 @@ test('respects `sourcemapExcludeSources` Rollup option', async () => { }); assert.ok(css.map); - assert.is(css.map.sources.length, 0); - assert.is(css.map.sourcesContent.length, 0); + assert.is(css.map.sources.length, 2); + assert.is(css.map.sourcesContent, null); + assert.equal(css.map.sources, ['Bar.html', 'Foo.html']); }); test('produces readable sourcemap output when `dev` is truthy', async () => { From 1383b4b7fe64d514785f4d28c861447e21e10969 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Mon, 19 Oct 2020 21:23:56 -0700 Subject: [PATCH 3/3] chore: tabbify --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 7edceb3..e3579d9 100644 --- a/index.js +++ b/index.js @@ -227,9 +227,9 @@ module.exports = function svelte(options = {}) { const extension = path.extname(id); if (!~extensions.indexOf(extension)) return null; - + const filename = path.relative(process.cwd(), id); - + const dependencies = []; let preprocessPromise; if (options.preprocess) { @@ -313,7 +313,7 @@ module.exports = function svelte(options = {}) { return compiled.js; }); }, - + /** * If css: true then outputs a single file with all CSS bundled together */ @@ -321,8 +321,8 @@ module.exports = function svelte(options = {}) { if (css) { // TODO would be nice if there was a more idiomatic way to do this in Rollup let result = ''; - - const sources = []; + + const sources = []; const mappings = []; const sourcesContent = config.sourcemapExcludeSources ? null : [];