Skip to content

Commit 31a97d2

Browse files
fix(utils): don't create sourcemap file if disabled (#6229)
* fix(utils): don't create sourcemap file if disabled * fix writeLazyChunk
1 parent ecf1b97 commit 31a97d2

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/compiler/output-targets/dist-lazy/generate-lazy-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const writeLazyChunk = async (
254254
destinations.map((dst) => {
255255
const filePath = join(dst, rollupResult.fileName);
256256
let fileCode = code;
257-
if (rollupResult.map) {
257+
if (sourceMap) {
258258
fileCode = code + getSourceMappingUrlForEndOfFile(rollupResult.fileName);
259259
compilerCtx.fs.writeFile(filePath + '.map', JSON.stringify(sourceMap), { outputTargetType });
260260
}

src/utils/sourcemaps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function rollupToStencilSourceMap(rollupSourceMap: null): null;
1111
export function rollupToStencilSourceMap(rollupSourceMap: undefined): null;
1212
export function rollupToStencilSourceMap(rollupSourceMap: RollupSourceMap): d.SourceMap;
1313
export function rollupToStencilSourceMap(rollupSourceMap: RollupSourceMap | undefined | null): d.SourceMap | null {
14-
if (!rollupSourceMap) {
14+
if (!rollupSourceMap || !rollupSourceMap.file) {
1515
return null;
1616
}
1717

src/utils/test/sourcemaps.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ describe('sourcemaps', () => {
1818
expect(rollupToStencilSourceMap(undefined)).toBeNull();
1919
});
2020

21+
it('returns null if the given sourcemap has no file', () => {
22+
expect(rollupToStencilSourceMap({ sourcesContent: [] } as RollupSourceMap)).toBeNull();
23+
});
24+
2125
it('transforms a rollup sourcemap to a stencil sourcemap', () => {
2226
const rollupSourceMap: RollupSourceMap = {
2327
file: 'index.js',

0 commit comments

Comments
 (0)