Issue #3227125: Produce a sourcemap for aggregated JS
Merge request reports
Activity
added 2 commits
-
8a40e427 - 1 commit from branch
project:9.3.x
- 875cf52d - Merge branch '9.3.x' of https://git.drupalcode.org/project/drupal into 3227125-produce-a-sourcemap
-
8a40e427 - 1 commit from branch
added 1 commit
- 35d5e36a - add a checkbox to enable sourcemap generation
92 93 // grouping, optimizing and dumping, but change the strategy that is used to 93 94 // determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …). 94 95 $map = $this->state->get('system.js_cache_files', []); 96 97 $generate_sourcemaps = \Drupal::config('system.performance')->get('js.sourcemaps'); - Resolved by Théodore Biadala
7914 8106 "platform-overrides": { 7915 8107 "php": "7.3.0" 7916 8108 }, 7917 "plugin-api-version": "2.1.0" 8109 "plugin-api-version": "2.0.0" - Resolved by Théodore Biadala
125 'sections' => [], 126 ]; 120 127 foreach ($js_group['items'] as $js_asset) { 121 128 // Optimize this JS file, but only if it's not yet minified. 122 129 if (isset($js_asset['minified']) && $js_asset['minified']) { 123 $data .= file_get_contents($js_asset['data']); 130 $file_content = file_get_contents($js_asset['data']); 124 131 } 125 132 else { 126 $data .= $this->optimizer->optimize($js_asset); 133 $file_content = $this->optimizer->optimize($js_asset); 134 } 135 if ($generate_sourcemaps) { 136 $js_map = FALSE; 137 // pick up map files automatically, even if they're not declared 138 // in the source (looking at you jquery) changed this line in version 10 of the diff
- Resolved by Théodore Biadala
- Resolved by Théodore Biadala
145 $js_map = json_decode(file_get_contents($js_asset['data'] . '.map')); 146 } 147 elseif (preg_match('~//[#@]\s(?:source(?:Mapping)?URL)=\s*(\S+)\s*~', $file_content, $matches)) { 148 if (str_contains($matches[1], 'data:application/json;')) { 149 $base64 = str_replace('data:application/json;charset=utf-8;base64,', '', $matches[1]); 150 $js_map = json_decode(base64_decode($base64)); 151 } 152 else { 153 $map_file = pathinfo($js_asset['data'], PATHINFO_DIRNAME) . '/' . $matches[1]; 154 if (file_exists($map_file)) { 155 $js_map = json_decode(file_get_contents($map_file)); 156 } 157 } 158 } 159 $sourcesRoot = \Drupal::service('file_url_generator') 160 ->generateAbsoluteString(pathinfo($js_asset['data'], PATHINFO_DIRNAME)); changed this line in version 10 of the diff
159 $sourcesRoot = \Drupal::service('file_url_generator') 160 ->generateAbsoluteString(pathinfo($js_asset['data'], PATHINFO_DIRNAME)); 161 if ($js_map) { 162 // Make sure the source shows up in the right place. 163 $js_map->sourceRoot = $sourcesRoot; 164 $section = [ 165 'offset' => [ 166 'line' => substr_count($data, "\n"), 167 'column' => 0, 168 ], 169 'map' => $js_map, 170 ]; 171 } 172 // if there are not sourcemap create one to avoid problems when 173 // setting breakpoints. This happens when core js has not been 174 // generated with yarn build:js-dev changed this line in version 10 of the diff
- Resolved by Björn Brala
added 41 commits
-
35d5e36a...8fd69fcc - 34 commits from branch
project:9.3.x
- 5e2e8ee8 - Ugly-add aggregated sourcemaps
- ef41a04a - generate a sourcemap for files that do not have one
- 00b13bcc - spelling
- 432c2a87 - docs
- bb3ca403 - comment
- eade08a5 - yolo deprecation replacement
- 4596b9d7 - add a checkbox to enable sourcemap generation
Toggle commit list-
35d5e36a...8fd69fcc - 34 commits from branch
Please register or sign in to reply