Skip to content

Commit afeca7a

Browse files
committed
[INTERNAL] bundle/Builder: Correct bundling of resources with empty source map
If a resource features an empty source map (which is not the same as having no source map), the bundle's source map generation needs to handle this differently from cases where mappings exist. It must not prefix the empty mapping with a string "AAAA," since the danglíng comma will result in a corrupt source map. However, it should still add the mapping for the first line/column "AAAA". Otherwise the source map of the preceding module in the bundle would be applied. Resolves the root cause of UI5/openui5#4035 DINC0139775 (cherry picked from commit 1228db7)
1 parent 52116c8 commit afeca7a

File tree

21 files changed

+67
-5
lines changed

21 files changed

+67
-5
lines changed

lib/lbt/bundle/Builder.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,13 @@ class BundleBuilder {
353353
// If first column of the first line is not already mapped, add a mapping for the same reason as above.
354354
// This is typical for transpiled code, where there is a bunch of generated code at the beginning that
355355
// can't be mapped to the original source
356-
map.mappings = "AAAA," + map.mappings;
356+
if (map.mappings) {
357+
map.mappings = "AAAA," + map.mappings;
358+
} else {
359+
// If there are no existing mappings (e.g. if the file is empty or only comments),
360+
// make sure to still define a single mapping
361+
map.mappings = "AAAA";
362+
}
357363
}
358364

359365
map.sourceRoot = path.posix.relative(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*!
2+
* Some fancy copyright
3+
*/

test/expected/build/application.a/dest-deps/resources/library/d/empty.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expected/build/application.a/dest-deps/resources/library/d/empty.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*!
2+
* Some fancy copyright
3+
*/

test/expected/build/application.a/dest-depself/resources/library/d/empty.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expected/build/application.a/dest-depself/resources/library/d/empty.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expected/build/library.d-minified/preload/resources/library/d/empty.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expected/build/library.d-minified/preload/resources/library/d/empty.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expected/build/library.d-minified/preload/resources/library/d/library-preload.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)