@codingame/monaco-vscode-api 1.79.0 → 1.79.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (644) hide show
  1. package/README.md +17 -6
  2. package/dist/api.js +12 -10
  3. package/dist/composite.d.ts +65 -0
  4. package/dist/configurationRegistry.d.ts +212 -0
  5. package/dist/contextkey.d.ts +2 -2
  6. package/dist/default-extension.js +23 -0
  7. package/dist/default-extensions/json.js +1 -0
  8. package/dist/default-extensions/theme-defaults.js +2 -2
  9. package/dist/editor.d.ts +4 -320
  10. package/dist/editorBrowser.d.ts +597 -11
  11. package/dist/event.d.ts +6 -1
  12. package/dist/{extension-tools-d0cfdea1.js → extension-tools-3c2bf0a4.js} +1032 -706
  13. package/dist/extensions.d.ts +6 -6
  14. package/dist/extensions.d2.ts +6 -17
  15. package/dist/extensions.js +4 -37
  16. package/dist/extensionsRegistry.d.ts +15 -9
  17. package/dist/files.d.ts +73 -9
  18. package/dist/jsonSchema.d.ts +1 -1
  19. package/dist/keybinding.d.ts +3 -3
  20. package/dist/languageFeatures.d.ts +706 -65
  21. package/dist/log.d.ts +1 -1
  22. package/dist/monaco.d.ts +33 -33
  23. package/dist/monaco.js +62 -6
  24. package/dist/node_modules/rollup-plugin-styles/dist/runtime/inject-css.js +2 -0
  25. package/dist/override/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +2 -0
  26. package/dist/override/vs/workbench/contrib/notebook/browser/notebookEditor.js +2 -0
  27. package/dist/override/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +2 -0
  28. package/dist/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +5 -0
  29. package/dist/platform.d.ts +11 -0
  30. package/dist/rollup-extension-directory-plugin.js +1 -2
  31. package/dist/rollup-vsix-plugin.js +1 -2
  32. package/dist/service-override/configuration.d.ts +7 -208
  33. package/dist/service-override/editor.d.ts +13 -0
  34. package/dist/service-override/{modelEditor.js → editor.js} +6 -62
  35. package/dist/service-override/files.d.ts +4 -4
  36. package/dist/service-override/files.js +14 -2
  37. package/dist/service-override/keybindings.js +3 -79
  38. package/dist/service-override/layout.js +6 -2
  39. package/dist/service-override/markers.d.ts +7 -0
  40. package/dist/service-override/markers.js +6 -0
  41. package/dist/service-override/model.d.ts +7 -0
  42. package/dist/service-override/model.js +10 -0
  43. package/dist/service-override/output.d.ts +7 -0
  44. package/dist/service-override/output.js +22 -0
  45. package/dist/service-override/preferences.js +7 -1
  46. package/dist/service-override/quickaccess.d.ts +7 -0
  47. package/dist/service-override/quickaccess.js +71 -0
  48. package/dist/service-override/search.d.ts +7 -0
  49. package/dist/service-override/search.js +19 -0
  50. package/dist/service-override/snippets.js +5 -1
  51. package/dist/service-override/terminal.d.ts +607 -0
  52. package/dist/service-override/terminal.js +98 -0
  53. package/dist/service-override/textmate.js +7 -2
  54. package/dist/service-override/theme.d.ts +1 -1
  55. package/dist/service-override/tools/editor.js +73 -0
  56. package/dist/service-override/views.d.ts +569 -481
  57. package/dist/service-override/views.js +149 -15
  58. package/dist/services.d.ts +2819 -203
  59. package/dist/services.js +3 -0
  60. package/dist/severity.d.ts +16 -0
  61. package/dist/uri.d.ts +22 -11
  62. package/dist/views.d.ts +270 -0
  63. package/dist/vscode/vs/base/browser/ui/centered/centeredViewLayout.js +178 -0
  64. package/dist/vscode/vs/base/browser/ui/grid/grid.js +452 -0
  65. package/dist/vscode/vs/base/browser/ui/grid/gridview.css.js +4 -0
  66. package/dist/vscode/vs/base/browser/ui/grid/gridview.js +999 -0
  67. package/dist/vscode/vs/base/browser/ui/iconLabel/simpleIconLabel.js +14 -0
  68. package/dist/vscode/vs/base/browser/ui/menu/menubar.css.js +4 -0
  69. package/dist/vscode/vs/base/browser/ui/menu/menubar.js +1 -1
  70. package/dist/vscode/vs/base/browser/ui/splitview/paneview.css.js +4 -0
  71. package/dist/vscode/vs/base/browser/ui/splitview/paneview.js +1 -1
  72. package/dist/vscode/vs/base/common/processes.js +24 -0
  73. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/decorations.js +20 -0
  74. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/delegatingEditorImpl.js +106 -0
  75. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/diffEditorSash.js +59 -0
  76. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2.contribution.js +41 -0
  77. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2.js +369 -0
  78. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/diffModel.js +247 -0
  79. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/lineAlignment.js +179 -0
  80. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/overviewRulerPart.js +121 -0
  81. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/style.css.js +4 -0
  82. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/unchangedRanges.js +184 -0
  83. package/dist/vscode/vs/editor/browser/widget/diffEditorWidget2/utils.js +88 -0
  84. package/dist/vscode/vs/platform/extensionManagement/common/extensionManagement.js +39 -1
  85. package/dist/vscode/vs/platform/extensionManagement/common/extensionManagementUtil.js +5 -1
  86. package/dist/vscode/vs/platform/extensionManagement/common/extensionStorage.js +1 -1
  87. package/dist/vscode/vs/platform/extensionResourceLoader/common/extensionResourceLoader.js +13 -5
  88. package/dist/vscode/vs/platform/files/common/fileService.js +43 -5
  89. package/dist/vscode/vs/platform/files/common/files.js +3 -1
  90. package/dist/vscode/vs/platform/languagePacks/common/languagePacks.js +4 -1
  91. package/dist/vscode/vs/platform/log/common/bufferLog.js +34 -0
  92. package/dist/vscode/vs/platform/log/common/fileLog.js +105 -0
  93. package/dist/vscode/vs/platform/quickinput/browser/quickPickPin.js +94 -0
  94. package/dist/vscode/vs/platform/remote/common/remoteAuthorityResolver.js +20 -1
  95. package/dist/vscode/vs/platform/request/browser/requestService.js +1 -1
  96. package/dist/vscode/vs/platform/request/common/request.js +3 -3
  97. package/dist/vscode/vs/platform/storage/common/storage.js +3 -0
  98. package/dist/vscode/vs/platform/terminal/common/capabilities/bufferMarkCapability.js +39 -0
  99. package/dist/vscode/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +565 -0
  100. package/dist/vscode/vs/platform/terminal/common/capabilities/cwdDetectionCapability.js +27 -0
  101. package/dist/vscode/vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability.js +22 -0
  102. package/dist/vscode/vs/platform/terminal/common/capabilities/partialCommandDetectionCapability.js +46 -0
  103. package/dist/vscode/vs/platform/terminal/common/capabilities/terminalCapabilityStore.js +80 -0
  104. package/dist/vscode/vs/platform/terminal/common/environmentVariable.js +7 -0
  105. package/dist/vscode/vs/platform/terminal/common/environmentVariableCollection.js +196 -0
  106. package/dist/vscode/vs/platform/terminal/common/environmentVariableShared.js +23 -0
  107. package/dist/vscode/vs/platform/terminal/common/terminal.js +23 -0
  108. package/dist/vscode/vs/platform/terminal/common/terminalDataBuffering.js +45 -0
  109. package/dist/vscode/vs/platform/terminal/common/terminalEnvironment.js +37 -0
  110. package/dist/vscode/vs/platform/terminal/common/terminalPlatformConfiguration.js +622 -0
  111. package/dist/vscode/vs/platform/terminal/common/terminalProfiles.js +107 -0
  112. package/dist/vscode/vs/platform/terminal/common/terminalRecorder.js +66 -0
  113. package/dist/vscode/vs/platform/terminal/common/terminalStrings.js +16 -0
  114. package/dist/vscode/vs/platform/terminal/common/xterm/shellIntegrationAddon.js +321 -0
  115. package/dist/vscode/vs/platform/update/common/update.js +11 -1
  116. package/dist/vscode/vs/platform/userDataSync/common/settingsMerge.js +39 -1
  117. package/dist/vscode/vs/platform/userDataSync/common/userDataSync.js +19 -0
  118. package/dist/vscode/vs/platform/workspace/common/canonicalUri.js +3 -0
  119. package/dist/vscode/vs/platform/workspace/common/virtualWorkspace.js +4 -1
  120. package/dist/vscode/vs/platform/workspaces/common/workspaces.js +2 -2
  121. package/dist/vscode/vs/workbench/api/browser/mainThreadCommands.js +2 -3
  122. package/dist/vscode/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +1 -1
  123. package/dist/vscode/vs/workbench/api/browser/mainThreadEditorTabs.js +473 -0
  124. package/dist/vscode/vs/workbench/api/browser/mainThreadLanguageFeatures.js +45 -38
  125. package/dist/vscode/vs/workbench/api/browser/mainThreadSearch.js +146 -0
  126. package/dist/vscode/vs/workbench/api/browser/mainThreadStatusBar.js +49 -0
  127. package/dist/vscode/vs/workbench/api/browser/mainThreadTerminalService.js +395 -0
  128. package/dist/vscode/vs/workbench/api/browser/mainThreadTheming.js +22 -0
  129. package/dist/vscode/vs/workbench/api/browser/mainThreadTreeViews.js +10 -5
  130. package/dist/vscode/vs/workbench/api/browser/mainThreadWindow.js +11 -4
  131. package/dist/vscode/vs/workbench/api/browser/mainThreadWorkspace.js +34 -11
  132. package/dist/vscode/vs/workbench/api/browser/statusBarExtensionPoint.js +81 -0
  133. package/dist/vscode/vs/workbench/api/common/extHost.protocol.js +7 -2
  134. package/dist/vscode/vs/workbench/api/common/extHostDebugService.js +4 -13
  135. package/dist/vscode/vs/workbench/api/common/extHostExtensionService.js +30 -15
  136. package/dist/vscode/vs/workbench/api/common/extHostFileSystemConsumer.js +20 -6
  137. package/dist/vscode/vs/workbench/api/common/extHostLanguageFeatures.js +41 -8
  138. package/dist/vscode/vs/workbench/api/common/extHostManagedSockets.js +3 -0
  139. package/dist/vscode/vs/workbench/api/common/extHostSearch.js +109 -0
  140. package/dist/vscode/vs/workbench/api/common/extHostStatusBar.js +261 -0
  141. package/dist/vscode/vs/workbench/api/common/extHostTerminalService.js +879 -1
  142. package/dist/vscode/vs/workbench/api/common/extHostTheming.js +38 -0
  143. package/dist/vscode/vs/workbench/api/common/extHostTreeViews.js +8 -5
  144. package/dist/vscode/vs/workbench/api/common/extHostTypeConverters.js +15 -17
  145. package/dist/vscode/vs/workbench/api/common/extHostTypes.js +122 -4
  146. package/dist/vscode/vs/workbench/api/common/extHostWindow.js +28 -6
  147. package/dist/vscode/vs/workbench/api/common/extHostWorkspace.js +28 -0
  148. package/dist/vscode/vs/workbench/api/common/shared/dataTransferCache.js +11 -14
  149. package/dist/vscode/vs/workbench/api/node/extHostTerminalService.js +22 -0
  150. package/dist/vscode/vs/workbench/browser/actions/layoutActions.js +22 -18
  151. package/dist/vscode/vs/workbench/browser/actions/quickAccessActions.js +204 -0
  152. package/dist/vscode/vs/workbench/browser/actions/windowActions.js +2 -2
  153. package/dist/vscode/vs/workbench/browser/dnd.js +82 -3
  154. package/dist/vscode/vs/workbench/browser/editor.js +94 -0
  155. package/dist/vscode/vs/workbench/browser/labels.js +23 -2
  156. package/dist/vscode/vs/workbench/browser/media/part.css.js +4 -0
  157. package/dist/vscode/vs/workbench/browser/part.js +1 -1
  158. package/dist/vscode/vs/workbench/browser/parts/activitybar/activitybarActions.js +1 -1
  159. package/dist/vscode/vs/workbench/browser/parts/activitybar/activitybarPart.js +3 -3
  160. package/dist/vscode/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +4 -0
  161. package/dist/vscode/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +4 -0
  162. package/dist/vscode/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions.js +14 -26
  163. package/dist/vscode/vs/workbench/browser/parts/compositePart.js +2 -2
  164. package/dist/vscode/vs/workbench/browser/parts/dialogs/dialogHandler.js +2 -2
  165. package/dist/vscode/vs/workbench/browser/parts/editor/binaryDiffEditor.js +43 -0
  166. package/dist/vscode/vs/workbench/browser/parts/editor/binaryEditor.js +55 -0
  167. package/dist/vscode/vs/workbench/browser/parts/editor/breadcrumbs.js +330 -0
  168. package/dist/vscode/vs/workbench/browser/parts/editor/breadcrumbsControl.js +690 -0
  169. package/dist/vscode/vs/workbench/browser/parts/editor/breadcrumbsModel.js +142 -0
  170. package/dist/vscode/vs/workbench/browser/parts/editor/breadcrumbsPicker.js +414 -0
  171. package/dist/vscode/vs/workbench/browser/parts/editor/editor.contribution.js +801 -6
  172. package/dist/vscode/vs/workbench/browser/parts/editor/editor.js +57 -1
  173. package/dist/vscode/vs/workbench/browser/parts/editor/editorActions.js +1484 -107
  174. package/dist/vscode/vs/workbench/browser/parts/editor/editorCommands.js +1125 -9
  175. package/dist/vscode/vs/workbench/browser/parts/editor/editorDropTarget.js +499 -0
  176. package/dist/vscode/vs/workbench/browser/parts/editor/editorGroupView.js +1225 -0
  177. package/dist/vscode/vs/workbench/browser/parts/editor/editorGroupWatermark.js +133 -0
  178. package/dist/vscode/vs/workbench/browser/parts/editor/editorPane.js +242 -0
  179. package/dist/vscode/vs/workbench/browser/parts/editor/editorPanes.js +297 -0
  180. package/dist/vscode/vs/workbench/browser/parts/editor/editorPart.js +841 -0
  181. package/dist/vscode/vs/workbench/browser/parts/editor/editorPlaceholder.js +235 -0
  182. package/dist/vscode/vs/workbench/browser/parts/editor/editorQuickAccess.js +1 -1
  183. package/dist/vscode/vs/workbench/browser/parts/editor/editorStatus.js +1152 -0
  184. package/dist/vscode/vs/workbench/browser/parts/editor/editorWithViewState.js +139 -0
  185. package/dist/vscode/vs/workbench/browser/parts/editor/editorsObserver.js +339 -0
  186. package/dist/vscode/vs/workbench/browser/parts/editor/media/breadcrumbscontrol.css.js +4 -0
  187. package/dist/vscode/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +4 -0
  188. package/dist/vscode/vs/workbench/browser/parts/editor/media/editorgroupview.css.js +4 -0
  189. package/dist/vscode/vs/workbench/browser/parts/editor/media/editorplaceholder.css.js +4 -0
  190. package/dist/vscode/vs/workbench/browser/parts/editor/media/editorquickaccess.css.js +4 -0
  191. package/dist/vscode/vs/workbench/browser/parts/editor/media/editorstatus.css.js +4 -0
  192. package/dist/vscode/vs/workbench/browser/parts/editor/media/notabstitlecontrol.css.js +4 -0
  193. package/dist/vscode/vs/workbench/browser/parts/editor/media/sidebysideeditor.css.js +4 -0
  194. package/dist/vscode/vs/workbench/browser/parts/editor/media/tabstitlecontrol.css.js +4 -0
  195. package/dist/vscode/vs/workbench/browser/parts/editor/media/titlecontrol.css.js +4 -0
  196. package/dist/vscode/vs/workbench/browser/parts/editor/noTabsTitleControl.js +245 -0
  197. package/dist/vscode/vs/workbench/browser/parts/editor/sideBySideEditor.js +387 -0
  198. package/dist/vscode/vs/workbench/browser/parts/editor/tabFocus.js +77 -0
  199. package/dist/vscode/vs/workbench/browser/parts/editor/tabsTitleControl.js +1553 -0
  200. package/dist/vscode/vs/workbench/browser/parts/editor/textCodeEditor.js +79 -0
  201. package/dist/vscode/vs/workbench/browser/parts/editor/textDiffEditor.js +310 -0
  202. package/dist/vscode/vs/workbench/browser/parts/editor/textEditor.js +220 -0
  203. package/dist/vscode/vs/workbench/browser/parts/editor/textResourceEditor.js +149 -0
  204. package/dist/vscode/vs/workbench/browser/parts/editor/titleControl.js +284 -0
  205. package/dist/vscode/vs/workbench/browser/parts/media/compositepart.css.js +4 -0
  206. package/dist/vscode/vs/workbench/browser/parts/notifications/media/notificationsActions.css.js +4 -0
  207. package/dist/vscode/vs/workbench/browser/parts/notifications/media/notificationsCenter.css.js +4 -0
  208. package/dist/vscode/vs/workbench/browser/parts/notifications/media/notificationsList.css.js +4 -0
  209. package/dist/vscode/vs/workbench/browser/parts/notifications/media/notificationsToasts.css.js +4 -0
  210. package/dist/vscode/vs/workbench/browser/parts/notifications/notificationsActions.js +8 -8
  211. package/dist/vscode/vs/workbench/browser/parts/notifications/notificationsCenter.js +2 -2
  212. package/dist/vscode/vs/workbench/browser/parts/notifications/notificationsList.js +1 -1
  213. package/dist/vscode/vs/workbench/browser/parts/notifications/notificationsToasts.js +1 -1
  214. package/dist/vscode/vs/workbench/browser/parts/panel/media/basepanelpart.css.js +4 -0
  215. package/dist/vscode/vs/workbench/browser/parts/panel/media/panelpart.css.js +4 -0
  216. package/dist/vscode/vs/workbench/browser/parts/panel/panelActions.js +19 -5
  217. package/dist/vscode/vs/workbench/browser/parts/panel/panelPart.js +2 -2
  218. package/dist/vscode/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +4 -0
  219. package/dist/vscode/vs/workbench/browser/parts/sidebar/sidebarPart.js +1 -1
  220. package/dist/vscode/vs/workbench/browser/parts/statusbar/media/statusbarpart.css.js +4 -0
  221. package/dist/vscode/vs/workbench/browser/parts/statusbar/statusbarActions.js +109 -0
  222. package/dist/vscode/vs/workbench/browser/parts/statusbar/statusbarItem.js +224 -0
  223. package/dist/vscode/vs/workbench/browser/parts/statusbar/statusbarModel.js +251 -0
  224. package/dist/vscode/vs/workbench/browser/parts/statusbar/statusbarPart.js +439 -0
  225. package/dist/vscode/vs/workbench/browser/parts/titlebar/media/menubarControl.css.js +4 -0
  226. package/dist/vscode/vs/workbench/browser/parts/titlebar/menubarControl.js +76 -3
  227. package/dist/vscode/vs/workbench/browser/parts/views/checkbox.js +10 -0
  228. package/dist/vscode/vs/workbench/browser/parts/views/media/paneviewlet.css.js +4 -0
  229. package/dist/vscode/vs/workbench/browser/parts/views/media/views.css.js +4 -0
  230. package/dist/vscode/vs/workbench/browser/parts/views/treeView.js +79 -15
  231. package/dist/vscode/vs/workbench/browser/parts/views/viewPane.js +5 -5
  232. package/dist/vscode/vs/workbench/browser/parts/views/viewPaneContainer.js +2 -2
  233. package/dist/vscode/vs/workbench/browser/parts/views/viewsService.js +4 -4
  234. package/dist/vscode/vs/workbench/browser/quickaccess.js +6 -2
  235. package/dist/vscode/vs/workbench/browser/workbench.contribution.js +1167 -0
  236. package/dist/vscode/vs/workbench/common/configuration.js +8 -1
  237. package/dist/vscode/vs/workbench/common/contextkeys.js +42 -1
  238. package/dist/vscode/vs/workbench/common/editor/editorGroupModel.js +678 -0
  239. package/dist/vscode/vs/workbench/common/editor/resourceEditorInput.js +6 -3
  240. package/dist/vscode/vs/workbench/common/editor/textResourceEditorInput.js +9 -6
  241. package/dist/vscode/vs/workbench/common/editor.js +57 -5
  242. package/dist/vscode/vs/workbench/common/resources.js +111 -34
  243. package/dist/vscode/vs/workbench/common/theme.js +35 -35
  244. package/dist/vscode/vs/workbench/common/views.js +1 -1
  245. package/dist/vscode/vs/workbench/contrib/bulkEdit/browser/bulkEditService.js +1 -1
  246. package/dist/vscode/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.js +1 -1
  247. package/dist/vscode/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +4 -4
  248. package/dist/vscode/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +1 -1
  249. package/dist/vscode/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +4 -0
  250. package/dist/vscode/vs/workbench/contrib/chat/browser/chat.js +3 -0
  251. package/dist/vscode/vs/workbench/contrib/chat/common/chatService.js +3 -0
  252. package/dist/vscode/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.js +6 -4
  253. package/dist/vscode/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoLineQuickAccess.js +77 -0
  254. package/dist/vscode/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.js +217 -0
  255. package/dist/vscode/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.css.js +4 -0
  256. package/dist/vscode/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.js +250 -0
  257. package/dist/vscode/vs/workbench/contrib/codeEditor/browser/workbenchReferenceSearch.js +24 -0
  258. package/dist/vscode/vs/workbench/contrib/customEditor/browser/customEditorInput.js +290 -0
  259. package/dist/vscode/vs/workbench/contrib/customEditor/common/customEditor.js +3 -0
  260. package/dist/vscode/vs/workbench/contrib/debug/browser/breakpointWidget.js +1 -1
  261. package/dist/vscode/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +1 -1
  262. package/dist/vscode/vs/workbench/contrib/debug/browser/debug.contribution.js +30 -4
  263. package/dist/vscode/vs/workbench/contrib/debug/browser/debugActionViewItems.js +1 -0
  264. package/dist/vscode/vs/workbench/contrib/debug/browser/debugCommands.js +15 -2
  265. package/dist/vscode/vs/workbench/contrib/debug/browser/debugConfigurationManager.js +20 -20
  266. package/dist/vscode/vs/workbench/contrib/debug/browser/debugEditorActions.js +5 -3
  267. package/dist/vscode/vs/workbench/contrib/debug/browser/debugEditorContribution.js +5 -2
  268. package/dist/vscode/vs/workbench/contrib/debug/browser/debugHover.js +33 -6
  269. package/dist/vscode/vs/workbench/contrib/debug/browser/debugIcons.js +77 -127
  270. package/dist/vscode/vs/workbench/contrib/debug/browser/debugSession.js +1 -1
  271. package/dist/vscode/vs/workbench/contrib/debug/browser/debugTaskRunner.js +1 -1
  272. package/dist/vscode/vs/workbench/contrib/debug/browser/debugToolBar.js +1 -1
  273. package/dist/vscode/vs/workbench/contrib/debug/browser/debugViewlet.js +1 -1
  274. package/dist/vscode/vs/workbench/contrib/debug/browser/disassemblyView.js +620 -0
  275. package/dist/vscode/vs/workbench/contrib/debug/browser/exceptionWidget.js +1 -1
  276. package/dist/vscode/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +4 -0
  277. package/dist/vscode/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +4 -0
  278. package/dist/vscode/vs/workbench/contrib/debug/browser/media/debug.contribution.css.js +4 -0
  279. package/dist/vscode/vs/workbench/contrib/debug/browser/media/debugHover.css.js +4 -0
  280. package/dist/vscode/vs/workbench/contrib/debug/browser/media/debugToolBar.css.js +4 -0
  281. package/dist/vscode/vs/workbench/contrib/debug/browser/media/debugViewlet.css.js +4 -0
  282. package/dist/vscode/vs/workbench/contrib/debug/browser/media/exceptionWidget.css.js +4 -0
  283. package/dist/vscode/vs/workbench/contrib/debug/browser/media/repl.css.js +4 -0
  284. package/dist/vscode/vs/workbench/contrib/debug/browser/repl.js +4 -4
  285. package/dist/vscode/vs/workbench/contrib/debug/common/debug.js +2 -1
  286. package/dist/vscode/vs/workbench/contrib/debug/common/debugModel.js +29 -17
  287. package/dist/vscode/vs/workbench/contrib/debug/common/debugStorage.js +11 -10
  288. package/dist/vscode/vs/workbench/contrib/debug/common/debugger.js +10 -6
  289. package/dist/vscode/vs/workbench/contrib/extensions/browser/extensionsActions.js +2514 -0
  290. package/dist/vscode/vs/workbench/contrib/extensions/browser/extensionsIcons.js +82 -0
  291. package/dist/vscode/vs/workbench/contrib/extensions/browser/media/extensionActions.css.js +4 -0
  292. package/dist/vscode/vs/workbench/contrib/extensions/common/extensions.js +6 -1
  293. package/dist/vscode/vs/workbench/contrib/extensions/common/extensionsFileTemplate.js +16 -0
  294. package/dist/vscode/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +71 -0
  295. package/dist/vscode/vs/workbench/contrib/files/browser/editors/fileEditorInput.js +2 -3
  296. package/dist/vscode/vs/workbench/contrib/files/browser/editors/textFileEditor.js +225 -0
  297. package/dist/vscode/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +2 -0
  298. package/dist/vscode/vs/workbench/contrib/files/browser/explorerService.js +10 -6
  299. package/dist/vscode/vs/workbench/contrib/files/browser/explorerViewlet.js +8 -22
  300. package/dist/vscode/vs/workbench/contrib/files/browser/fileActions.contribution.js +306 -5
  301. package/dist/vscode/vs/workbench/contrib/files/browser/fileActions.js +68 -3
  302. package/dist/vscode/vs/workbench/contrib/files/browser/fileCommands.js +27 -9
  303. package/dist/vscode/vs/workbench/contrib/files/browser/fileConstants.js +10 -1
  304. package/dist/vscode/vs/workbench/contrib/files/browser/files.contribution.js +51 -6
  305. package/dist/vscode/vs/workbench/contrib/files/browser/files.js +1 -0
  306. package/dist/vscode/vs/workbench/contrib/files/browser/media/explorerviewlet.css.js +4 -0
  307. package/dist/vscode/vs/workbench/contrib/files/browser/views/explorerView.js +3 -3
  308. package/dist/vscode/vs/workbench/contrib/files/browser/views/explorerViewer.js +6 -2
  309. package/dist/vscode/vs/workbench/contrib/files/browser/views/media/openeditors.css.js +4 -0
  310. package/dist/vscode/vs/workbench/contrib/files/browser/views/openEditorsView.js +608 -0
  311. package/dist/vscode/vs/workbench/contrib/files/common/explorerModel.js +16 -9
  312. package/dist/vscode/vs/workbench/contrib/files/common/files.js +2 -6
  313. package/dist/vscode/vs/workbench/contrib/interactive/browser/interactiveDocumentService.js +3 -0
  314. package/dist/vscode/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +200 -0
  315. package/dist/vscode/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +3 -0
  316. package/dist/vscode/vs/workbench/contrib/markers/browser/markers.contribution.js +586 -0
  317. package/dist/vscode/vs/workbench/contrib/markers/browser/markersFilterOptions.js +75 -0
  318. package/dist/vscode/vs/workbench/contrib/markers/browser/markersModel.js +201 -0
  319. package/dist/vscode/vs/workbench/contrib/markers/browser/markersTable.js +451 -0
  320. package/dist/vscode/vs/workbench/contrib/markers/browser/markersTreeViewer.js +670 -0
  321. package/dist/vscode/vs/workbench/contrib/markers/browser/markersView.js +857 -0
  322. package/dist/vscode/vs/workbench/contrib/markers/browser/markersViewActions.css.js +4 -0
  323. package/dist/vscode/vs/workbench/contrib/markers/browser/markersViewActions.js +132 -0
  324. package/dist/vscode/vs/workbench/contrib/markers/browser/media/markers.css.js +4 -0
  325. package/dist/vscode/vs/workbench/contrib/markers/browser/messages.js +171 -0
  326. package/dist/vscode/vs/workbench/contrib/markers/common/markers.js +15 -1
  327. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +135 -0
  328. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +421 -0
  329. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +5 -0
  330. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +55 -0
  331. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/editing.js +54 -0
  332. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +108 -0
  333. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +334 -0
  334. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +606 -0
  335. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +307 -0
  336. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +36 -0
  337. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +165 -0
  338. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/telemetry.js +78 -0
  339. package/dist/vscode/vs/workbench/contrib/mergeEditor/browser/utils.js +68 -0
  340. package/dist/vscode/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +2 -0
  341. package/dist/vscode/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.js +70 -0
  342. package/dist/vscode/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css.js +4 -0
  343. package/dist/vscode/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +158 -0
  344. package/dist/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser.js +8 -3
  345. package/dist/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.js +3 -0
  346. package/dist/vscode/vs/workbench/contrib/notebook/common/notebookCommon.js +16 -1
  347. package/dist/vscode/vs/workbench/contrib/notebook/common/notebookService.js +1 -8
  348. package/dist/vscode/vs/workbench/contrib/output/browser/logViewer.js +64 -0
  349. package/dist/vscode/vs/workbench/contrib/output/browser/output.contribution.js +378 -0
  350. package/dist/vscode/vs/workbench/contrib/output/browser/outputServices.js +39 -3
  351. package/dist/vscode/vs/workbench/contrib/output/browser/outputView.js +220 -0
  352. package/dist/vscode/vs/workbench/contrib/output/common/outputChannelModel.js +12 -3
  353. package/dist/vscode/vs/workbench/contrib/output/common/outputLinkComputer.js +129 -0
  354. package/dist/vscode/vs/workbench/contrib/preferences/browser/keybindingWidgets.js +270 -0
  355. package/dist/vscode/vs/workbench/contrib/preferences/browser/keybindingsEditor.js +1080 -0
  356. package/dist/vscode/vs/workbench/contrib/preferences/browser/media/keybindings.css.js +4 -0
  357. package/dist/vscode/vs/workbench/contrib/preferences/browser/media/keybindingsEditor.css.js +4 -0
  358. package/dist/vscode/vs/workbench/contrib/preferences/browser/media/preferences.css.js +4 -0
  359. package/dist/vscode/vs/workbench/contrib/preferences/browser/media/settingsEditor2.css.js +4 -0
  360. package/dist/vscode/vs/workbench/contrib/preferences/browser/media/settingsWidgets.css.js +4 -0
  361. package/dist/vscode/vs/workbench/contrib/preferences/browser/preferences.contribution.js +1154 -0
  362. package/dist/vscode/vs/workbench/contrib/preferences/browser/preferencesActions.js +94 -0
  363. package/dist/vscode/vs/workbench/contrib/preferences/browser/preferencesEditor.js +47 -0
  364. package/dist/vscode/vs/workbench/contrib/preferences/browser/preferencesIcons.js +37 -0
  365. package/dist/vscode/vs/workbench/contrib/preferences/browser/preferencesRenderers.js +731 -0
  366. package/dist/vscode/vs/workbench/contrib/preferences/browser/preferencesSearch.js +271 -0
  367. package/dist/vscode/vs/workbench/contrib/preferences/browser/preferencesWidgets.js +479 -0
  368. package/dist/vscode/vs/workbench/contrib/preferences/browser/settingsEditor2.js +1465 -0
  369. package/dist/vscode/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.js +506 -0
  370. package/dist/vscode/vs/workbench/contrib/preferences/browser/settingsLayout.js +296 -0
  371. package/dist/vscode/vs/workbench/contrib/preferences/browser/settingsSearchMenu.js +79 -0
  372. package/dist/vscode/vs/workbench/contrib/preferences/browser/settingsTree.js +1984 -0
  373. package/dist/vscode/vs/workbench/contrib/preferences/browser/settingsTreeModels.js +759 -0
  374. package/dist/vscode/vs/workbench/contrib/preferences/browser/settingsWidgets.js +1008 -0
  375. package/dist/vscode/vs/workbench/contrib/preferences/browser/tocTree.js +196 -0
  376. package/dist/vscode/vs/workbench/contrib/preferences/common/preferences.js +68 -0
  377. package/dist/vscode/vs/workbench/contrib/preferences/common/preferencesContribution.js +157 -0
  378. package/dist/vscode/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +67 -0
  379. package/dist/vscode/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.js +49 -17
  380. package/dist/vscode/vs/workbench/contrib/quickaccess/browser/quickAccess.contribution.js +129 -0
  381. package/dist/vscode/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.js +225 -0
  382. package/dist/vscode/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +4 -0
  383. package/dist/vscode/vs/workbench/contrib/remote/browser/remoteExplorer.js +23 -2
  384. package/dist/vscode/vs/workbench/contrib/remote/browser/remoteIcons.js +21 -17
  385. package/dist/vscode/vs/workbench/contrib/remote/browser/tunnelView.js +6 -6
  386. package/dist/vscode/vs/workbench/contrib/search/browser/anythingQuickAccess.js +757 -0
  387. package/dist/vscode/vs/workbench/contrib/search/browser/media/anythingQuickAccess.css.js +4 -0
  388. package/dist/vscode/vs/workbench/contrib/search/browser/media/searchview.css.js +4 -0
  389. package/dist/vscode/vs/workbench/contrib/search/browser/patternInputWidget.js +217 -0
  390. package/dist/vscode/vs/workbench/contrib/search/browser/replace.js +3 -0
  391. package/dist/vscode/vs/workbench/contrib/search/browser/replaceContributions.js +7 -0
  392. package/dist/vscode/vs/workbench/contrib/search/browser/replaceService.js +222 -0
  393. package/dist/vscode/vs/workbench/contrib/search/browser/search.contribution.js +467 -0
  394. package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsBase.js +17 -0
  395. package/dist/vscode/vs/workbench/contrib/search/browser/searchFindInput.js +41 -0
  396. package/dist/vscode/vs/workbench/contrib/search/browser/searchIcons.js +35 -0
  397. package/dist/vscode/vs/workbench/contrib/search/browser/searchMessage.js +58 -0
  398. package/dist/vscode/vs/workbench/contrib/search/browser/searchModel.js +1842 -0
  399. package/dist/vscode/vs/workbench/contrib/search/browser/searchNotebookHelpers.js +49 -0
  400. package/dist/vscode/vs/workbench/contrib/search/browser/searchResultsView.js +379 -0
  401. package/dist/vscode/vs/workbench/contrib/search/browser/searchView.js +1867 -0
  402. package/dist/vscode/vs/workbench/contrib/search/browser/searchWidget.js +628 -0
  403. package/dist/vscode/vs/workbench/contrib/search/browser/symbolsQuickAccess.js +219 -0
  404. package/dist/vscode/vs/workbench/contrib/search/common/cacheState.js +85 -0
  405. package/dist/vscode/vs/workbench/contrib/search/common/constants.js +31 -0
  406. package/dist/vscode/vs/workbench/contrib/search/common/search.js +127 -1
  407. package/dist/vscode/vs/workbench/contrib/search/common/searchHistoryService.js +42 -0
  408. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/constants.js +11 -0
  409. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/media/searchEditor.css.js +4 -0
  410. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.js +477 -0
  411. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/searchEditor.js +697 -0
  412. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/searchEditorActions.js +188 -0
  413. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/searchEditorInput.js +295 -0
  414. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/searchEditorModel.js +135 -0
  415. package/dist/vscode/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.js +268 -0
  416. package/dist/vscode/vs/workbench/contrib/snippets/browser/tabCompletion.js +2 -2
  417. package/dist/vscode/vs/workbench/contrib/tasks/browser/taskQuickPick.js +385 -0
  418. package/dist/vscode/vs/workbench/contrib/tasks/browser/tasksQuickAccess.js +108 -0
  419. package/dist/vscode/vs/workbench/contrib/tasks/common/taskService.js +16 -1
  420. package/dist/vscode/vs/workbench/contrib/tasks/common/tasks.js +351 -0
  421. package/dist/vscode/vs/workbench/contrib/terminal/browser/environmentVariableInfo.js +119 -0
  422. package/dist/vscode/vs/workbench/contrib/terminal/browser/media/scrollbar.css.js +4 -0
  423. package/dist/vscode/vs/workbench/contrib/terminal/browser/media/terminal.css.js +4 -0
  424. package/dist/vscode/vs/workbench/contrib/terminal/browser/media/widgets.css.js +4 -0
  425. package/dist/vscode/vs/workbench/contrib/terminal/browser/media/xterm.css.js +4 -0
  426. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminal.contribution.js +238 -0
  427. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminal.js +7 -0
  428. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalActions.js +1930 -0
  429. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalCommands.js +22 -0
  430. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalConfigHelper.js +213 -0
  431. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalContextMenu.js +17 -0
  432. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalEditor.js +186 -0
  433. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalEditorInput.js +199 -0
  434. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalEditorService.js +239 -0
  435. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalExtensions.js +22 -0
  436. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalGroup.js +482 -0
  437. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalGroupService.js +372 -0
  438. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalIcon.js +103 -0
  439. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalIcons.js +37 -0
  440. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalInstance.js +2123 -0
  441. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalInstanceService.js +79 -0
  442. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalMainContribution.js +82 -0
  443. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalMenus.js +850 -0
  444. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.js +142 -0
  445. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalProcessManager.js +618 -0
  446. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.js +278 -0
  447. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.js +417 -0
  448. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalProfileService.js +213 -0
  449. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalQuickAccess.js +144 -0
  450. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalRunRecentQuickPick.js +267 -0
  451. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalService.js +1063 -0
  452. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalStatusList.js +108 -0
  453. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalTabbedView.js +417 -0
  454. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalTabsList.js +680 -0
  455. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalTooltip.js +72 -0
  456. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalUri.js +39 -0
  457. package/dist/vscode/vs/workbench/contrib/terminal/browser/terminalView.js +535 -0
  458. package/dist/vscode/vs/workbench/contrib/terminal/browser/widgets/widgetManager.js +36 -0
  459. package/dist/vscode/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +469 -0
  460. package/dist/vscode/vs/workbench/contrib/terminal/browser/xterm/decorationStyles.js +97 -0
  461. package/dist/vscode/vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon.js +56 -0
  462. package/dist/vscode/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +416 -0
  463. package/dist/vscode/vs/workbench/contrib/terminal/browser/xterm/suggestAddon.js +390 -0
  464. package/dist/vscode/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +587 -0
  465. package/dist/vscode/vs/workbench/contrib/terminal/common/environmentVariable.js +3 -0
  466. package/dist/vscode/vs/workbench/contrib/terminal/common/environmentVariableService.js +94 -0
  467. package/dist/vscode/vs/workbench/contrib/terminal/common/history.js +356 -0
  468. package/dist/vscode/vs/workbench/contrib/terminal/common/terminal.js +266 -0
  469. package/dist/vscode/vs/workbench/contrib/terminal/common/terminalColorRegistry.js +169 -16
  470. package/dist/vscode/vs/workbench/contrib/terminal/common/terminalConfiguration.js +965 -0
  471. package/dist/vscode/vs/workbench/contrib/terminal/common/terminalContextKey.js +157 -0
  472. package/dist/vscode/vs/workbench/contrib/terminal/common/terminalEnvironment.js +272 -0
  473. package/dist/vscode/vs/workbench/contrib/terminal/common/terminalExtensionPoints.js +27 -0
  474. package/dist/vscode/vs/workbench/contrib/terminal/common/terminalStrings.js +86 -0
  475. package/dist/vscode/vs/workbench/contrib/terminal/electron-sandbox/terminalProfileResolverService.js +46 -0
  476. package/dist/vscode/vs/workbench/contrib/terminalContrib/links/browser/links.js +3 -0
  477. package/dist/vscode/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkProviderService.js +26 -0
  478. package/dist/vscode/vs/workbench/contrib/terminalContrib/quickFix/browser/quickFix.js +3 -0
  479. package/dist/vscode/vs/workbench/contrib/terminalContrib/quickFix/browser/terminalQuickFixService.js +143 -0
  480. package/dist/vscode/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +4 -0
  481. package/dist/vscode/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +1 -1
  482. package/dist/vscode/vs/workbench/contrib/webviewPanel/browser/webviewEditorInput.js +85 -0
  483. package/dist/vscode/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.js +52 -0
  484. package/dist/vscode/vs/workbench/services/actions/common/menusExtensionPoint.js +14 -6
  485. package/dist/vscode/vs/workbench/services/assignment/common/assignmentService.js +3 -0
  486. package/dist/vscode/vs/workbench/services/configuration/browser/configurationService.js +13 -13
  487. package/dist/vscode/vs/workbench/services/configuration/common/configuration.js +2 -1
  488. package/dist/vscode/vs/workbench/services/configuration/common/configurationEditing.js +2 -2
  489. package/dist/vscode/vs/workbench/services/configuration/common/jsonEditingService.js +2 -2
  490. package/dist/vscode/vs/workbench/services/editor/browser/editorDropService.js +3 -0
  491. package/dist/vscode/vs/workbench/services/editor/browser/editorResolverService.js +619 -0
  492. package/dist/vscode/vs/workbench/services/editor/browser/editorService.js +720 -0
  493. package/dist/vscode/vs/workbench/services/editor/common/editorGroupFinder.js +116 -0
  494. package/dist/vscode/vs/workbench/services/editor/common/editorGroupsService.js +6 -1
  495. package/dist/vscode/vs/workbench/services/editor/common/editorResolverService.js +34 -1
  496. package/dist/vscode/vs/workbench/services/extensionManagement/common/extensionManagement.js +3 -2
  497. package/dist/vscode/vs/workbench/services/extensionRecommendations/common/extensionRecommendations.js +4 -0
  498. package/dist/vscode/vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig.js +2 -0
  499. package/dist/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService.js +3 -0
  500. package/dist/vscode/vs/workbench/services/extensions/common/extensions.js +14 -2
  501. package/dist/vscode/vs/workbench/services/extensions/common/extensionsApiProposals.js +10 -1
  502. package/dist/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.js +70 -3
  503. package/dist/vscode/vs/workbench/services/history/browser/historyService.js +1451 -0
  504. package/dist/vscode/vs/workbench/services/hover/browser/hoverService.js +2 -2
  505. package/dist/vscode/vs/workbench/services/hover/browser/hoverWidget.js +2 -1
  506. package/dist/vscode/vs/workbench/services/hover/browser/media/hover.css.js +4 -0
  507. package/dist/vscode/vs/workbench/services/keybinding/common/keybindingEditing.js +275 -0
  508. package/dist/vscode/vs/workbench/services/languageDetection/common/languageDetectionWorkerService.js +2 -1
  509. package/dist/vscode/vs/workbench/services/localization/common/locale.js +3 -0
  510. package/dist/vscode/vs/workbench/services/log/common/logConstants.js +2 -0
  511. package/dist/vscode/vs/workbench/services/outline/browser/outline.js +3 -0
  512. package/dist/vscode/vs/workbench/services/output/common/output.js +4 -1
  513. package/dist/vscode/vs/workbench/services/preferences/common/preferences.js +22 -1
  514. package/dist/vscode/vs/workbench/services/preferences/common/preferencesModels.js +6 -0
  515. package/dist/vscode/vs/workbench/services/preferences/common/preferencesValidation.js +37 -1
  516. package/dist/vscode/vs/workbench/services/progress/browser/progressIndicator.js +72 -1
  517. package/dist/vscode/vs/workbench/services/quickinput/browser/quickInputService.js +67 -0
  518. package/dist/vscode/vs/workbench/services/remote/common/remoteAgentService.js +69 -0
  519. package/dist/vscode/vs/workbench/services/remote/common/remoteExplorerService.js +66 -27
  520. package/dist/vscode/vs/workbench/services/search/common/fileSearchManager.js +265 -0
  521. package/dist/vscode/vs/workbench/services/search/common/queryBuilder.js +6 -0
  522. package/dist/vscode/vs/workbench/services/search/common/replace.js +203 -0
  523. package/dist/vscode/vs/workbench/services/search/common/search.js +117 -1
  524. package/dist/vscode/vs/workbench/services/search/common/searchExtTypes.js +6 -0
  525. package/dist/vscode/vs/workbench/services/search/common/textSearchManager.js +309 -0
  526. package/dist/vscode/vs/workbench/services/semanticSimilarity/common/semanticSimilarityService.js +54 -1
  527. package/dist/vscode/vs/workbench/services/statusbar/browser/statusbar.js +15 -0
  528. package/dist/vscode/vs/workbench/services/suggest/browser/media/suggest.css.js +4 -0
  529. package/dist/vscode/vs/workbench/services/suggest/browser/simpleCompletionItem.js +10 -0
  530. package/dist/vscode/vs/workbench/services/suggest/browser/simpleCompletionModel.js +98 -0
  531. package/dist/vscode/vs/workbench/services/suggest/browser/simpleSuggestWidget.js +399 -0
  532. package/dist/vscode/vs/workbench/services/suggest/browser/simpleSuggestWidgetRenderer.js +83 -0
  533. package/dist/vscode/vs/workbench/services/terminal/common/embedderTerminalService.js +3 -0
  534. package/dist/vscode/vs/workbench/services/textMate/browser/worker/textMate.worker.js +90 -0
  535. package/dist/vscode/vs/workbench/services/textMate/browser/worker/textMateWorkerModel.js +133 -0
  536. package/dist/vscode/vs/workbench/services/textfile/browser/textFileService.js +1 -1
  537. package/dist/vscode/vs/workbench/services/textfile/common/textFileEditorModel.js +10 -3
  538. package/dist/vscode/vs/workbench/services/themes/browser/fileIconThemeData.js +3 -3
  539. package/dist/vscode/vs/workbench/services/themes/browser/productIconThemeData.js +3 -3
  540. package/dist/vscode/vs/workbench/services/themes/common/colorThemeData.js +3 -3
  541. package/dist/vscode/vs/workbench/services/untitled/common/untitledTextEditorInput.js +6 -4
  542. package/dist/vscode/vs/workbench/services/untitled/common/untitledTextEditorModel.js +3 -0
  543. package/dist/vscode/vs/workbench/services/untitled/common/untitledTextEditorService.js +114 -3
  544. package/dist/vscode/vs/workbench/services/userActivity/common/userActivityRegistry.js +15 -0
  545. package/dist/vscode/vs/workbench/services/userActivity/common/userActivityService.js +37 -0
  546. package/dist/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.js +1 -1
  547. package/dist/vscode/vs/workbench/services/userDataSync/common/userDataSync.js +7 -0
  548. package/dist/vscode/vs/workbench/services/workingCopy/common/workingCopyEditorService.js +40 -0
  549. package/dist/vscode/vs/workbench/services/workingCopy/common/workingCopyService.js +12 -0
  550. package/dist/vscode/vs/workbench/services/workspaces/common/canonicalUriService.js +19 -0
  551. package/dist/vscode-default-extensions/css/syntaxes/css.tmLanguage.json.extensionResource.js +1 -1
  552. package/dist/vscode-default-extensions/json/package.json.js +1 -1
  553. package/dist/vscode-default-extensions/json/syntaxes/JSONC.tmLanguage.json.extensionResource.js +1 -1
  554. package/dist/vscode-default-extensions/json/syntaxes/JSONL.tmLanguage.json.extensionResource.js +2 -0
  555. package/dist/vscode-default-extensions/latex/syntaxes/Bibtex.tmLanguage.json.extensionResource.js +1 -1
  556. package/dist/vscode-default-extensions/latex/syntaxes/LaTeX.tmLanguage.json.extensionResource.js +1 -1
  557. package/dist/vscode-default-extensions/latex/syntaxes/TeX.tmLanguage.json.extensionResource.js +1 -1
  558. package/dist/vscode-default-extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.extensionResource.js +1 -1
  559. package/dist/vscode-default-extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.extensionResource.js +1 -1
  560. package/dist/vscode-default-extensions/lua/syntaxes/lua.tmLanguage.json.extensionResource.js +1 -1
  561. package/dist/vscode-default-extensions/perl/package.json.js +1 -1
  562. package/dist/vscode-default-extensions/php/snippets/php.code-snippets.extensionResource.js +1 -1
  563. package/dist/vscode-default-extensions/sql/language-configuration.json.extensionResource.js +1 -1
  564. package/dist/vscode-default-extensions/theme-abyss/themes/abyss-color-theme.json.extensionResource.js +1 -1
  565. package/dist/vscode-default-extensions/theme-defaults/package.json.js +1 -1
  566. package/dist/vscode-default-extensions/theme-defaults/themes/dark_modern.json.extensionResource.js +2 -0
  567. package/dist/vscode-default-extensions/theme-defaults/themes/dark_vs.json.extensionResource.js +1 -1
  568. package/dist/vscode-default-extensions/theme-defaults/themes/hc_black.json.extensionResource.js +1 -1
  569. package/dist/vscode-default-extensions/theme-defaults/themes/hc_light.json.extensionResource.js +1 -1
  570. package/dist/vscode-default-extensions/theme-defaults/themes/light_modern.json.extensionResource.js +2 -0
  571. package/dist/vscode-default-extensions/theme-defaults/themes/light_vs.json.extensionResource.js +1 -1
  572. package/dist/vscode-default-extensions/theme-kimbie-dark/themes/kimbie-dark-color-theme.json.extensionResource.js +1 -1
  573. package/dist/vscode-default-extensions/theme-monokai/themes/monokai-color-theme.json.extensionResource.js +1 -1
  574. package/dist/vscode-default-extensions/theme-monokai-dimmed/themes/dimmed-monokai-color-theme.json.extensionResource.js +1 -1
  575. package/dist/vscode-default-extensions/theme-quietlight/themes/quietlight-color-theme.json.extensionResource.js +1 -1
  576. package/dist/vscode-default-extensions/theme-red/themes/Red-color-theme.json.extensionResource.js +1 -1
  577. package/dist/vscode-default-extensions/theme-seti/icons/vs-seti-icon-theme.json.extensionResource.js +1 -1
  578. package/dist/vscode-default-extensions/theme-solarized-dark/themes/solarized-dark-color-theme.json.extensionResource.js +1 -1
  579. package/dist/vscode-default-extensions/theme-solarized-light/themes/solarized-light-color-theme.json.extensionResource.js +1 -1
  580. package/dist/vscode-default-extensions/theme-tomorrow-night-blue/themes/tomorrow-night-blue-color-theme.json.extensionResource.js +1 -1
  581. package/dist/vscode-default-extensions/vb/language-configuration.json.extensionResource.js +1 -1
  582. package/dist/vscode-services/env.js +4 -2
  583. package/dist/vscode-services/extHost.js +41 -50
  584. package/dist/vscode-services/missing-services.js +504 -12
  585. package/dist/vscode-services/window.js +80 -67
  586. package/dist/vscode-services/workspace.js +19 -4
  587. package/dist/workbenchThemeService.d.ts +1 -1
  588. package/dist/workers/outputLinkComputer.worker.d.ts +2 -0
  589. package/dist/workers/outputLinkComputer.worker.js +3 -0
  590. package/dist/workers/textMate.worker.d.ts +2 -0
  591. package/dist/workers/textMate.worker.js +3 -0
  592. package/dist/workspace.d.ts +1 -1
  593. package/monaco-editor-treemending.patch +1305 -1184
  594. package/package.json +98 -32
  595. package/dist/activity.d.ts +0 -2902
  596. package/dist/assets/activityaction.css +0 -224
  597. package/dist/assets/activitybarpart.css +0 -65
  598. package/dist/assets/basepanelpart.css +0 -221
  599. package/dist/assets/breakpointWidget.css +0 -31
  600. package/dist/assets/callHierarchy.css +0 -62
  601. package/dist/assets/callStackEditorContribution.css +0 -12
  602. package/dist/assets/compositepart.css +0 -17
  603. package/dist/assets/debug.contribution.css +0 -138
  604. package/dist/assets/debugHover.css +0 -80
  605. package/dist/assets/debugToolBar.css +0 -49
  606. package/dist/assets/debugViewlet.css +0 -337
  607. package/dist/assets/editorquickaccess.css +0 -8
  608. package/dist/assets/exceptionWidget.css +0 -52
  609. package/dist/assets/explorerviewlet.css +0 -129
  610. package/dist/assets/hover.css +0 -127
  611. package/dist/assets/interactiveSession.css +0 -340
  612. package/dist/assets/menubar.css +0 -111
  613. package/dist/assets/menubarControl.css +0 -61
  614. package/dist/assets/notificationsActions.css +0 -14
  615. package/dist/assets/notificationsCenter.css +0 -69
  616. package/dist/assets/notificationsList.css +0 -152
  617. package/dist/assets/notificationsToasts.css +0 -63
  618. package/dist/assets/panelpart.css +0 -75
  619. package/dist/assets/paneview.css +0 -148
  620. package/dist/assets/paneviewlet.css +0 -79
  621. package/dist/assets/part.css +0 -109
  622. package/dist/assets/repl.css +0 -145
  623. package/dist/assets/sidebarpart.css +0 -61
  624. package/dist/assets/tunnelView.css +0 -107
  625. package/dist/assets/typeHierarchy.css +0 -62
  626. package/dist/assets/views.css +0 -297
  627. package/dist/collections.d.ts +0 -7
  628. package/dist/colorRegistry.d.ts +0 -710
  629. package/dist/override/vs/workbench/browser/parts/editor/textEditor.js +0 -2
  630. package/dist/override/vs/workbench/contrib/files/browser/views/openEditorsView.js +0 -2
  631. package/dist/service-override/modelEditor.d.ts +0 -14
  632. package/dist/vscode/vs/workbench/contrib/interactiveSession/browser/interactiveSessionFollowups.js +0 -30
  633. package/dist/vscode/vs/workbench/contrib/interactiveSession/browser/interactiveSessionInputPart.js +0 -196
  634. package/dist/vscode/vs/workbench/contrib/interactiveSession/browser/interactiveSessionListRenderer.js +0 -622
  635. package/dist/vscode/vs/workbench/contrib/interactiveSession/browser/interactiveSessionOptions.js +0 -77
  636. package/dist/vscode/vs/workbench/contrib/interactiveSession/browser/interactiveSessionWidget.js +0 -311
  637. package/dist/vscode/vs/workbench/contrib/interactiveSession/common/interactiveSessionContextKeys.js +0 -48
  638. package/dist/vscode/vs/workbench/contrib/interactiveSession/common/interactiveSessionService.js +0 -8
  639. package/dist/vscode/vs/workbench/contrib/interactiveSession/common/interactiveSessionViewModel.js +0 -207
  640. package/dist/vscode/vs/workbench/contrib/interactiveSession/common/interactiveSessionWidgetHistoryService.js +0 -3
  641. package/dist/vscode/vs/workbench/contrib/interactiveSession/common/interactiveSessionWordCounter.js +0 -25
  642. package/dist/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -249
  643. package/dist/vscode-default-extensions/theme-defaults/themes/dark_plus_experimental.json.extensionResource.js +0 -2
  644. package/dist/vscode-default-extensions/theme-defaults/themes/light_plus_experimental.json.extensionResource.js +0 -2
@@ -7,7 +7,6 @@ import process$1, { env as env$1 } from 'node:process';
7
7
  import { performance } from 'node:perf_hooks';
8
8
  import { createHash as createHash$1 } from 'node:crypto';
9
9
  import { mkdir, writeFile, readFile, lstat, realpath, readdir } from 'node:fs/promises';
10
- import { EventEmitter } from 'node:events';
11
10
  import * as tty from 'tty';
12
11
  import { addExtension } from '@rollup/pluginutils';
13
12
 
@@ -1401,6 +1400,9 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
1401
1400
  * Copyright (c) Microsoft Corporation. All rights reserved.
1402
1401
  * Licensed under the MIT License. See License.txt in the project root for license information.
1403
1402
  *--------------------------------------------------------------------------------------------*/
1403
+ /**
1404
+ * Extracted from json.ts to keep json nls free.
1405
+ */
1404
1406
  function getParseErrorMessage(errorCode) {
1405
1407
  switch (errorCode) {
1406
1408
  case 1 /* ParseErrorCode.InvalidSymbol */: return localize('error.invalidSymbol', 'Invalid symbol');
@@ -1419,15 +1421,15 @@ function getParseErrorMessage(errorCode) {
1419
1421
 
1420
1422
  /*
1421
1423
  @license
1422
- Rollup.js v3.21.3
1423
- Tue, 02 May 2023 04:37:56 GMT - commit ef6ca52fec43ec4a7d6f12c8ebdee82ee690c2ce
1424
+ Rollup.js v3.25.1
1425
+ Mon, 12 Jun 2023 04:38:12 GMT - commit b1341bf9cd719670a670905e0308418b37621d70
1424
1426
 
1425
1427
  https://github.com/rollup/rollup
1426
1428
 
1427
1429
  Released under the MIT License.
1428
1430
  */
1429
1431
 
1430
- var version$1 = "3.21.3";
1432
+ var version$1 = "3.25.1";
1431
1433
 
1432
1434
  const comma = ','.charCodeAt(0);
1433
1435
  const semicolon = ';'.charCodeAt(0);
@@ -3383,6 +3385,89 @@ const EMPTY_SET = Object.freeze(new (class extends Set {
3383
3385
  }
3384
3386
  })());
3385
3387
 
3388
+ const RESERVED_NAMES = new Set([
3389
+ 'await',
3390
+ 'break',
3391
+ 'case',
3392
+ 'catch',
3393
+ 'class',
3394
+ 'const',
3395
+ 'continue',
3396
+ 'debugger',
3397
+ 'default',
3398
+ 'delete',
3399
+ 'do',
3400
+ 'else',
3401
+ 'enum',
3402
+ 'eval',
3403
+ 'export',
3404
+ 'extends',
3405
+ 'false',
3406
+ 'finally',
3407
+ 'for',
3408
+ 'function',
3409
+ 'if',
3410
+ 'implements',
3411
+ 'import',
3412
+ 'in',
3413
+ 'instanceof',
3414
+ 'interface',
3415
+ 'let',
3416
+ 'NaN',
3417
+ 'new',
3418
+ 'null',
3419
+ 'package',
3420
+ 'private',
3421
+ 'protected',
3422
+ 'public',
3423
+ 'return',
3424
+ 'static',
3425
+ 'super',
3426
+ 'switch',
3427
+ 'this',
3428
+ 'throw',
3429
+ 'true',
3430
+ 'try',
3431
+ 'typeof',
3432
+ 'undefined',
3433
+ 'var',
3434
+ 'void',
3435
+ 'while',
3436
+ 'with',
3437
+ 'yield'
3438
+ ]);
3439
+ const RESERVED_NAMES$1 = RESERVED_NAMES;
3440
+
3441
+ const illegalCharacters = /[^\w$]/g;
3442
+ const startsWithDigit = (value) => /\d/.test(value[0]);
3443
+ const needsEscape = (value) => startsWithDigit(value) || RESERVED_NAMES$1.has(value) || value === 'arguments';
3444
+ function isLegal(value) {
3445
+ if (needsEscape(value)) {
3446
+ return false;
3447
+ }
3448
+ return !illegalCharacters.test(value);
3449
+ }
3450
+ function makeLegal(value) {
3451
+ value = value
3452
+ .replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
3453
+ .replace(illegalCharacters, '_');
3454
+ if (needsEscape(value))
3455
+ value = `_${value}`;
3456
+ return value || '_';
3457
+ }
3458
+
3459
+ const LOGLEVEL_SILENT = 'silent';
3460
+ const LOGLEVEL_ERROR = 'error';
3461
+ const LOGLEVEL_WARN = 'warn';
3462
+ const LOGLEVEL_INFO = 'info';
3463
+ const LOGLEVEL_DEBUG = 'debug';
3464
+ const logLevelPriority = {
3465
+ [LOGLEVEL_DEBUG]: 0,
3466
+ [LOGLEVEL_INFO]: 1,
3467
+ [LOGLEVEL_SILENT]: 3,
3468
+ [LOGLEVEL_WARN]: 2
3469
+ };
3470
+
3386
3471
  function getLocator(source, options) {
3387
3472
  if (options === void 0) { options = {}; }
3388
3473
  var offsetLine = options.offsetLine || 0;
@@ -3495,6 +3580,12 @@ function isValidUrl(url) {
3495
3580
  function getRollupUrl(snippet) {
3496
3581
  return `https://rollupjs.org/${snippet}`;
3497
3582
  }
3583
+ function addTrailingSlashIfMissed(url) {
3584
+ if (!url.endsWith('/')) {
3585
+ return url + '/';
3586
+ }
3587
+ return url;
3588
+ }
3498
3589
 
3499
3590
  // troubleshooting
3500
3591
  const URL_AVOIDING_EVAL = 'troubleshooting/#avoiding-eval';
@@ -3554,21 +3645,21 @@ function augmentCodeLocation(properties, pos, source, id) {
3554
3645
  }
3555
3646
  // Error codes should be sorted alphabetically while errors should be sorted by
3556
3647
  // error code below
3557
- const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ASSERTIONS = 'INCONSISTENT_IMPORT_ASSERTIONS', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
3558
- function errorAddonNotGenerated(message, hook, plugin) {
3648
+ const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ASSERTIONS = 'INCONSISTENT_IMPORT_ASSERTIONS', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
3649
+ function logAddonNotGenerated(message, hook, plugin) {
3559
3650
  return {
3560
3651
  code: ADDON_ERROR,
3561
3652
  message: `Could not retrieve "${hook}". Check configuration of plugin "${plugin}".
3562
3653
  \tError Message: ${message}`
3563
3654
  };
3564
3655
  }
3565
- function errorAlreadyClosed() {
3656
+ function logAlreadyClosed() {
3566
3657
  return {
3567
3658
  code: ALREADY_CLOSED,
3568
3659
  message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
3569
3660
  };
3570
3661
  }
3571
- function errorAmbiguousExternalNamespaces(binding, reexportingModule, usedModule, sources) {
3662
+ function logAmbiguousExternalNamespaces(binding, reexportingModule, usedModule, sources) {
3572
3663
  return {
3573
3664
  binding,
3574
3665
  code: AMBIGUOUS_EXTERNAL_NAMESPACES,
@@ -3577,61 +3668,61 @@ function errorAmbiguousExternalNamespaces(binding, reexportingModule, usedModule
3577
3668
  reexporter: reexportingModule
3578
3669
  };
3579
3670
  }
3580
- function errorAnonymousPluginCache() {
3671
+ function logAnonymousPluginCache() {
3581
3672
  return {
3582
3673
  code: ANONYMOUS_PLUGIN_CACHE,
3583
3674
  message: 'A plugin is trying to use the Rollup cache but is not declaring a plugin name or cacheKey.'
3584
3675
  };
3585
3676
  }
3586
- function errorAssetNotFinalisedForFileName(name) {
3677
+ function logAssetNotFinalisedForFileName(name) {
3587
3678
  return {
3588
3679
  code: ASSET_NOT_FINALISED,
3589
3680
  message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_<referenceId>, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.`
3590
3681
  };
3591
3682
  }
3592
- function errorAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
3683
+ function logAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
3593
3684
  return {
3594
3685
  code: ASSET_NOT_FOUND,
3595
3686
  message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
3596
3687
  };
3597
3688
  }
3598
- function errorAssetSourceAlreadySet(name) {
3689
+ function logAssetSourceAlreadySet(name) {
3599
3690
  return {
3600
3691
  code: ASSET_SOURCE_ALREADY_SET,
3601
3692
  message: `Unable to set the source for asset "${name}", source already set.`
3602
3693
  };
3603
3694
  }
3604
- function errorNoAssetSourceSet(assetName) {
3695
+ function logNoAssetSourceSet(assetName) {
3605
3696
  return {
3606
3697
  code: ASSET_SOURCE_MISSING,
3607
3698
  message: `Plugin error creating asset "${assetName}" - no asset source set.`
3608
3699
  };
3609
3700
  }
3610
- function errorBadLoader(id) {
3701
+ function logBadLoader(id) {
3611
3702
  return {
3612
3703
  code: BAD_LOADER,
3613
3704
  message: `Error loading "${relativeId(id)}": plugin load hook should return a string, a { code, map } object, or nothing/null.`
3614
3705
  };
3615
3706
  }
3616
- function errorCannotCallNamespace(name) {
3707
+ function logCannotCallNamespace(name) {
3617
3708
  return {
3618
3709
  code: CANNOT_CALL_NAMESPACE,
3619
3710
  message: `Cannot call a namespace ("${name}").`
3620
3711
  };
3621
3712
  }
3622
- function errorCannotEmitFromOptionsHook() {
3713
+ function logCannotEmitFromOptionsHook() {
3623
3714
  return {
3624
3715
  code: CANNOT_EMIT_FROM_OPTIONS_HOOK,
3625
3716
  message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
3626
3717
  };
3627
3718
  }
3628
- function errorChunkNotGeneratedForFileName(name) {
3719
+ function logChunkNotGeneratedForFileName(name) {
3629
3720
  return {
3630
3721
  code: CHUNK_NOT_GENERATED,
3631
3722
  message: `Plugin error - Unable to get file name for emitted chunk "${name}". You can only get file names once chunks have been generated after the "renderStart" hook.`
3632
3723
  };
3633
3724
  }
3634
- function errorChunkInvalid({ fileName, code }, exception) {
3725
+ function logChunkInvalid({ fileName, code }, exception) {
3635
3726
  const errorProperties = {
3636
3727
  code: CHUNK_INVALID,
3637
3728
  message: `Chunk "${fileName}" is not valid JavaScript: ${exception.message}.`
@@ -3639,21 +3730,21 @@ function errorChunkInvalid({ fileName, code }, exception) {
3639
3730
  augmentCodeLocation(errorProperties, exception.loc, code, fileName);
3640
3731
  return errorProperties;
3641
3732
  }
3642
- function errorCircularDependency(cyclePath) {
3733
+ function logCircularDependency(cyclePath) {
3643
3734
  return {
3644
3735
  code: CIRCULAR_DEPENDENCY,
3645
3736
  ids: cyclePath,
3646
3737
  message: `Circular dependency: ${cyclePath.map(relativeId).join(' -> ')}`
3647
3738
  };
3648
3739
  }
3649
- function errorCircularReexport(exportName, exporter) {
3740
+ function logCircularReexport(exportName, exporter) {
3650
3741
  return {
3651
3742
  code: CIRCULAR_REEXPORT,
3652
3743
  exporter,
3653
3744
  message: `"${exportName}" cannot be exported from "${relativeId(exporter)}" as it is a reexport that references itself.`
3654
3745
  };
3655
3746
  }
3656
- function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importer, preserveModules) {
3747
+ function logCyclicCrossChunkReexport(exportName, exporter, reexporter, importer, preserveModules) {
3657
3748
  return {
3658
3749
  code: CYCLIC_CROSS_CHUNK_REEXPORT,
3659
3750
  exporter,
@@ -3662,7 +3753,7 @@ function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importe
3662
3753
  reexporter
3663
3754
  };
3664
3755
  }
3665
- function errorDeprecation(deprecation, urlSnippet, plugin) {
3756
+ function logDeprecation(deprecation, urlSnippet, plugin) {
3666
3757
  return {
3667
3758
  code: DEPRECATED_FEATURE,
3668
3759
  message: deprecation,
@@ -3670,20 +3761,20 @@ function errorDeprecation(deprecation, urlSnippet, plugin) {
3670
3761
  ...(plugin ? { plugin } : {})
3671
3762
  };
3672
3763
  }
3673
- function errorDuplicatePluginName(plugin) {
3764
+ function logDuplicatePluginName(plugin) {
3674
3765
  return {
3675
3766
  code: DUPLICATE_PLUGIN_NAME,
3676
3767
  message: `The plugin name ${plugin} is being used twice in the same build. Plugin names must be distinct or provide a cacheKey (please post an issue to the plugin if you are a plugin user).`
3677
3768
  };
3678
3769
  }
3679
- function errorEmptyChunk(chunkName) {
3770
+ function logEmptyChunk(chunkName) {
3680
3771
  return {
3681
3772
  code: EMPTY_BUNDLE,
3682
3773
  message: `Generated an empty chunk: "${chunkName}".`,
3683
3774
  names: [chunkName]
3684
3775
  };
3685
3776
  }
3686
- function errorEval(id) {
3777
+ function logEval(id) {
3687
3778
  return {
3688
3779
  code: EVAL,
3689
3780
  id,
@@ -3691,39 +3782,45 @@ function errorEval(id) {
3691
3782
  url: getRollupUrl(URL_AVOIDING_EVAL)
3692
3783
  };
3693
3784
  }
3694
- function errorExternalSyntheticExports(id, importer) {
3785
+ function logExternalSyntheticExports(id, importer) {
3695
3786
  return {
3696
3787
  code: EXTERNAL_SYNTHETIC_EXPORTS,
3697
3788
  exporter: id,
3698
3789
  message: `External "${id}" cannot have "syntheticNamedExports" enabled (imported by "${relativeId(importer)}").`
3699
3790
  };
3700
3791
  }
3701
- function errorFileNameConflict(fileName) {
3792
+ function logFileNameConflict(fileName) {
3702
3793
  return {
3703
3794
  code: FILE_NAME_CONFLICT,
3704
3795
  message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
3705
3796
  };
3706
3797
  }
3707
- function errorFileReferenceIdNotFoundForFilename(assetReferenceId) {
3798
+ function logFileReferenceIdNotFoundForFilename(assetReferenceId) {
3708
3799
  return {
3709
3800
  code: FILE_NOT_FOUND,
3710
3801
  message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
3711
3802
  };
3712
3803
  }
3713
- function errorIllegalIdentifierAsName(name) {
3804
+ function logFirstSideEffect(source, id, { line, column }) {
3805
+ return {
3806
+ code: FIRST_SIDE_EFFECT,
3807
+ message: `First side effect in ${relativeId(id)} is at (${line}:${column})\n${getCodeFrame(source, line, column)}`
3808
+ };
3809
+ }
3810
+ function logIllegalIdentifierAsName(name) {
3714
3811
  return {
3715
3812
  code: ILLEGAL_IDENTIFIER_AS_NAME,
3716
3813
  message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`,
3717
3814
  url: getRollupUrl(URL_OUTPUT_EXTEND)
3718
3815
  };
3719
3816
  }
3720
- function errorIllegalImportReassignment(name, importingId) {
3817
+ function logIllegalImportReassignment(name, importingId) {
3721
3818
  return {
3722
3819
  code: ILLEGAL_REASSIGNMENT,
3723
3820
  message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
3724
3821
  };
3725
3822
  }
3726
- function errorInconsistentImportAssertions(existingAssertions, newAssertions, source, importer) {
3823
+ function logInconsistentImportAssertions(existingAssertions, newAssertions, source, importer) {
3727
3824
  return {
3728
3825
  code: INCONSISTENT_IMPORT_ASSERTIONS,
3729
3826
  message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAssertions(newAssertions)} assertions, but it was already imported elsewhere with ${formatAssertions(existingAssertions)} assertions. Please ensure that import assertions for the same module are always consistent.`
@@ -3735,46 +3832,52 @@ const formatAssertions = (assertions) => {
3735
3832
  return 'no';
3736
3833
  return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
3737
3834
  };
3738
- function errorInputHookInOutputPlugin(pluginName, hookName) {
3835
+ function logInputHookInOutputPlugin(pluginName, hookName) {
3739
3836
  return {
3740
3837
  code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
3741
3838
  message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
3742
3839
  };
3743
3840
  }
3744
- function errorCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
3841
+ function logCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
3745
3842
  return {
3746
3843
  code: INVALID_CHUNK,
3747
3844
  message: `Cannot assign "${relativeId(moduleId)}" to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
3748
3845
  };
3749
3846
  }
3750
- function errorInvalidExportOptionValue(optionValue) {
3847
+ function logInvalidExportOptionValue(optionValue) {
3751
3848
  return {
3752
3849
  code: INVALID_EXPORT_OPTION,
3753
3850
  message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}".`,
3754
3851
  url: getRollupUrl(URL_OUTPUT_EXPORTS)
3755
3852
  };
3756
3853
  }
3757
- function errorIncompatibleExportOptionValue(optionValue, keys, entryModule) {
3854
+ function logIncompatibleExportOptionValue(optionValue, keys, entryModule) {
3758
3855
  return {
3759
3856
  code: INVALID_EXPORT_OPTION,
3760
3857
  message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${printQuotedStringList(keys)}`,
3761
3858
  url: getRollupUrl(URL_OUTPUT_EXPORTS)
3762
3859
  };
3763
3860
  }
3764
- function errorInternalIdCannotBeExternal(source, importer) {
3861
+ function logInternalIdCannotBeExternal(source, importer) {
3765
3862
  return {
3766
3863
  code: INVALID_EXTERNAL_ID,
3767
3864
  message: `"${source}" is imported as an external by "${relativeId(importer)}", but is already an existing non-external module id.`
3768
3865
  };
3769
3866
  }
3770
- function errorInvalidOption(option, urlSnippet, explanation, value) {
3867
+ function logInvalidLogPosition(plugin) {
3868
+ return {
3869
+ code: INVALID_LOG_POSITION,
3870
+ message: `Plugin "${plugin}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
3871
+ };
3872
+ }
3873
+ function logInvalidOption(option, urlSnippet, explanation, value) {
3771
3874
  return {
3772
3875
  code: INVALID_OPTION,
3773
3876
  message: `Invalid value ${value === undefined ? '' : `${JSON.stringify(value)} `}for option "${option}" - ${explanation}.`,
3774
3877
  url: getRollupUrl(urlSnippet)
3775
3878
  };
3776
3879
  }
3777
- function errorInvalidAddonPluginHook(hook, plugin) {
3880
+ function logInvalidAddonPluginHook(hook, plugin) {
3778
3881
  return {
3779
3882
  code: INVALID_PLUGIN_HOOK,
3780
3883
  hook,
@@ -3782,7 +3885,7 @@ function errorInvalidAddonPluginHook(hook, plugin) {
3782
3885
  plugin
3783
3886
  };
3784
3887
  }
3785
- function errorInvalidFunctionPluginHook(hook, plugin) {
3888
+ function logInvalidFunctionPluginHook(hook, plugin) {
3786
3889
  return {
3787
3890
  code: INVALID_PLUGIN_HOOK,
3788
3891
  hook,
@@ -3790,32 +3893,32 @@ function errorInvalidFunctionPluginHook(hook, plugin) {
3790
3893
  plugin
3791
3894
  };
3792
3895
  }
3793
- function errorInvalidRollupPhaseForAddWatchFile() {
3896
+ function logInvalidRollupPhaseForAddWatchFile() {
3794
3897
  return {
3795
3898
  code: INVALID_ROLLUP_PHASE,
3796
3899
  message: `Cannot call "addWatchFile" after the build has finished.`
3797
3900
  };
3798
3901
  }
3799
- function errorInvalidRollupPhaseForChunkEmission() {
3902
+ function logInvalidRollupPhaseForChunkEmission() {
3800
3903
  return {
3801
3904
  code: INVALID_ROLLUP_PHASE,
3802
3905
  message: `Cannot emit chunks after module loading has finished.`
3803
3906
  };
3804
3907
  }
3805
- function errorInvalidSetAssetSourceCall() {
3908
+ function logInvalidSetAssetSourceCall() {
3806
3909
  return {
3807
3910
  code: INVALID_SETASSETSOURCE,
3808
3911
  message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
3809
3912
  };
3810
3913
  }
3811
- function errorInvalidFormatForTopLevelAwait(id, format) {
3914
+ function logInvalidFormatForTopLevelAwait(id, format) {
3812
3915
  return {
3813
3916
  code: INVALID_TLA_FORMAT,
3814
3917
  id,
3815
3918
  message: `Module format "${format}" does not support top-level await. Use the "es" or "system" output formats rather.`
3816
3919
  };
3817
3920
  }
3818
- function errorMissingExport(binding, importingModule, exporter) {
3921
+ function logMissingExport(binding, importingModule, exporter) {
3819
3922
  const isJson = extname(exporter) === '.json';
3820
3923
  return {
3821
3924
  binding,
@@ -3826,7 +3929,7 @@ function errorMissingExport(binding, importingModule, exporter) {
3826
3929
  url: getRollupUrl(URL_NAME_IS_NOT_EXPORTED)
3827
3930
  };
3828
3931
  }
3829
- function errorMissingGlobalName(externalId, guess) {
3932
+ function logMissingGlobalName(externalId, guess) {
3830
3933
  return {
3831
3934
  code: MISSING_GLOBAL_NAME,
3832
3935
  id: externalId,
@@ -3835,19 +3938,19 @@ function errorMissingGlobalName(externalId, guess) {
3835
3938
  url: getRollupUrl(URL_OUTPUT_GLOBALS)
3836
3939
  };
3837
3940
  }
3838
- function errorImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
3941
+ function logImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
3839
3942
  return {
3840
3943
  code: MISSING_IMPLICIT_DEPENDANT,
3841
3944
  message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
3842
3945
  };
3843
3946
  }
3844
- function errorUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
3947
+ function logUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
3845
3948
  return {
3846
3949
  code: MISSING_IMPLICIT_DEPENDANT,
3847
3950
  message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
3848
3951
  };
3849
3952
  }
3850
- function errorImplicitDependantIsNotIncluded(module) {
3953
+ function logImplicitDependantIsNotIncluded(module) {
3851
3954
  const implicitDependencies = [...module.implicitlyLoadedBefore]
3852
3955
  .map(dependency => relativeId(dependency.id))
3853
3956
  .sort();
@@ -3856,21 +3959,21 @@ function errorImplicitDependantIsNotIncluded(module) {
3856
3959
  message: `Module "${relativeId(module.id)}" that should be implicitly loaded before ${printQuotedStringList(implicitDependencies)} is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.`
3857
3960
  };
3858
3961
  }
3859
- function errorMissingNameOptionForIifeExport() {
3962
+ function logMissingNameOptionForIifeExport() {
3860
3963
  return {
3861
3964
  code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
3862
3965
  message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`,
3863
3966
  url: getRollupUrl(URL_OUTPUT_NAME)
3864
3967
  };
3865
3968
  }
3866
- function errorMissingNameOptionForUmdExport() {
3969
+ function logMissingNameOptionForUmdExport() {
3867
3970
  return {
3868
3971
  code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
3869
3972
  message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.',
3870
3973
  url: getRollupUrl(URL_OUTPUT_NAME)
3871
3974
  };
3872
3975
  }
3873
- function errorMissingNodeBuiltins(externalBuiltins) {
3976
+ function logMissingNodeBuiltins(externalBuiltins) {
3874
3977
  return {
3875
3978
  code: MISSING_NODE_BUILTINS,
3876
3979
  ids: externalBuiltins,
@@ -3878,14 +3981,14 @@ function errorMissingNodeBuiltins(externalBuiltins) {
3878
3981
  };
3879
3982
  }
3880
3983
  // eslint-disable-next-line unicorn/prevent-abbreviations
3881
- function errorMissingFileOrDirOption() {
3984
+ function logMissingFileOrDirOption() {
3882
3985
  return {
3883
3986
  code: MISSING_OPTION,
3884
3987
  message: 'You must specify "output.file" or "output.dir" for the build.',
3885
3988
  url: getRollupUrl(URL_OUTPUT_DIR)
3886
3989
  };
3887
3990
  }
3888
- function errorMixedExport(facadeModuleId, name) {
3991
+ function logMixedExport(facadeModuleId, name) {
3889
3992
  return {
3890
3993
  code: MIXED_EXPORTS,
3891
3994
  id: facadeModuleId,
@@ -3893,14 +3996,14 @@ function errorMixedExport(facadeModuleId, name) {
3893
3996
  url: getRollupUrl(URL_OUTPUT_EXPORTS)
3894
3997
  };
3895
3998
  }
3896
- function errorModuleLevelDirective(directive, id) {
3999
+ function logModuleLevelDirective(directive, id) {
3897
4000
  return {
3898
4001
  code: MODULE_LEVEL_DIRECTIVE,
3899
4002
  id,
3900
4003
  message: `Module level directives cause errors when bundled, "${directive}" in "${relativeId(id)}" was ignored.`
3901
4004
  };
3902
4005
  }
3903
- function errorNamespaceConflict(binding, reexportingModuleId, sources) {
4006
+ function logNamespaceConflict(binding, reexportingModuleId, sources) {
3904
4007
  return {
3905
4008
  binding,
3906
4009
  code: NAMESPACE_CONFLICT,
@@ -3909,14 +4012,22 @@ function errorNamespaceConflict(binding, reexportingModuleId, sources) {
3909
4012
  reexporter: reexportingModuleId
3910
4013
  };
3911
4014
  }
3912
- function errorNoTransformMapOrAstWithoutCode(pluginName) {
4015
+ function logNoTransformMapOrAstWithoutCode(pluginName) {
3913
4016
  return {
3914
4017
  code: NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
3915
4018
  message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
3916
4019
  'a "code". This will be ignored.'
3917
4020
  };
3918
4021
  }
3919
- function errorParseError(error, moduleId) {
4022
+ function logOptimizeChunkStatus(chunks, smallChunks, pointInTime) {
4023
+ return {
4024
+ code: OPTIMIZE_CHUNK_STATUS,
4025
+ message: `${pointInTime}, there are\n` +
4026
+ `${chunks} chunks, of which\n` +
4027
+ `${smallChunks} are below minChunkSize.`
4028
+ };
4029
+ }
4030
+ function logParseError(error, moduleId) {
3920
4031
  let message = error.message.replace(/ \(\d+:\d+\)$/, '');
3921
4032
  if (moduleId.endsWith('.json')) {
3922
4033
  message += ' (Note that you need @rollup/plugin-json to import JSON files)';
@@ -3931,10 +4042,8 @@ function errorParseError(error, moduleId) {
3931
4042
  message
3932
4043
  };
3933
4044
  }
3934
- function errorPluginError(error, plugin, { hook, id } = {}) {
3935
- if (typeof error === 'string')
3936
- error = { message: error };
3937
- if (error.code && error.code !== PLUGIN_ERROR) {
4045
+ function logPluginError(error, plugin, { hook, id } = {}) {
4046
+ if (error.code && !error.code.startsWith('PLUGIN_') && !error.pluginCode) {
3938
4047
  error.pluginCode = error.code;
3939
4048
  }
3940
4049
  error.code = PLUGIN_ERROR;
@@ -3947,7 +4056,7 @@ function errorPluginError(error, plugin, { hook, id } = {}) {
3947
4056
  }
3948
4057
  return error;
3949
4058
  }
3950
- function errorShimmedExport(id, binding) {
4059
+ function logShimmedExport(id, binding) {
3951
4060
  return {
3952
4061
  binding,
3953
4062
  code: SHIMMED_EXPORT,
@@ -3955,7 +4064,7 @@ function errorShimmedExport(id, binding) {
3955
4064
  message: `Missing export "${binding}" has been shimmed in module "${relativeId(id)}".`
3956
4065
  };
3957
4066
  }
3958
- function errorSourcemapBroken(plugin) {
4067
+ function logSourcemapBroken(plugin) {
3959
4068
  return {
3960
4069
  code: SOURCEMAP_BROKEN,
3961
4070
  message: `Sourcemap is likely to be incorrect: a plugin (${plugin}) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`,
@@ -3963,13 +4072,13 @@ function errorSourcemapBroken(plugin) {
3963
4072
  url: getRollupUrl(URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT)
3964
4073
  };
3965
4074
  }
3966
- function errorConflictingSourcemapSources(filename) {
4075
+ function logConflictingSourcemapSources(filename) {
3967
4076
  return {
3968
4077
  code: SOURCEMAP_BROKEN,
3969
4078
  message: `Multiple conflicting contents for sourcemap source ${filename}`
3970
4079
  };
3971
4080
  }
3972
- function errorInvalidSourcemapForError(error, id, column, line, pos) {
4081
+ function logInvalidSourcemapForError(error, id, column, line, pos) {
3973
4082
  return {
3974
4083
  cause: error,
3975
4084
  code: SOURCEMAP_ERROR,
@@ -3983,7 +4092,7 @@ function errorInvalidSourcemapForError(error, id, column, line, pos) {
3983
4092
  pos
3984
4093
  };
3985
4094
  }
3986
- function errorSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
4095
+ function logSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
3987
4096
  return {
3988
4097
  code: SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
3989
4098
  exporter: id,
@@ -3992,14 +4101,14 @@ function errorSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExports
3992
4101
  : 'a default export'} that does not reexport an unresolved named export of the same module.`
3993
4102
  };
3994
4103
  }
3995
- function errorThisIsUndefined() {
4104
+ function logThisIsUndefined() {
3996
4105
  return {
3997
4106
  code: THIS_IS_UNDEFINED,
3998
4107
  message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`,
3999
4108
  url: getRollupUrl(URL_THIS_IS_UNDEFINED)
4000
4109
  };
4001
4110
  }
4002
- function errorUnexpectedNamedImport(id, imported, isReexport) {
4111
+ function logUnexpectedNamedImport(id, imported, isReexport) {
4003
4112
  const importType = isReexport ? 'reexport' : 'import';
4004
4113
  return {
4005
4114
  code: UNEXPECTED_NAMED_IMPORT,
@@ -4008,7 +4117,7 @@ function errorUnexpectedNamedImport(id, imported, isReexport) {
4008
4117
  url: getRollupUrl(URL_OUTPUT_INTEROP)
4009
4118
  };
4010
4119
  }
4011
- function errorUnexpectedNamespaceReexport(id) {
4120
+ function logUnexpectedNamespaceReexport(id) {
4012
4121
  return {
4013
4122
  code: UNEXPECTED_NAMED_IMPORT,
4014
4123
  exporter: id,
@@ -4016,25 +4125,25 @@ function errorUnexpectedNamespaceReexport(id) {
4016
4125
  url: getRollupUrl(URL_OUTPUT_INTEROP)
4017
4126
  };
4018
4127
  }
4019
- function errorUnknownOption(optionType, unknownOptions, validOptions) {
4128
+ function logUnknownOption(optionType, unknownOptions, validOptions) {
4020
4129
  return {
4021
4130
  code: UNKNOWN_OPTION,
4022
4131
  message: `Unknown ${optionType}: ${unknownOptions.join(', ')}. Allowed options: ${validOptions.join(', ')}`
4023
4132
  };
4024
4133
  }
4025
- function errorEntryCannotBeExternal(unresolvedId) {
4134
+ function logEntryCannotBeExternal(unresolvedId) {
4026
4135
  return {
4027
4136
  code: UNRESOLVED_ENTRY,
4028
4137
  message: `Entry module "${relativeId(unresolvedId)}" cannot be external.`
4029
4138
  };
4030
4139
  }
4031
- function errorUnresolvedEntry(unresolvedId) {
4140
+ function logUnresolvedEntry(unresolvedId) {
4032
4141
  return {
4033
4142
  code: UNRESOLVED_ENTRY,
4034
4143
  message: `Could not resolve entry module "${relativeId(unresolvedId)}".`
4035
4144
  };
4036
4145
  }
4037
- function errorUnresolvedImport(source, importer) {
4146
+ function logUnresolvedImport(source, importer) {
4038
4147
  return {
4039
4148
  code: UNRESOLVED_IMPORT,
4040
4149
  exporter: source,
@@ -4042,7 +4151,7 @@ function errorUnresolvedImport(source, importer) {
4042
4151
  message: `Could not resolve "${source}" from "${relativeId(importer)}"`
4043
4152
  };
4044
4153
  }
4045
- function errorUnresolvedImportTreatedAsExternal(source, importer) {
4154
+ function logUnresolvedImportTreatedAsExternal(source, importer) {
4046
4155
  return {
4047
4156
  code: UNRESOLVED_IMPORT,
4048
4157
  exporter: source,
@@ -4051,7 +4160,7 @@ function errorUnresolvedImportTreatedAsExternal(source, importer) {
4051
4160
  url: getRollupUrl(URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY)
4052
4161
  };
4053
4162
  }
4054
- function errorUnusedExternalImports(externalId, names, importers) {
4163
+ function logUnusedExternalImports(externalId, names, importers) {
4055
4164
  return {
4056
4165
  code: UNUSED_EXTERNAL_IMPORT,
4057
4166
  exporter: externalId,
@@ -4063,94 +4172,23 @@ function errorUnusedExternalImports(externalId, names, importers) {
4063
4172
  names
4064
4173
  };
4065
4174
  }
4066
- function errorFailedValidation(message) {
4175
+ function logFailedValidation(message) {
4067
4176
  return {
4068
4177
  code: VALIDATION_ERROR,
4069
4178
  message
4070
4179
  };
4071
4180
  }
4072
4181
  function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
4073
- warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onwarn, options.strictDeprecations, plugin);
4182
+ warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations, plugin);
4074
4183
  }
4075
- function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, warn, strictDeprecations, plugin) {
4184
+ function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
4076
4185
  if (activeDeprecation || strictDeprecations) {
4077
- const warning = errorDeprecation(deprecation, urlSnippet, plugin);
4186
+ const warning = logDeprecation(deprecation, urlSnippet, plugin);
4078
4187
  if (strictDeprecations) {
4079
4188
  return error(warning);
4080
4189
  }
4081
- warn(warning);
4082
- }
4083
- }
4084
-
4085
- const RESERVED_NAMES = new Set([
4086
- 'await',
4087
- 'break',
4088
- 'case',
4089
- 'catch',
4090
- 'class',
4091
- 'const',
4092
- 'continue',
4093
- 'debugger',
4094
- 'default',
4095
- 'delete',
4096
- 'do',
4097
- 'else',
4098
- 'enum',
4099
- 'eval',
4100
- 'export',
4101
- 'extends',
4102
- 'false',
4103
- 'finally',
4104
- 'for',
4105
- 'function',
4106
- 'if',
4107
- 'implements',
4108
- 'import',
4109
- 'in',
4110
- 'instanceof',
4111
- 'interface',
4112
- 'let',
4113
- 'NaN',
4114
- 'new',
4115
- 'null',
4116
- 'package',
4117
- 'private',
4118
- 'protected',
4119
- 'public',
4120
- 'return',
4121
- 'static',
4122
- 'super',
4123
- 'switch',
4124
- 'this',
4125
- 'throw',
4126
- 'true',
4127
- 'try',
4128
- 'typeof',
4129
- 'undefined',
4130
- 'var',
4131
- 'void',
4132
- 'while',
4133
- 'with',
4134
- 'yield'
4135
- ]);
4136
- const RESERVED_NAMES$1 = RESERVED_NAMES;
4137
-
4138
- const illegalCharacters = /[^\w$]/g;
4139
- const startsWithDigit = (value) => /\d/.test(value[0]);
4140
- const needsEscape = (value) => startsWithDigit(value) || RESERVED_NAMES$1.has(value) || value === 'arguments';
4141
- function isLegal(value) {
4142
- if (needsEscape(value)) {
4143
- return false;
4190
+ log(LOGLEVEL_WARN, warning);
4144
4191
  }
4145
- return !illegalCharacters.test(value);
4146
- }
4147
- function makeLegal(value) {
4148
- value = value
4149
- .replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
4150
- .replace(illegalCharacters, '_');
4151
- if (needsEscape(value))
4152
- value = `_${value}`;
4153
- return value || '_';
4154
4192
  }
4155
4193
 
4156
4194
  class ExternalModule {
@@ -4235,7 +4273,7 @@ class ExternalModule {
4235
4273
  }
4236
4274
  }
4237
4275
  const importersArray = [...importersSet];
4238
- this.options.onwarn(errorUnusedExternalImports(this.id, unused, importersArray));
4276
+ this.options.onLog(LOGLEVEL_WARN, logUnusedExternalImports(this.id, unused, importersArray));
4239
4277
  }
4240
4278
  }
4241
4279
 
@@ -4763,6 +4801,7 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
4763
4801
 
4764
4802
  // AST walker module for Mozilla Parser API compatible trees
4765
4803
 
4804
+
4766
4805
  function skipThrough(node, st, c) { c(node, st); }
4767
4806
  function ignore(_node, _st, _c) {}
4768
4807
 
@@ -5032,7 +5071,10 @@ const BlockStatement$1 = 'BlockStatement';
5032
5071
  const CallExpression$1 = 'CallExpression';
5033
5072
  const ChainExpression$1 = 'ChainExpression';
5034
5073
  const ConditionalExpression$1 = 'ConditionalExpression';
5074
+ const ExportDefaultDeclaration$1 = 'ExportDefaultDeclaration';
5075
+ const ExportNamedDeclaration$1 = 'ExportNamedDeclaration';
5035
5076
  const ExpressionStatement$1 = 'ExpressionStatement';
5077
+ const FunctionDeclaration$1 = 'FunctionDeclaration';
5036
5078
  const Identifier$1 = 'Identifier';
5037
5079
  const LogicalExpression$1 = 'LogicalExpression';
5038
5080
  const NewExpression$1 = 'NewExpression';
@@ -5040,6 +5082,8 @@ const Program$1 = 'Program';
5040
5082
  const Property$1 = 'Property';
5041
5083
  const ReturnStatement$1 = 'ReturnStatement';
5042
5084
  const SequenceExpression$1 = 'SequenceExpression';
5085
+ const VariableDeclarator$1 = 'VariableDeclarator';
5086
+ const VariableDeclaration$1 = 'VariableDeclaration';
5043
5087
 
5044
5088
  // this looks ridiculous, but it prevents sourcemap tooling from mistaking
5045
5089
  // this for an actual sourceMappingURL
@@ -5111,6 +5155,28 @@ function markPureNode(node, comment, code) {
5111
5155
  invalidAnnotation = true;
5112
5156
  break;
5113
5157
  }
5158
+ case ExportNamedDeclaration$1:
5159
+ case ExportDefaultDeclaration$1: {
5160
+ node = node.declaration;
5161
+ continue;
5162
+ }
5163
+ case VariableDeclaration$1: {
5164
+
5165
+ const declaration = node;
5166
+ if (declaration.kind === 'const') {
5167
+ // jsdoc only applies to the first declaration
5168
+ node = declaration.declarations[0].init;
5169
+ continue;
5170
+ }
5171
+ invalidAnnotation = true;
5172
+ break;
5173
+ }
5174
+ case VariableDeclarator$1: {
5175
+ node = node.init;
5176
+ continue;
5177
+ }
5178
+ case FunctionDeclaration$1:
5179
+ case ArrowFunctionExpression$1:
5114
5180
  case CallExpression$1:
5115
5181
  case NewExpression$1: {
5116
5182
  break;
@@ -5153,15 +5219,20 @@ function doesNotMatchOutsideComment(code, forbiddenChars) {
5153
5219
  }
5154
5220
  return true;
5155
5221
  }
5156
- const pureCommentRegex = /[#@]__PURE__/;
5222
+ const annotationsRegexes = [
5223
+ ['pure', /[#@]__PURE__/],
5224
+ ['noSideEffects', /[#@]__NO_SIDE_EFFECTS__/]
5225
+ ];
5157
5226
  function addAnnotations(comments, esTreeAst, code) {
5158
5227
  const annotations = [];
5159
5228
  const sourceMappingComments = [];
5160
5229
  for (const comment of comments) {
5161
- if (pureCommentRegex.test(comment.value)) {
5162
- annotations.push(comment);
5230
+ for (const [annotationType, regex] of annotationsRegexes) {
5231
+ if (regex.test(comment.value)) {
5232
+ annotations.push({ ...comment, annotationType });
5233
+ }
5163
5234
  }
5164
- else if (SOURCEMAPPING_URL_RE.test(comment.value)) {
5235
+ if (SOURCEMAPPING_URL_RE.test(comment.value)) {
5165
5236
  sourceMappingComments.push(comment);
5166
5237
  }
5167
5238
  }
@@ -5305,7 +5376,12 @@ class NodeBase extends ExpressionEntity {
5305
5376
  continue;
5306
5377
  if (key.charCodeAt(0) === 95 /* _ */) {
5307
5378
  if (key === ANNOTATION_KEY) {
5308
- this.annotations = value;
5379
+ const annotations = value;
5380
+ this.annotations = annotations;
5381
+ if (this.context.options.treeshake.annotations) {
5382
+ this.annotationNoSideEffects = annotations.some(comment => comment.annotationType === 'noSideEffects');
5383
+ this.annotationPure = annotations.some(comment => comment.annotationType === 'pure');
5384
+ }
5309
5385
  }
5310
5386
  else if (key === INVALID_COMMENT_KEY) {
5311
5387
  for (const { start, end } of value)
@@ -6648,6 +6724,13 @@ const IMPURE = {
6648
6724
  getLiteralValue: getTruthyLiteralValue,
6649
6725
  hasEffectsWhenCalled: returnTrue
6650
6726
  };
6727
+ const PURE_WITH_ARRAY = {
6728
+ deoptimizeArgumentsOnCall: doNothing,
6729
+ getLiteralValue: getTruthyLiteralValue,
6730
+ hasEffectsWhenCalled({ args }) {
6731
+ return args.length > 1 && !(args[1] instanceof ArrayExpression);
6732
+ }
6733
+ };
6651
6734
  // We use shortened variables to reduce file size here
6652
6735
  /* OBJECT */
6653
6736
  const O = {
@@ -6685,6 +6768,11 @@ const PC = {
6685
6768
  [ValueProperties]: PURE,
6686
6769
  prototype: O
6687
6770
  };
6771
+ const PC_WITH_ARRAY = {
6772
+ __proto__: null,
6773
+ [ValueProperties]: PURE_WITH_ARRAY,
6774
+ prototype: O
6775
+ };
6688
6776
  const ARRAY_TYPE = {
6689
6777
  __proto__: null,
6690
6778
  [ValueProperties]: PURE,
@@ -6755,7 +6843,7 @@ const knownGlobals = {
6755
6843
  isNaN: PF,
6756
6844
  isPrototypeOf: O,
6757
6845
  JSON: O,
6758
- Map: C,
6846
+ Map: PC_WITH_ARRAY,
6759
6847
  Math: {
6760
6848
  __proto__: null,
6761
6849
  [ValueProperties]: IMPURE,
@@ -6851,7 +6939,7 @@ const knownGlobals = {
6851
6939
  ReferenceError: PC,
6852
6940
  Reflect: O,
6853
6941
  RegExp: PC,
6854
- Set: C,
6942
+ Set: PC_WITH_ARRAY,
6855
6943
  SharedArrayBuffer: C,
6856
6944
  String: {
6857
6945
  __proto__: null,
@@ -6891,8 +6979,8 @@ const knownGlobals = {
6891
6979
  unescape: PF,
6892
6980
  URIError: PC,
6893
6981
  valueOf: O,
6894
- WeakMap: C,
6895
- WeakSet: C,
6982
+ WeakMap: PC_WITH_ARRAY,
6983
+ WeakSet: PC_WITH_ARRAY,
6896
6984
  // Additional globals shared by Node and Browser that are not strictly part of the language
6897
6985
  clearInterval: C,
6898
6986
  clearTimeout: C,
@@ -7769,7 +7857,7 @@ class Identifier extends NodeBase {
7769
7857
  }
7770
7858
  }
7771
7859
  disallowImportReassignment() {
7772
- return this.context.error(errorIllegalImportReassignment(this.name, this.context.module.id), this.start);
7860
+ return this.context.error(logIllegalImportReassignment(this.name, this.context.module.id), this.start);
7773
7861
  }
7774
7862
  getVariableRespectingTDZ() {
7775
7863
  if (this.isPossibleTDZ()) {
@@ -7977,9 +8065,9 @@ class ExpressionStatement extends NodeBase {
7977
8065
  if (this.directive &&
7978
8066
  this.directive !== 'use strict' &&
7979
8067
  this.parent.type === Program$1) {
7980
- this.context.warn(
8068
+ this.context.log(LOGLEVEL_WARN,
7981
8069
  // This is necessary, because either way (deleting or not) can lead to errors.
7982
- errorModuleLevelDirective(this.directive, this.context.module.id), this.start);
8070
+ logModuleLevelDirective(this.directive, this.context.module.id), this.start);
7983
8071
  }
7984
8072
  }
7985
8073
  render(code, options) {
@@ -8145,6 +8233,9 @@ class FunctionBase extends NodeBase {
8145
8233
  if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
8146
8234
  return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
8147
8235
  }
8236
+ if (this.annotationNoSideEffects) {
8237
+ return false;
8238
+ }
8148
8239
  if (this.async) {
8149
8240
  const { propertyReadSideEffects } = this.context.options
8150
8241
  .treeshake;
@@ -8208,8 +8299,12 @@ class ArrowFunctionExpression extends FunctionBase {
8208
8299
  return false;
8209
8300
  }
8210
8301
  hasEffectsOnInteractionAtPath(path, interaction, context) {
8211
- if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
8302
+ if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) {
8212
8303
  return true;
8304
+ }
8305
+ if (this.annotationNoSideEffects) {
8306
+ return false;
8307
+ }
8213
8308
  if (interaction.type === INTERACTION_CALLED) {
8214
8309
  const { ignore, brokenFlow } = context;
8215
8310
  context.ignore = {
@@ -8515,11 +8610,17 @@ class FunctionNode extends FunctionBase {
8515
8610
  hasEffects(context) {
8516
8611
  if (!this.deoptimized)
8517
8612
  this.applyDeoptimizations();
8613
+ if (this.annotationNoSideEffects) {
8614
+ return false;
8615
+ }
8518
8616
  return !!this.id?.hasEffects(context);
8519
8617
  }
8520
8618
  hasEffectsOnInteractionAtPath(path, interaction, context) {
8521
8619
  if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
8522
8620
  return true;
8621
+ if (this.annotationNoSideEffects) {
8622
+ return false;
8623
+ }
8523
8624
  if (interaction.type === INTERACTION_CALLED) {
8524
8625
  const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
8525
8626
  context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew ? this.constructedEntity : UNKNOWN_EXPRESSION);
@@ -9015,7 +9116,7 @@ class MemberExpression extends NodeBase {
9015
9116
  if (this.variable) {
9016
9117
  this.context.includeVariableInModule(this.variable);
9017
9118
  }
9018
- this.context.warn(errorIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
9119
+ this.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
9019
9120
  }
9020
9121
  }
9021
9122
  }
@@ -9061,7 +9162,7 @@ function resolveNamespaceVariables(baseVariable, path, astContext) {
9061
9162
  if (!variable) {
9062
9163
  if (path.length === 1) {
9063
9164
  const fileName = baseVariable.context.fileName;
9064
- astContext.warn(errorMissingExport(exportName, astContext.module.id, fileName), path[0].pos);
9165
+ astContext.log(LOGLEVEL_WARN, logMissingExport(exportName, astContext.module.id, fileName), path[0].pos);
9065
9166
  return 'undefined';
9066
9167
  }
9067
9168
  return null;
@@ -9168,10 +9269,10 @@ class CallExpression extends CallExpressionBase {
9168
9269
  if (this.callee instanceof Identifier) {
9169
9270
  const variable = this.scope.findVariable(this.callee.name);
9170
9271
  if (variable.isNamespace) {
9171
- this.context.warn(errorCannotCallNamespace(this.callee.name), this.start);
9272
+ this.context.log(LOGLEVEL_WARN, logCannotCallNamespace(this.callee.name), this.start);
9172
9273
  }
9173
9274
  if (this.callee.name === 'eval') {
9174
- this.context.warn(errorEval(this.context.module.id), this.start);
9275
+ this.context.log(LOGLEVEL_WARN, logEval(this.context.module.id), this.start);
9175
9276
  }
9176
9277
  }
9177
9278
  this.interaction = {
@@ -9191,9 +9292,9 @@ class CallExpression extends CallExpressionBase {
9191
9292
  if (argument.hasEffects(context))
9192
9293
  return true;
9193
9294
  }
9194
- if (this.context.options.treeshake.annotations &&
9195
- this.annotations)
9295
+ if (this.annotationPure) {
9196
9296
  return false;
9297
+ }
9197
9298
  return (this.callee.hasEffects(context) ||
9198
9299
  this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
9199
9300
  }
@@ -11164,8 +11265,7 @@ class NewExpression extends NodeBase {
11164
11265
  if (argument.hasEffects(context))
11165
11266
  return true;
11166
11267
  }
11167
- if (this.context.options.treeshake.annotations &&
11168
- this.annotations) {
11268
+ if (this.annotationPure) {
11169
11269
  return false;
11170
11270
  }
11171
11271
  return (this.callee.hasEffects(context) ||
@@ -11285,29 +11385,6 @@ class ObjectExpression extends NodeBase {
11285
11385
  class PrivateIdentifier extends NodeBase {
11286
11386
  }
11287
11387
 
11288
- function getOriginalLocation(sourcemapChain, location) {
11289
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
11290
- traceSourcemap: while (filteredSourcemapChain.length > 0) {
11291
- const sourcemap = filteredSourcemapChain.pop();
11292
- const line = sourcemap.mappings[location.line - 1];
11293
- if (line) {
11294
- const filteredLine = line.filter((segment) => segment.length > 1);
11295
- const lastSegment = filteredLine[filteredLine.length - 1];
11296
- for (const segment of filteredLine) {
11297
- if (segment[0] >= location.column || segment === lastSegment) {
11298
- location = {
11299
- column: segment[3],
11300
- line: segment[2] + 1
11301
- };
11302
- continue traceSourcemap;
11303
- }
11304
- }
11305
- }
11306
- throw new Error("Can't resolve original location of error.");
11307
- }
11308
- return location;
11309
- }
11310
-
11311
11388
  class Program extends NodeBase {
11312
11389
  constructor() {
11313
11390
  super(...arguments);
@@ -11327,19 +11404,8 @@ class Program extends NodeBase {
11327
11404
  if (node.hasEffects(context)) {
11328
11405
  if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
11329
11406
  this.hasLoggedEffect = true;
11330
- const { code, module } = this.context;
11331
- const { line, column } = locate(code, node.start, { offsetLine: 1 });
11332
- console.log(`First side effect in ${relativeId(module.id)} is at (${line}:${column})\n${getCodeFrame(code, line, column)}`);
11333
- try {
11334
- const { column: originalColumn, line: originalLine } = getOriginalLocation(module.sourcemapChain, { column, line });
11335
- if (originalLine !== line) {
11336
- console.log(`Original location is at (${originalLine}:${originalColumn})\n${getCodeFrame(module.originalCode, originalLine, originalColumn)}\n`);
11337
- }
11338
- }
11339
- catch {
11340
- /* ignored */
11341
- }
11342
- console.log();
11407
+ const { code, log, module } = this.context;
11408
+ log(LOGLEVEL_INFO, logFirstSideEffect(code, module.id, locate(code, node.start, { offsetLine: 1 })), node.start);
11343
11409
  }
11344
11410
  return (this.hasCachedEffect = true);
11345
11411
  }
@@ -11361,6 +11427,14 @@ class Program extends NodeBase {
11361
11427
  code.remove(0, start);
11362
11428
  }
11363
11429
  if (this.body.length > 0) {
11430
+ // Keep all consecutive lines that start with a comment
11431
+ while (code.original[start] === '/' && /[*/]/.test(code.original[start + 1])) {
11432
+ const firstLineBreak = findFirstLineBreakOutsideComment(code.original.slice(start, this.body[0].start));
11433
+ if (firstLineBreak[0] === -1) {
11434
+ break;
11435
+ }
11436
+ start += firstLineBreak[1];
11437
+ }
11364
11438
  renderStatementList(this.body, code, start, this.end, options);
11365
11439
  }
11366
11440
  else {
@@ -11604,6 +11678,7 @@ SwitchCase.prototype.needsBoundaries = true;
11604
11678
 
11605
11679
  class SwitchStatement extends NodeBase {
11606
11680
  createScope(parentScope) {
11681
+ this.parentScope = parentScope;
11607
11682
  this.scope = new BlockScope(parentScope);
11608
11683
  }
11609
11684
  hasEffects(context) {
@@ -11672,6 +11747,10 @@ class SwitchStatement extends NodeBase {
11672
11747
  }
11673
11748
  this.defaultCase = null;
11674
11749
  }
11750
+ parseNode(esTreeNode) {
11751
+ this.discriminant = new (this.context.getNodeConstructor(esTreeNode.discriminant.type))(esTreeNode.discriminant, this, this.parentScope);
11752
+ super.parseNode(esTreeNode);
11753
+ }
11675
11754
  render(code, options) {
11676
11755
  this.discriminant.render(code, options);
11677
11756
  if (this.cases.length > 0) {
@@ -11687,7 +11766,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
11687
11766
  const name = this.tag.name;
11688
11767
  const variable = this.scope.findVariable(name);
11689
11768
  if (variable.isNamespace) {
11690
- this.context.warn(errorCannotCallNamespace(name), this.start);
11769
+ this.context.log(LOGLEVEL_WARN, logCannotCallNamespace(name), this.start);
11691
11770
  }
11692
11771
  }
11693
11772
  }
@@ -11934,7 +12013,7 @@ class ThisExpression extends NodeBase {
11934
12013
  this.alias =
11935
12014
  this.scope.findLexicalBoundary() instanceof ModuleScope ? this.context.moduleContext : null;
11936
12015
  if (this.alias === 'undefined') {
11937
- this.context.warn(errorThisIsUndefined(), this.start);
12016
+ this.context.log(LOGLEVEL_WARN, logThisIsUndefined(), this.start);
11938
12017
  }
11939
12018
  }
11940
12019
  render(code) {
@@ -12478,14 +12557,14 @@ class NamespaceVariable extends Variable {
12478
12557
  const memberVariables = this.getMemberVariables();
12479
12558
  const members = Object.entries(memberVariables)
12480
12559
  .filter(([_, variable]) => variable.included)
12481
- .map(([name, original]) => {
12482
- if (this.referencedEarly || original.isReassigned) {
12560
+ .map(([name, variable]) => {
12561
+ if (this.referencedEarly || variable.isReassigned || variable === this) {
12483
12562
  return [
12484
12563
  null,
12485
- `get ${name}${_}()${_}{${_}return ${original.getName(getPropertyAccess)}${s}${_}}`
12564
+ `get ${name}${_}()${_}{${_}return ${variable.getName(getPropertyAccess)}${s}${_}}`
12486
12565
  ];
12487
12566
  }
12488
- return [name, original.getName(getPropertyAccess)];
12567
+ return [name, variable.getName(getPropertyAccess)];
12489
12568
  });
12490
12569
  members.unshift([null, `__proto__:${_}null`]);
12491
12570
  let output = getObject(members, { lineBreakIndent: { base: '', t } });
@@ -12577,6 +12656,29 @@ function getId(m) {
12577
12656
  return m.id;
12578
12657
  }
12579
12658
 
12659
+ function getOriginalLocation(sourcemapChain, location) {
12660
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
12661
+ traceSourcemap: while (filteredSourcemapChain.length > 0) {
12662
+ const sourcemap = filteredSourcemapChain.pop();
12663
+ const line = sourcemap.mappings[location.line - 1];
12664
+ if (line) {
12665
+ const filteredLine = line.filter((segment) => segment.length > 1);
12666
+ const lastSegment = filteredLine[filteredLine.length - 1];
12667
+ for (const segment of filteredLine) {
12668
+ if (segment[0] >= location.column || segment === lastSegment) {
12669
+ location = {
12670
+ column: segment[3],
12671
+ line: segment[2] + 1
12672
+ };
12673
+ continue traceSourcemap;
12674
+ }
12675
+ }
12676
+ }
12677
+ throw new Error("Can't resolve original location of error.");
12678
+ }
12679
+ return location;
12680
+ }
12681
+
12580
12682
  function getAssertionsFromImportExpression(node) {
12581
12683
  const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
12582
12684
  if (!assertProperty) {
@@ -12753,7 +12855,7 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
12753
12855
  const searchedModules = searchedNamesAndModules.get(name);
12754
12856
  if (searchedModules) {
12755
12857
  if (searchedModules.has(target)) {
12756
- return isExportAllSearch ? [null] : error(errorCircularReexport(name, target.id));
12858
+ return isExportAllSearch ? [null] : error(logCircularReexport(name, target.id));
12757
12859
  }
12758
12860
  searchedModules.add(target);
12759
12861
  }
@@ -12936,6 +13038,16 @@ class Module {
12936
13038
  this.addLocationToLogProps(properties, pos);
12937
13039
  return error(properties);
12938
13040
  }
13041
+ // sum up the length of all ast nodes that are included
13042
+ estimateSize() {
13043
+ let size = 0;
13044
+ for (const node of this.ast.body) {
13045
+ if (node.included) {
13046
+ size += node.end - node.start;
13047
+ }
13048
+ }
13049
+ return size;
13050
+ }
12939
13051
  getAllExportNames() {
12940
13052
  if (this.allExportNames) {
12941
13053
  return this.allExportNames;
@@ -13069,7 +13181,7 @@ class Module {
13069
13181
  : 'default', { onlyExplicit: true });
13070
13182
  }
13071
13183
  if (!this.syntheticNamespace) {
13072
- return error(errorSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports));
13184
+ return error(logSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports));
13073
13185
  }
13074
13186
  return this.syntheticNamespace;
13075
13187
  }
@@ -13088,7 +13200,7 @@ class Module {
13088
13200
  if (reexportDeclaration) {
13089
13201
  const [variable] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules);
13090
13202
  if (!variable) {
13091
- return this.error(errorMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
13203
+ return this.error(logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
13092
13204
  }
13093
13205
  if (importerForSideEffects) {
13094
13206
  setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
@@ -13205,7 +13317,11 @@ class Module {
13205
13317
  isIncluded() {
13206
13318
  // Modules where this.ast is missing have been loaded via this.load and are
13207
13319
  // not yet fully processed, hence they cannot be included.
13208
- return (this.ast && (this.ast.included || this.namespace.included || this.importedFromNotTreeshaken));
13320
+ return (this.ast &&
13321
+ (this.ast.included ||
13322
+ this.namespace.included ||
13323
+ this.importedFromNotTreeshaken ||
13324
+ this.exportShimVariable.included));
13209
13325
  }
13210
13326
  linkImports() {
13211
13327
  this.addModulesToImportDescriptions(this.importDescriptions);
@@ -13221,13 +13337,17 @@ class Module {
13221
13337
  }
13222
13338
  this.exportAllModules.push(...externalExportAllModules);
13223
13339
  }
13340
+ log(level, properties, pos) {
13341
+ this.addLocationToLogProps(properties, pos);
13342
+ this.options.onLog(level, properties);
13343
+ }
13224
13344
  render(options) {
13225
13345
  const source = this.magicString.clone();
13226
13346
  this.ast.render(source, options);
13227
13347
  source.trim();
13228
13348
  const { usesTopLevelAwait } = this.astContext;
13229
13349
  if (usesTopLevelAwait && options.format !== 'es' && options.format !== 'system') {
13230
- return error(errorInvalidFormatForTopLevelAwait(this.id, options.format));
13350
+ return error(logInvalidFormatForTopLevelAwait(this.id, options.format));
13231
13351
  }
13232
13352
  return { source, usesTopLevelAwait };
13233
13353
  }
@@ -13272,6 +13392,7 @@ class Module {
13272
13392
  includeAllExports: () => this.includeAllExports(true),
13273
13393
  includeDynamicImport: this.includeDynamicImport.bind(this),
13274
13394
  includeVariableInModule: this.includeVariableInModule.bind(this),
13395
+ log: this.log.bind(this),
13275
13396
  magicString: this.magicString,
13276
13397
  manualPureFunctions: this.graph.pureFunctions,
13277
13398
  module: this,
@@ -13280,8 +13401,7 @@ class Module {
13280
13401
  requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
13281
13402
  traceExport: (name) => this.getVariableForExportName(name)[0],
13282
13403
  traceVariable: this.traceVariable.bind(this),
13283
- usesTopLevelAwait: false,
13284
- warn: this.warn.bind(this)
13404
+ usesTopLevelAwait: false
13285
13405
  };
13286
13406
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
13287
13407
  this.namespace = new NamespaceVariable(this.astContext);
@@ -13341,7 +13461,7 @@ class Module {
13341
13461
  }
13342
13462
  const [declaration] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);
13343
13463
  if (!declaration) {
13344
- return this.error(errorMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13464
+ return this.error(logMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13345
13465
  }
13346
13466
  return declaration;
13347
13467
  }
@@ -13358,10 +13478,6 @@ class Module {
13358
13478
  Object.assign(this.info.meta, meta);
13359
13479
  }
13360
13480
  }
13361
- warn(properties, pos) {
13362
- this.addLocationToLogProps(properties, pos);
13363
- this.options.onwarn(properties);
13364
- }
13365
13481
  addDynamicImport(node) {
13366
13482
  let argument = node.source;
13367
13483
  if (argument instanceof TemplateLiteral) {
@@ -13475,7 +13591,7 @@ class Module {
13475
13591
  code = this.originalCode;
13476
13592
  }
13477
13593
  catch (error_) {
13478
- this.options.onwarn(errorInvalidSourcemapForError(error_, this.id, column, line, pos));
13594
+ this.options.onLog(LOGLEVEL_WARN, logInvalidSourcemapForError(error_, this.id, column, line, pos));
13479
13595
  }
13480
13596
  augmentCodeLocation(properties, { column, line }, code, this.id);
13481
13597
  }
@@ -13516,7 +13632,7 @@ class Module {
13516
13632
  const existingAssertions = this.sourcesWithAssertions.get(source);
13517
13633
  if (existingAssertions) {
13518
13634
  if (doAssertionsDiffer(existingAssertions, parsedAssertions)) {
13519
- this.warn(errorInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
13635
+ this.log(LOGLEVEL_WARN, logInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
13520
13636
  }
13521
13637
  }
13522
13638
  else {
@@ -13554,7 +13670,7 @@ class Module {
13554
13670
  if (foundDeclarationList.length === 1) {
13555
13671
  return [usedDeclaration];
13556
13672
  }
13557
- this.options.onwarn(errorNamespaceConflict(name, this.id, foundDeclarationList.map(([, module]) => module.id)));
13673
+ this.options.onLog(LOGLEVEL_WARN, logNamespaceConflict(name, this.id, foundDeclarationList.map(([, module]) => module.id)));
13558
13674
  // TODO we are pretending it was not found while it should behave like "undefined"
13559
13675
  return [null];
13560
13676
  }
@@ -13562,7 +13678,7 @@ class Module {
13562
13678
  const foundDeclarationList = [...foundExternalDeclarations];
13563
13679
  const usedDeclaration = foundDeclarationList[0];
13564
13680
  if (foundDeclarationList.length > 1) {
13565
- this.options.onwarn(errorAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
13681
+ this.options.onLog(LOGLEVEL_WARN, logAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
13566
13682
  }
13567
13683
  return [usedDeclaration, true];
13568
13684
  }
@@ -13606,10 +13722,15 @@ class Module {
13606
13722
  }
13607
13723
  }
13608
13724
  includeVariable(variable) {
13609
- if (!variable.included) {
13725
+ const variableModule = variable.module;
13726
+ if (variable.included) {
13727
+ if (variableModule instanceof Module && variableModule !== this) {
13728
+ getAndExtendSideEffectModules(variable, this);
13729
+ }
13730
+ }
13731
+ else {
13610
13732
  variable.include();
13611
13733
  this.graph.needsTreeshakingPass = true;
13612
- const variableModule = variable.module;
13613
13734
  if (variableModule instanceof Module) {
13614
13735
  if (!variableModule.isExecuted) {
13615
13736
  markModuleAndImpureDependenciesAsExecuted(variableModule);
@@ -13633,7 +13754,7 @@ class Module {
13633
13754
  }
13634
13755
  }
13635
13756
  shimMissingExport(name) {
13636
- this.options.onwarn(errorShimmedExport(this.id, name));
13757
+ this.options.onLog(LOGLEVEL_WARN, logShimmedExport(this.id, name));
13637
13758
  this.exports.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
13638
13759
  }
13639
13760
  tryParse() {
@@ -13641,7 +13762,7 @@ class Module {
13641
13762
  return this.graph.contextParse(this.info.code);
13642
13763
  }
13643
13764
  catch (error_) {
13644
- return this.error(errorParseError(error_, this.id), error_.pos);
13765
+ return this.error(logParseError(error_, this.id), error_.pos);
13645
13766
  }
13646
13767
  }
13647
13768
  }
@@ -13942,17 +14063,17 @@ const nodeBuiltins = new Set([
13942
14063
  'timers/promises',
13943
14064
  'util/types'
13944
14065
  ]);
13945
- function warnOnBuiltins(warn, dependencies) {
14066
+ function warnOnBuiltins(log, dependencies) {
13946
14067
  const externalBuiltins = dependencies
13947
14068
  .map(({ importPath }) => importPath)
13948
14069
  .filter(importPath => nodeBuiltins.has(importPath) || importPath.startsWith('node:'));
13949
14070
  if (externalBuiltins.length === 0)
13950
14071
  return;
13951
- warn(errorMissingNodeBuiltins(externalBuiltins));
14072
+ log(LOGLEVEL_WARN, logMissingNodeBuiltins(externalBuiltins));
13952
14073
  }
13953
14074
 
13954
- function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
13955
- warnOnBuiltins(onwarn, dependencies);
14075
+ function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, log, outro, snippets }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
14076
+ warnOnBuiltins(log, dependencies);
13956
14077
  const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
13957
14078
  const parameters = dependencies.map(m => m.name);
13958
14079
  const { n, getNonArrowFunctionIntro, _ } = snippets;
@@ -14177,19 +14298,19 @@ function trimEmptyImports(dependencies) {
14177
14298
  return [];
14178
14299
  }
14179
14300
 
14180
- function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
14301
+ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, log, outro, snippets }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
14181
14302
  const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
14182
14303
  const isNamespaced = name && name.includes('.');
14183
14304
  const useVariableAssignment = !extend && !isNamespaced;
14184
14305
  if (name && useVariableAssignment && !isLegal(name)) {
14185
- return error(errorIllegalIdentifierAsName(name));
14306
+ return error(logIllegalIdentifierAsName(name));
14186
14307
  }
14187
- warnOnBuiltins(onwarn, dependencies);
14308
+ warnOnBuiltins(log, dependencies);
14188
14309
  const external = trimEmptyImports(dependencies);
14189
14310
  const deps = external.map(dep => dep.globalName || 'null');
14190
14311
  const parameters = external.map(m => m.name);
14191
14312
  if (hasExports && !name) {
14192
- onwarn(errorMissingNameOptionForIifeExport());
14313
+ log(LOGLEVEL_WARN, logMissingNameOptionForIifeExport());
14193
14314
  }
14194
14315
  if (namedExportsMode && hasExports) {
14195
14316
  if (extend) {
@@ -14381,14 +14502,14 @@ function safeAccess(name, globalVariable, { _, getPropertyAccess }) {
14381
14502
  .map(part => (propertyPath += getPropertyAccess(part)))
14382
14503
  .join(`${_}&&${_}`);
14383
14504
  }
14384
- function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
14505
+ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, log, outro, snippets }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
14385
14506
  const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
14386
14507
  const factoryVariable = compact ? 'f' : 'factory';
14387
14508
  const globalVariable = compact ? 'g' : 'global';
14388
14509
  if (hasExports && !name) {
14389
- return error(errorMissingNameOptionForUmdExport());
14510
+ return error(logMissingNameOptionForUmdExport());
14390
14511
  }
14391
- warnOnBuiltins(onwarn, dependencies);
14512
+ warnOnBuiltins(log, dependencies);
14392
14513
  const amdDeps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
14393
14514
  const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
14394
14515
  const trimmedImports = trimEmptyImports(dependencies);
@@ -14498,7 +14619,7 @@ async function createAddons(options, outputPluginDriver, chunk) {
14498
14619
  return { banner, footer, intro, outro };
14499
14620
  }
14500
14621
  catch (error_) {
14501
- return error(errorAddonNotGenerated(error_.message, error_.hook, error_.plugin));
14622
+ return error(logAddonNotGenerated(error_.message, error_.hook, error_.plugin));
14502
14623
  }
14503
14624
  }
14504
14625
 
@@ -14651,15 +14772,15 @@ function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
14651
14772
  }
14652
14773
  }
14653
14774
 
14654
- function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, warn) {
14775
+ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, log) {
14655
14776
  const exportKeys = chunk.getExportNames();
14656
14777
  if (exportMode === 'default') {
14657
14778
  if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
14658
- return error(errorIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
14779
+ return error(logIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
14659
14780
  }
14660
14781
  }
14661
14782
  else if (exportMode === 'none' && exportKeys.length > 0) {
14662
- return error(errorIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
14783
+ return error(logIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
14663
14784
  }
14664
14785
  if (exportMode === 'auto') {
14665
14786
  if (exportKeys.length === 0) {
@@ -14670,7 +14791,7 @@ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModul
14670
14791
  }
14671
14792
  else {
14672
14793
  if (format !== 'es' && format !== 'system' && exportKeys.includes('default')) {
14673
- warn(errorMixedExport(facadeModuleId, name));
14794
+ log(LOGLEVEL_WARN, logMixedExport(facadeModuleId, name));
14674
14795
  }
14675
14796
  exportMode = 'named';
14676
14797
  }
@@ -14747,7 +14868,8 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
14747
14868
  }
14748
14869
  }
14749
14870
 
14750
- // Four random characters from the private use area to minimize risk of conflicts
14871
+ // Four random characters from the private use area to minimize risk of
14872
+ // conflicts
14751
14873
  const hashPlaceholderLeft = '!~{';
14752
14874
  const hashPlaceholderRight = '}~';
14753
14875
  const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
@@ -14758,11 +14880,11 @@ const getHashPlaceholderGenerator = () => {
14758
14880
  let nextIndex = 0;
14759
14881
  return (optionName, hashSize = defaultHashSize) => {
14760
14882
  if (hashSize > maxHashSize) {
14761
- return error(errorFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
14883
+ return error(logFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
14762
14884
  }
14763
14885
  const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
14764
14886
  if (placeholder.length > hashSize) {
14765
- return error(errorFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
14887
+ return error(logFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
14766
14888
  }
14767
14889
  return placeholder;
14768
14890
  };
@@ -14829,14 +14951,14 @@ const removeUnreferencedAssets = (outputBundle) => {
14829
14951
 
14830
14952
  function renderNamePattern(pattern, patternName, replacements) {
14831
14953
  if (isPathFragment(pattern))
14832
- return error(errorFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
14954
+ return error(logFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
14833
14955
  return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
14834
14956
  if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
14835
- return error(errorFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
14957
+ return error(logFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
14836
14958
  }
14837
14959
  const replacement = replacements[type](size && Number.parseInt(size.slice(1)));
14838
14960
  if (isPathFragment(replacement))
14839
- return error(errorFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
14961
+ return error(logFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
14840
14962
  return replacement;
14841
14963
  });
14842
14964
  }
@@ -14861,13 +14983,13 @@ const NON_ASSET_EXTENSIONS = new Set([
14861
14983
  '.cjs',
14862
14984
  '.cts'
14863
14985
  ]);
14864
- function getGlobalName(chunk, globals, hasExports, warn) {
14986
+ function getGlobalName(chunk, globals, hasExports, log) {
14865
14987
  const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
14866
14988
  if (globalName) {
14867
14989
  return globalName;
14868
14990
  }
14869
14991
  if (hasExports) {
14870
- warn(errorMissingGlobalName(chunk.id, chunk.variableName));
14992
+ log(LOGLEVEL_WARN, logMissingGlobalName(chunk.id, chunk.variableName));
14871
14993
  return chunk.variableName;
14872
14994
  }
14873
14995
  }
@@ -14969,13 +15091,18 @@ class Chunk {
14969
15091
  }
14970
15092
  canModuleBeFacade(module, exposedVariables) {
14971
15093
  const moduleExportNamesByVariable = module.getExportNamesByVariable();
15094
+ // All exports of this chunk need to be exposed by the candidate module
14972
15095
  for (const exposedVariable of this.exports) {
14973
15096
  if (!moduleExportNamesByVariable.has(exposedVariable)) {
14974
15097
  return false;
14975
15098
  }
14976
15099
  }
15100
+ // Additionally, we need to expose namespaces of dynamic entries that are not the facade module and exports from other entry modules
14977
15101
  for (const exposedVariable of exposedVariables) {
14978
- if (!(moduleExportNamesByVariable.has(exposedVariable) || exposedVariable.module === module)) {
15102
+ if (!(exposedVariable.module === module ||
15103
+ moduleExportNamesByVariable.has(exposedVariable) ||
15104
+ (exposedVariable instanceof SyntheticNamedExportVariable &&
15105
+ moduleExportNamesByVariable.has(exposedVariable.getBaseVariable())))) {
14979
15106
  return false;
14980
15107
  }
14981
15108
  }
@@ -15021,7 +15148,7 @@ class Chunk {
15021
15148
  assignExportsToNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
15022
15149
  }
15023
15150
  if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.info.isEntry))
15024
- this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
15151
+ this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onLog);
15025
15152
  }
15026
15153
  generateFacades() {
15027
15154
  const facades = [];
@@ -15030,7 +15157,10 @@ class Chunk {
15030
15157
  for (const module of entryModules) {
15031
15158
  if (module.preserveSignature) {
15032
15159
  for (const exportedVariable of module.getExportNamesByVariable().keys()) {
15033
- exposedVariables.add(exportedVariable);
15160
+ // We need to expose all entry exports from this chunk
15161
+ if (this.chunkByModule.get(exportedVariable.module) === this) {
15162
+ exposedVariables.add(exportedVariable);
15163
+ }
15034
15164
  }
15035
15165
  }
15036
15166
  }
@@ -15166,7 +15296,7 @@ class Chunk {
15166
15296
  }
15167
15297
  }
15168
15298
  async render() {
15169
- const { dependencies, exportMode, facadeModule, inputOptions: { onwarn }, outputOptions, pluginDriver, snippets } = this;
15299
+ const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
15170
15300
  const { format, hoistTransitiveImports, preserveModules } = outputOptions;
15171
15301
  // for static and dynamic entry points, add transitive dependencies to this
15172
15302
  // chunk's dependencies to avoid loading latency
@@ -15216,8 +15346,8 @@ class Chunk {
15216
15346
  intro,
15217
15347
  isEntryFacade: preserveModules || (facadeModule !== null && facadeModule.info.isEntry),
15218
15348
  isModuleFacade: facadeModule !== null,
15349
+ log: onLog,
15219
15350
  namedExportsMode: exportMode !== 'default',
15220
- onwarn,
15221
15351
  outro,
15222
15352
  snippets,
15223
15353
  usesTopLevelAwait
@@ -15272,7 +15402,7 @@ class Chunk {
15272
15402
  if (alternativeReexportModule) {
15273
15403
  const exportingChunk = this.chunkByModule.get(alternativeReexportModule);
15274
15404
  if (exportingChunk !== exportChunk) {
15275
- this.inputOptions.onwarn(errorCyclicCrossChunkReexport(
15405
+ this.inputOptions.onLog(LOGLEVEL_WARN, logCyclicCrossChunkReexport(
15276
15406
  // Namespaces do not have an export name
15277
15407
  variableModule.getExportNamesByVariable().get(variable)?.[0] || '*', variableModule.id, alternativeReexportModule.id, importingModule.id, this.outputOptions.preserveModules));
15278
15408
  }
@@ -15460,7 +15590,7 @@ class Chunk {
15460
15590
  dependency = this.externalChunkByModule.get(module);
15461
15591
  imported = variable.name;
15462
15592
  if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
15463
- return error(errorUnexpectedNamedImport(module.id, imported, false));
15593
+ return error(logUnexpectedNamedImport(module.id, imported, false));
15464
15594
  }
15465
15595
  }
15466
15596
  else {
@@ -15550,7 +15680,7 @@ class Chunk {
15550
15680
  if (exportName[0] === '*') {
15551
15681
  const id = exportName.slice(1);
15552
15682
  if (interop(id) === 'defaultOnly') {
15553
- this.inputOptions.onwarn(errorUnexpectedNamespaceReexport(id));
15683
+ this.inputOptions.onLog(LOGLEVEL_WARN, logUnexpectedNamespaceReexport(id));
15554
15684
  }
15555
15685
  needsLiveBinding = externalLiveBindings;
15556
15686
  dependency = this.externalChunkByModule.get(this.modulesById.get(id));
@@ -15572,7 +15702,7 @@ class Chunk {
15572
15702
  dependency = this.externalChunkByModule.get(module);
15573
15703
  imported = variable.name;
15574
15704
  if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
15575
- return error(errorUnexpectedNamedImport(module.id, imported, true));
15705
+ return error(logUnexpectedNamedImport(module.id, imported, true));
15576
15706
  }
15577
15707
  needsLiveBinding =
15578
15708
  externalLiveBindings &&
@@ -15617,7 +15747,7 @@ class Chunk {
15617
15747
  defaultVariableName: dep.defaultVariableName,
15618
15748
  globalName: dep instanceof ExternalChunk &&
15619
15749
  (this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
15620
- getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onwarn),
15750
+ getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onLog),
15621
15751
  importPath,
15622
15752
  imports,
15623
15753
  isChunk: dep instanceof Chunk,
@@ -15641,7 +15771,7 @@ class Chunk {
15641
15771
  }
15642
15772
  // This method changes properties on the AST before rendering and must not be async
15643
15773
  renderModules(fileName) {
15644
- const { accessedGlobalsByScope, dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onwarn }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
15774
+ const { accessedGlobalsByScope, dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onLog }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
15645
15775
  const { compact, dynamicImportFunction, format, freeze, namespaceToStringTag } = outputOptions;
15646
15776
  const { _, cnst, n } = snippets;
15647
15777
  this.setDynamicImportResolutions(fileName);
@@ -15714,7 +15844,7 @@ class Chunk {
15714
15844
  }
15715
15845
  const renderedSource = compact ? magicString : magicString.trim();
15716
15846
  if (isEmpty && this.getExportNames().length === 0 && dependencies.size === 0) {
15717
- onwarn(errorEmptyChunk(this.getChunkName()));
15847
+ onLog(LOGLEVEL_WARN, logEmptyChunk(this.getChunkName()));
15718
15848
  }
15719
15849
  return { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait };
15720
15850
  }
@@ -16003,15 +16133,18 @@ function* concatLazy(iterables) {
16003
16133
  * those chunks that are already loaded for that dynamic entry and create
16004
16134
  * another round of chunks.
16005
16135
  */
16006
- function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16136
+ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
16007
16137
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
16008
16138
  const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
16009
16139
  // Each chunk is identified by its position in this array
16010
- const initialChunks = Object.values(getChunksBySignature(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks)));
16140
+ const initialChunks = getChunksFromDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
16011
16141
  // This mutates initialChunks but also clears
16012
16142
  // dynamicallyDependentEntriesByDynamicEntry as side effect
16013
16143
  removeUnnecessaryDependentEntries(initialChunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
16014
- chunkDefinitions.push(...createChunks(allEntries, getChunksBySignature(initialChunks), minChunkSize));
16144
+ chunkDefinitions.push(...getOptimizedChunks(getChunksFromDependentEntries(initialChunks), allEntries.length, minChunkSize, log).map(({ modules }) => ({
16145
+ alias: null,
16146
+ modules
16147
+ })));
16015
16148
  return chunkDefinitions;
16016
16149
  }
16017
16150
  function getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry) {
@@ -16117,7 +16250,7 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
16117
16250
  }
16118
16251
  return dynamicallyDependentEntriesByDynamicEntry;
16119
16252
  }
16120
- function getChunksBySignature(modulesWithDependentEntries) {
16253
+ function getChunksFromDependentEntries(modulesWithDependentEntries) {
16121
16254
  var _a;
16122
16255
  const chunkModules = Object.create(null);
16123
16256
  for (const { dependentEntries, modules } of modulesWithDependentEntries) {
@@ -16130,7 +16263,7 @@ function getChunksBySignature(modulesWithDependentEntries) {
16130
16263
  modules: []
16131
16264
  })).modules.push(...modules);
16132
16265
  }
16133
- return chunkModules;
16266
+ return Object.values(chunkModules);
16134
16267
  }
16135
16268
  function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks) {
16136
16269
  for (const [module, dependentEntries] of dependentEntriesByModule) {
@@ -16188,17 +16321,6 @@ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesBy
16188
16321
  chunkMask <<= 1n;
16189
16322
  }
16190
16323
  }
16191
- function createChunks(allEntries, chunkModulesBySignature, minChunkSize) {
16192
- return minChunkSize === 0
16193
- ? Object.values(chunkModulesBySignature).map(({ modules }) => ({
16194
- alias: null,
16195
- modules
16196
- }))
16197
- : getOptimizedChunks(chunkModulesBySignature, allEntries.length, minChunkSize).map(({ modules }) => ({
16198
- alias: null,
16199
- modules
16200
- }));
16201
- }
16202
16324
  /**
16203
16325
  * This function tries to get rid of small chunks by merging them with other
16204
16326
  * chunks.
@@ -16241,239 +16363,270 @@ function createChunks(allEntries, chunkModulesBySignature, minChunkSize) {
16241
16363
  * dependency side effects are AF.
16242
16364
  * For entry chunks, dependency and correlated side effects are the same.
16243
16365
  *
16244
- * With these concepts, merging chunks is allowed if the correlated side effects
16245
- * of each entry do not change. Thus, we are allowed to merge two chunks if
16366
+ * With these concepts, merging chunks is allowed if the correlated side
16367
+ * effects of each entry do not change. Thus, we are allowed to merge two
16368
+ * chunks if
16369
+ *
16246
16370
  * a) the dependency side effects of each chunk are a subset of the correlated
16247
16371
  * side effects of the other chunk, so no additional side effects are
16248
16372
  * triggered for any entry, or
16249
- * b) The signature of chunk A is a subset of the signature of chunk B while the
16250
- * dependency side effects of A are a subset of the correlated side effects
16251
- * of B. Because in that scenario, whenever A is loaded, B is loaded as well.
16252
- * But there are cases when B is loaded where A is not loaded. So if we merge
16253
- * the chunks, all dependency side effects of A will be added to the
16254
- * correlated side effects of B, and as the latter is not allowed to change,
16255
- * the former need to be a subset of the latter.
16373
+ * b) The dependent entry points of chunk A are a subset of the dependent entry
16374
+ * points of chunk B while the dependency side effects of A are a subset of
16375
+ * the correlated side effects of B. Because in that scenario, whenever A is
16376
+ * loaded, B is loaded as well. But there are cases when B is loaded where A
16377
+ * is not loaded. So if we merge the chunks, all dependency side effects of
16378
+ * A will be added to the correlated side effects of B, and as the latter is
16379
+ * not allowed to change, the former need to be a subset of the latter.
16256
16380
  *
16257
- * Another consideration when merging small chunks into other chunks is to avoid
16381
+ * Another consideration when merging small chunks into other chunks is to
16382
+ * avoid
16258
16383
  * that too much additional code is loaded. This is achieved when the dependent
16259
- * entries of the small chunk are a subset of the dependent entries of the other
16384
+ * entries of the small chunk are a subset of the dependent entries of the
16385
+ * other
16260
16386
  * chunk. Because then when the small chunk is loaded, the other chunk was
16261
16387
  * loaded/in memory anyway, so at most when the other chunk is loaded, the
16262
16388
  * additional size of the small chunk is loaded unnecessarily.
16263
16389
  *
16264
16390
  * So the algorithm performs merges in two passes:
16391
+ *
16265
16392
  * 1. First we try to merge small chunks A only into other chunks B if the
16266
16393
  * dependent entries of A are a subset of the dependent entries of B and the
16267
16394
  * dependency side effects of A are a subset of the correlated side effects
16268
16395
  * of B.
16269
16396
  * 2. Only then for all remaining small chunks, we look for arbitrary merges
16270
- * following the above rules (a) and (b), starting with the smallest chunks
16271
- * to look for possible merge targets.
16397
+ * following the rule (a), starting with the smallest chunks to look for
16398
+ * possible merge targets.
16272
16399
  */
16273
- // TODO instead of picking the "closest" chunk, we could actually use a
16274
- // technique similar to what we do for side effects to compare the size of the
16275
- // static dependencies that are not part of the correlated dependencies
16276
- function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
16400
+ function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize, log) {
16277
16401
  timeStart('optimize chunks', 3);
16278
- const chunkPartition = getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize);
16279
- console.log('Before eliminating small chunks, there were\n', Object.keys(chunkModulesBySignature).length, 'chunks, of which\n', chunkPartition.small.size, 'were below minChunkSize.');
16280
- if (chunkPartition.small.size > 0) {
16281
- mergeChunks(chunkPartition, minChunkSize);
16282
- }
16283
- console.log('After merging chunks,\n', chunkPartition.small.size + chunkPartition.big.size, 'chunks remain, of which\n', chunkPartition.small.size, 'are below minChunkSize.');
16402
+ const chunkPartition = getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize);
16403
+ if (!chunkPartition) {
16404
+ timeEnd('optimize chunks', 3);
16405
+ return initialChunks; // the actual modules
16406
+ }
16407
+ minChunkSize > 1 &&
16408
+ log('info', logOptimizeChunkStatus(initialChunks.length, chunkPartition.small.size, 'Initially'));
16409
+ mergeChunks(chunkPartition, minChunkSize);
16410
+ minChunkSize > 1 &&
16411
+ log('info', logOptimizeChunkStatus(chunkPartition.small.size + chunkPartition.big.size, chunkPartition.small.size, 'After merging chunks'));
16284
16412
  timeEnd('optimize chunks', 3);
16285
16413
  return [...chunkPartition.small, ...chunkPartition.big];
16286
16414
  }
16287
- function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
16415
+ function getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize) {
16288
16416
  const smallChunks = [];
16289
16417
  const bigChunks = [];
16290
16418
  const chunkByModule = new Map();
16291
- const sideEffectsByEntry = [];
16292
- for (let index = 0; index < numberOfEntries; index++) {
16293
- sideEffectsByEntry.push(new Set());
16294
- }
16295
- for (const [signature, { dependentEntries, modules }] of Object.entries(chunkModulesBySignature)) {
16419
+ const sizeByAtom = [];
16420
+ let sideEffectAtoms = 0n;
16421
+ let containedAtoms = 1n;
16422
+ for (const { dependentEntries, modules } of initialChunks) {
16296
16423
  const chunkDescription = {
16297
- correlatedSideEffects: new Set(),
16424
+ containedAtoms,
16425
+ correlatedAtoms: 0n,
16298
16426
  dependencies: new Set(),
16299
16427
  dependentChunks: new Set(),
16300
16428
  dependentEntries,
16301
16429
  modules,
16302
16430
  pure: true,
16303
- sideEffects: new Set(),
16304
16431
  size: 0
16305
16432
  };
16306
16433
  let size = 0;
16307
16434
  let pure = true;
16308
16435
  for (const module of modules) {
16309
16436
  chunkByModule.set(module, chunkDescription);
16310
- pure && (pure = !module.hasEffects());
16311
16437
  // Unfortunately, we cannot take tree-shaking into account here because
16312
- // rendering did not happen yet
16313
- size += module.originalCode.length;
16438
+ // rendering did not happen yet, but we can detect empty modules
16439
+ if (module.isIncluded()) {
16440
+ pure && (pure = !module.hasEffects());
16441
+ // we use a trivial size for the default minChunkSize to improve
16442
+ // performance
16443
+ size += minChunkSize > 1 ? module.estimateSize() : 1;
16444
+ }
16314
16445
  }
16315
16446
  chunkDescription.pure = pure;
16316
16447
  chunkDescription.size = size;
16448
+ sizeByAtom.push(size);
16317
16449
  if (!pure) {
16318
- for (const entryIndex of dependentEntries) {
16319
- sideEffectsByEntry[entryIndex].add(signature);
16320
- }
16321
- // In the beginning, each chunk is only its own side effect. After
16322
- // merging, additional side effects can accumulate.
16323
- chunkDescription.sideEffects.add(signature);
16450
+ sideEffectAtoms |= containedAtoms;
16324
16451
  }
16325
16452
  (size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
16453
+ containedAtoms <<= 1n;
16326
16454
  }
16327
- sortChunksAndAddDependenciesAndEffects([bigChunks, smallChunks], chunkByModule, sideEffectsByEntry);
16455
+ // If there are no small chunks, we will not optimize
16456
+ if (smallChunks.length === 0) {
16457
+ return null;
16458
+ }
16459
+ sideEffectAtoms |= addChunkDependenciesAndAtomsAndGetSideEffectAtoms([bigChunks, smallChunks], chunkByModule, numberOfEntries, containedAtoms);
16328
16460
  return {
16329
16461
  big: new Set(bigChunks),
16462
+ sideEffectAtoms,
16463
+ sizeByAtom,
16330
16464
  small: new Set(smallChunks)
16331
16465
  };
16332
16466
  }
16333
- function sortChunksAndAddDependenciesAndEffects(chunkLists, chunkByModule, sideEffectsByEntry) {
16467
+ function mergeChunks(chunkPartition, minChunkSize) {
16468
+ const { small } = chunkPartition;
16469
+ for (const mergedChunk of small) {
16470
+ const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition,
16471
+ // In the default case, we do not accept size increases
16472
+ minChunkSize <= 1 ? 1 : Infinity);
16473
+ if (bestTargetChunk) {
16474
+ const { containedAtoms, correlatedAtoms, modules, pure, size } = mergedChunk;
16475
+ small.delete(mergedChunk);
16476
+ getChunksInPartition(bestTargetChunk, minChunkSize, chunkPartition).delete(bestTargetChunk);
16477
+ bestTargetChunk.modules.push(...modules);
16478
+ bestTargetChunk.size += size;
16479
+ bestTargetChunk.pure && (bestTargetChunk.pure = pure);
16480
+ const { dependencies, dependentChunks, dependentEntries } = bestTargetChunk;
16481
+ bestTargetChunk.correlatedAtoms &= correlatedAtoms;
16482
+ bestTargetChunk.containedAtoms |= containedAtoms;
16483
+ for (const entry of mergedChunk.dependentEntries) {
16484
+ dependentEntries.add(entry);
16485
+ }
16486
+ for (const dependency of mergedChunk.dependencies) {
16487
+ dependencies.add(dependency);
16488
+ dependency.dependentChunks.delete(mergedChunk);
16489
+ dependency.dependentChunks.add(bestTargetChunk);
16490
+ }
16491
+ for (const dependentChunk of mergedChunk.dependentChunks) {
16492
+ dependentChunks.add(dependentChunk);
16493
+ dependentChunk.dependencies.delete(mergedChunk);
16494
+ dependentChunk.dependencies.add(bestTargetChunk);
16495
+ }
16496
+ dependencies.delete(bestTargetChunk);
16497
+ dependentChunks.delete(bestTargetChunk);
16498
+ getChunksInPartition(bestTargetChunk, minChunkSize, chunkPartition).add(bestTargetChunk);
16499
+ }
16500
+ }
16501
+ }
16502
+ function addChunkDependenciesAndAtomsAndGetSideEffectAtoms(chunkLists, chunkByModule, numberOfEntries, nextAtomSignature) {
16503
+ const signatureByExternalModule = new Map();
16504
+ let sideEffectAtoms = 0n;
16505
+ const atomsByEntry = [];
16506
+ for (let index = 0; index < numberOfEntries; index++) {
16507
+ atomsByEntry.push(0n);
16508
+ }
16334
16509
  for (const chunks of chunkLists) {
16335
16510
  chunks.sort(compareChunkSize);
16336
16511
  for (const chunk of chunks) {
16337
- const { dependencies, modules, correlatedSideEffects, dependentEntries } = chunk;
16512
+ const { dependencies, dependentEntries, modules } = chunk;
16338
16513
  for (const module of modules) {
16339
16514
  for (const dependency of module.getDependenciesToBeIncluded()) {
16340
- const dependencyChunk = chunkByModule.get(dependency);
16341
- if (dependencyChunk && dependencyChunk !== chunk) {
16342
- dependencies.add(dependencyChunk);
16343
- dependencyChunk.dependentChunks.add(chunk);
16344
- }
16345
- }
16346
- }
16347
- let firstEntry = true;
16348
- // Correlated side effects is the intersection of all entry side effects
16349
- for (const entryIndex of dependentEntries) {
16350
- const entryEffects = sideEffectsByEntry[entryIndex];
16351
- if (firstEntry) {
16352
- for (const sideEffect of entryEffects) {
16353
- correlatedSideEffects.add(sideEffect);
16515
+ if (dependency instanceof ExternalModule) {
16516
+ if (dependency.info.moduleSideEffects) {
16517
+ chunk.containedAtoms |= getOrCreate(signatureByExternalModule, dependency, () => {
16518
+ const signature = nextAtomSignature;
16519
+ nextAtomSignature <<= 1n;
16520
+ sideEffectAtoms |= signature;
16521
+ return signature;
16522
+ });
16523
+ }
16354
16524
  }
16355
- firstEntry = false;
16356
- }
16357
- else {
16358
- for (const sideEffect of correlatedSideEffects) {
16359
- if (!entryEffects.has(sideEffect)) {
16360
- correlatedSideEffects.delete(sideEffect);
16525
+ else {
16526
+ const dependencyChunk = chunkByModule.get(dependency);
16527
+ if (dependencyChunk && dependencyChunk !== chunk) {
16528
+ dependencies.add(dependencyChunk);
16529
+ dependencyChunk.dependentChunks.add(chunk);
16361
16530
  }
16362
16531
  }
16363
16532
  }
16364
16533
  }
16534
+ const { containedAtoms } = chunk;
16535
+ for (const entryIndex of dependentEntries) {
16536
+ atomsByEntry[entryIndex] |= containedAtoms;
16537
+ }
16365
16538
  }
16366
16539
  }
16367
- }
16368
- function compareChunkSize({ size: sizeA }, { size: sizeB }) {
16369
- return sizeA - sizeB;
16370
- }
16371
- function mergeChunks(chunkPartition, minChunkSize) {
16372
- for (const allowArbitraryMerges of [false, true]) {
16373
- for (const mergedChunk of chunkPartition.small) {
16374
- let closestChunk = null;
16375
- let closestChunkDistance = Infinity;
16376
- const { modules, pure, size } = mergedChunk;
16377
- for (const targetChunk of concatLazy([chunkPartition.small, chunkPartition.big])) {
16378
- if (mergedChunk === targetChunk)
16379
- continue;
16380
- // If both chunks are small, we also allow for unrelated merges during
16381
- // the first pass
16382
- const onlySubsetMerge = !allowArbitraryMerges && targetChunk.size >= minChunkSize;
16383
- const distance = getChunkEntryDistance(mergedChunk, targetChunk, onlySubsetMerge);
16384
- if (distance < closestChunkDistance &&
16385
- isValidMerge(mergedChunk, targetChunk, onlySubsetMerge)) {
16386
- closestChunk = targetChunk;
16387
- closestChunkDistance = distance;
16388
- }
16389
- }
16390
- if (closestChunk) {
16391
- chunkPartition.small.delete(mergedChunk);
16392
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).delete(closestChunk);
16393
- closestChunk.modules.push(...modules);
16394
- closestChunk.size += size;
16395
- closestChunk.pure && (closestChunk.pure = pure);
16396
- const { correlatedSideEffects, dependencies, dependentChunks, dependentEntries, sideEffects } = closestChunk;
16397
- for (const sideEffect of correlatedSideEffects) {
16398
- if (!mergedChunk.correlatedSideEffects.has(sideEffect)) {
16399
- correlatedSideEffects.delete(sideEffect);
16400
- }
16401
- }
16402
- for (const entry of mergedChunk.dependentEntries) {
16403
- dependentEntries.add(entry);
16404
- }
16405
- for (const sideEffect of mergedChunk.sideEffects) {
16406
- sideEffects.add(sideEffect);
16407
- }
16408
- for (const dependency of mergedChunk.dependencies) {
16409
- dependencies.add(dependency);
16410
- dependency.dependentChunks.delete(mergedChunk);
16411
- dependency.dependentChunks.add(closestChunk);
16412
- }
16413
- for (const dependentChunk of mergedChunk.dependentChunks) {
16414
- dependentChunks.add(dependentChunk);
16415
- dependentChunk.dependencies.delete(mergedChunk);
16416
- dependentChunk.dependencies.add(closestChunk);
16417
- }
16418
- dependencies.delete(closestChunk);
16419
- dependentChunks.delete(closestChunk);
16420
- getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16540
+ for (const chunks of chunkLists) {
16541
+ for (const chunk of chunks) {
16542
+ const { dependentEntries } = chunk;
16543
+ // Correlated atoms are the intersection of all entry atoms
16544
+ chunk.correlatedAtoms = -1n;
16545
+ for (const entryIndex of dependentEntries) {
16546
+ chunk.correlatedAtoms &= atomsByEntry[entryIndex];
16421
16547
  }
16422
16548
  }
16423
16549
  }
16550
+ return sideEffectAtoms;
16424
16551
  }
16425
- // Merging will not produce cycles if none of the direct non-merged dependencies
16426
- // of a chunk have the other chunk as a transitive dependency
16427
- function isValidMerge(mergedChunk, targetChunk, onlySubsetMerge) {
16428
- return !(hasTransitiveDependencyOrNonCorrelatedSideEffect(mergedChunk, targetChunk, true) ||
16429
- hasTransitiveDependencyOrNonCorrelatedSideEffect(targetChunk, mergedChunk, !onlySubsetMerge));
16430
- }
16431
- function hasTransitiveDependencyOrNonCorrelatedSideEffect(dependentChunk, dependencyChunk, checkSideEffects) {
16432
- const { correlatedSideEffects } = dependencyChunk;
16433
- if (checkSideEffects) {
16434
- for (const sideEffect of dependentChunk.sideEffects) {
16435
- if (!correlatedSideEffects.has(sideEffect)) {
16436
- return true;
16437
- }
16552
+ function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, small }, smallestAdditionalSize) {
16553
+ let bestTargetChunk = null;
16554
+ // In the default case, we do not accept size increases
16555
+ for (const targetChunk of concatLazy([small, big])) {
16556
+ if (mergedChunk === targetChunk)
16557
+ continue;
16558
+ const additionalSizeAfterMerge = getAdditionalSizeAfterMerge(mergedChunk, targetChunk, smallestAdditionalSize, sideEffectAtoms, sizeByAtom);
16559
+ if (additionalSizeAfterMerge < smallestAdditionalSize) {
16560
+ bestTargetChunk = targetChunk;
16561
+ if (additionalSizeAfterMerge === 0)
16562
+ break;
16563
+ smallestAdditionalSize = additionalSizeAfterMerge;
16438
16564
  }
16439
16565
  }
16566
+ return bestTargetChunk;
16567
+ }
16568
+ function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16569
+ return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16570
+ }
16571
+ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
16572
+ return sizeA - sizeB;
16573
+ }
16574
+ /**
16575
+ * Determine the additional unused code size that would be added by merging the
16576
+ * two chunks. This is not an exact measurement but rather an upper bound. If
16577
+ * the merge produces cycles or adds non-correlated side effects, `Infinity`
16578
+ * is returned.
16579
+ * Merging will not produce cycles if none of the direct non-merged
16580
+ * dependencies of a chunk have the other chunk as a transitive dependency.
16581
+ */
16582
+ function getAdditionalSizeAfterMerge(mergedChunk, targetChunk,
16583
+ // The maximum additional unused code size allowed to be added by the merge,
16584
+ // taking dependencies into account, needs to be below this number
16585
+ currentAdditionalSize, sideEffectAtoms, sizeByAtom) {
16586
+ const firstSize = getAdditionalSizeIfNoTransitiveDependencyOrNonCorrelatedSideEffect(mergedChunk, targetChunk, currentAdditionalSize, sideEffectAtoms, sizeByAtom);
16587
+ return firstSize < currentAdditionalSize
16588
+ ? firstSize +
16589
+ getAdditionalSizeIfNoTransitiveDependencyOrNonCorrelatedSideEffect(targetChunk, mergedChunk, currentAdditionalSize - firstSize, sideEffectAtoms, sizeByAtom)
16590
+ : Infinity;
16591
+ }
16592
+ function getAdditionalSizeIfNoTransitiveDependencyOrNonCorrelatedSideEffect(dependentChunk, dependencyChunk, currentAdditionalSize, sideEffectAtoms, sizeByAtom) {
16593
+ const { correlatedAtoms } = dependencyChunk;
16594
+ let dependencyAtoms = dependentChunk.containedAtoms;
16595
+ const dependentContainedSideEffects = dependencyAtoms & sideEffectAtoms;
16596
+ if ((correlatedAtoms & dependentContainedSideEffects) !== dependentContainedSideEffects) {
16597
+ return Infinity;
16598
+ }
16440
16599
  const chunksToCheck = new Set(dependentChunk.dependencies);
16441
- for (const { dependencies, sideEffects } of chunksToCheck) {
16600
+ for (const { dependencies, containedAtoms } of chunksToCheck) {
16601
+ dependencyAtoms |= containedAtoms;
16602
+ const containedSideEffects = containedAtoms & sideEffectAtoms;
16603
+ if ((correlatedAtoms & containedSideEffects) !== containedSideEffects) {
16604
+ return Infinity;
16605
+ }
16442
16606
  for (const dependency of dependencies) {
16443
16607
  if (dependency === dependencyChunk) {
16444
- return true;
16608
+ return Infinity;
16445
16609
  }
16446
16610
  chunksToCheck.add(dependency);
16447
16611
  }
16448
- if (checkSideEffects) {
16449
- for (const sideEffect of sideEffects) {
16450
- if (!correlatedSideEffects.has(sideEffect)) {
16451
- return true;
16452
- }
16453
- }
16454
- }
16455
16612
  }
16456
- return false;
16457
- }
16458
- function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16459
- return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16613
+ return getAtomsSizeIfBelowLimit(dependencyAtoms & ~correlatedAtoms, currentAdditionalSize, sizeByAtom);
16460
16614
  }
16461
- function getChunkEntryDistance({ dependentEntries: sourceEntries }, { dependentEntries: targetEntries }, enforceSubest) {
16462
- let distance = 0;
16463
- for (const entryIndex of targetEntries) {
16464
- if (!sourceEntries.has(entryIndex)) {
16465
- distance++;
16615
+ function getAtomsSizeIfBelowLimit(atoms, currentAdditionalSize, sizeByAtom) {
16616
+ let size = 0;
16617
+ let atomIndex = 0;
16618
+ let atomSignature = 1n;
16619
+ const { length } = sizeByAtom;
16620
+ for (; atomIndex < length; atomIndex++) {
16621
+ if ((atoms & atomSignature) === atomSignature) {
16622
+ size += sizeByAtom[atomIndex];
16466
16623
  }
16467
- }
16468
- for (const entryIndex of sourceEntries) {
16469
- if (!targetEntries.has(entryIndex)) {
16470
- if (enforceSubest) {
16471
- return Infinity;
16472
- }
16473
- distance++;
16624
+ atomSignature <<= 1n;
16625
+ if (size >= currentAdditionalSize) {
16626
+ return Infinity;
16474
16627
  }
16475
16628
  }
16476
- return distance;
16629
+ return size;
16477
16630
  }
16478
16631
 
16479
16632
  // ported from https://github.com/substack/node-commondir
@@ -16666,7 +16819,7 @@ class Link {
16666
16819
  sourcesContent[sourceIndex] = content;
16667
16820
  }
16668
16821
  else if (content != null && sourcesContent[sourceIndex] !== content) {
16669
- return error(errorConflictingSourcemapSources(filename));
16822
+ return error(logConflictingSourcemapSources(filename));
16670
16823
  }
16671
16824
  const tracedSegment = [segment[0], sourceIndex, line, column];
16672
16825
  if (name) {
@@ -16716,12 +16869,12 @@ class Link {
16716
16869
  return null;
16717
16870
  }
16718
16871
  }
16719
- function getLinkMap(warn) {
16872
+ function getLinkMap(log) {
16720
16873
  return function linkMap(source, map) {
16721
16874
  if (map.mappings) {
16722
16875
  return new Link(map, [source]);
16723
16876
  }
16724
- warn(errorSourcemapBroken(map.plugin));
16877
+ log(LOGLEVEL_WARN, logSourcemapBroken(map.plugin));
16725
16878
  return new Link({
16726
16879
  mappings: [],
16727
16880
  names: []
@@ -16743,8 +16896,8 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
16743
16896
  }
16744
16897
  return sourcemapChain.reduce(linkMap, source);
16745
16898
  }
16746
- function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, warn) {
16747
- const linkMap = getLinkMap(warn);
16899
+ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, log) {
16900
+ const linkMap = getLinkMap(log);
16748
16901
  const moduleSources = modules
16749
16902
  .filter(module => !module.excludeFromSourcemap)
16750
16903
  .map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
@@ -16759,11 +16912,11 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
16759
16912
  sourcesContent = (excludeContent ? null : sourcesContent);
16760
16913
  return new SourceMap({ file, mappings, names, sources, sourcesContent });
16761
16914
  }
16762
- function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn) {
16915
+ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log) {
16763
16916
  if (sourcemapChain.length === 0) {
16764
16917
  return originalSourcemap;
16765
16918
  }
16766
- const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(warn));
16919
+ const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(log));
16767
16920
  const map = source.traceMappings();
16768
16921
  return { version: 3, ...map };
16769
16922
  }
@@ -16788,14 +16941,14 @@ function decodedSourcemap(map) {
16788
16941
  return { ...map, mappings };
16789
16942
  }
16790
16943
 
16791
- async function renderChunks(chunks, bundle, pluginDriver, outputOptions, onwarn) {
16944
+ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
16792
16945
  timeStart('render chunks', 2);
16793
16946
  reserveEntryChunksInBundle(chunks);
16794
16947
  const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
16795
16948
  timeEnd('render chunks', 2);
16796
16949
  timeStart('transform chunks', 2);
16797
16950
  const chunkGraph = getChunkGraph(chunks);
16798
- const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
16951
+ const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
16799
16952
  const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
16800
16953
  addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
16801
16954
  timeEnd('transform chunks', 2);
@@ -16814,7 +16967,7 @@ function getChunkGraph(chunks) {
16814
16967
  return [renderedChunkInfo.fileName, renderedChunkInfo];
16815
16968
  }));
16816
16969
  }
16817
- async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, onwarn) {
16970
+ async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, log) {
16818
16971
  let map = null;
16819
16972
  const sourcemapChain = [];
16820
16973
  let code = await outputPluginDriver.hookReduceArg0('renderChunk', [magicString.toString(), chunkGraph[fileName], options, { chunks: chunkGraph }], (code, result, plugin) => {
@@ -16845,13 +16998,13 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
16845
16998
  else
16846
16999
  resultingFile = resolve(fileName);
16847
17000
  const decodedMap = magicString.generateDecodedMap({});
16848
- map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, onwarn);
17001
+ map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, log);
16849
17002
  for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
16850
17003
  let sourcePath = map.sources[sourcesIndex];
16851
17004
  const sourcemapPath = `${resultingFile}.map`;
16852
17005
  const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
16853
17006
  if (typeof ignoreList !== 'boolean') {
16854
- error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17007
+ error(logFailedValidation('sourcemapIgnoreList function must return a boolean.'));
16855
17008
  }
16856
17009
  if (ignoreList) {
16857
17010
  if (map.x_google_ignoreList === undefined) {
@@ -16864,7 +17017,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
16864
17017
  if (sourcemapPathTransform) {
16865
17018
  sourcePath = sourcemapPathTransform(sourcePath, sourcemapPath);
16866
17019
  if (typeof sourcePath !== 'string') {
16867
- error(errorFailedValidation(`sourcemapPathTransform function must return a string.`));
17020
+ error(logFailedValidation(`sourcemapPathTransform function must return a string.`));
16868
17021
  }
16869
17022
  }
16870
17023
  map.sources[sourcesIndex] = normalize(sourcePath);
@@ -16876,7 +17029,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
16876
17029
  map
16877
17030
  };
16878
17031
  }
16879
- async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn) {
17032
+ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log) {
16880
17033
  const nonHashedChunksWithPlaceholders = [];
16881
17034
  const renderedChunksByPlaceholder = new Map();
16882
17035
  const hashDependenciesByPlaceholder = new Map();
@@ -16889,7 +17042,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
16889
17042
  const transformedChunk = {
16890
17043
  chunk,
16891
17044
  fileName,
16892
- ...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, onwarn))
17045
+ ...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, log))
16893
17046
  };
16894
17047
  const { code } = transformedChunk;
16895
17048
  if (hashPlaceholder) {
@@ -17006,14 +17159,14 @@ class Bundle {
17006
17159
  const getHashPlaceholder = getHashPlaceholderGenerator();
17007
17160
  const chunks = await this.generateChunks(outputBundle, getHashPlaceholder);
17008
17161
  if (chunks.length > 1) {
17009
- validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn);
17162
+ validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onLog);
17010
17163
  }
17011
17164
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
17012
17165
  for (const chunk of chunks) {
17013
17166
  chunk.generateExports();
17014
17167
  }
17015
17168
  timeEnd('generate chunks', 2);
17016
- await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onwarn);
17169
+ await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onLog);
17017
17170
  }
17018
17171
  catch (error_) {
17019
17172
  await this.pluginDriver.hookParallel('renderError', [error_]);
@@ -17076,7 +17229,7 @@ class Bundle {
17076
17229
  });
17077
17230
  }
17078
17231
  catch (error_) {
17079
- this.inputOptions.onwarn(errorChunkInvalid(file, error_));
17232
+ this.inputOptions.onLog(LOGLEVEL_WARN, logChunkInvalid(file, error_));
17080
17233
  }
17081
17234
  }
17082
17235
  }
@@ -17098,7 +17251,7 @@ class Bundle {
17098
17251
  ? [{ alias: null, modules: includedModules }]
17099
17252
  : preserveModules
17100
17253
  ? includedModules.map(module => ({ alias: null, modules: [module] }))
17101
- : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
17254
+ : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize, this.inputOptions.onLog)) {
17102
17255
  sortByExecutionOrder(modules);
17103
17256
  const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
17104
17257
  chunks.push(chunk);
@@ -17113,15 +17266,15 @@ class Bundle {
17113
17266
  return [...chunks, ...facades];
17114
17267
  }
17115
17268
  }
17116
- function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
17269
+ function validateOptionsForMultiChunkOutput(outputOptions, log) {
17117
17270
  if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
17118
- return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
17271
+ return error(logInvalidOption('output.format', URL_OUTPUT_FORMAT, 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
17119
17272
  if (typeof outputOptions.file === 'string')
17120
- return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option'));
17273
+ return error(logInvalidOption('output.file', URL_OUTPUT_DIR, 'when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option'));
17121
17274
  if (outputOptions.sourcemapFile)
17122
- return error(errorInvalidOption('output.sourcemapFile', URL_OUTPUT_SOURCEMAPFILE, '"output.sourcemapFile" is only supported for single-file builds'));
17275
+ return error(logInvalidOption('output.sourcemapFile', URL_OUTPUT_SOURCEMAPFILE, '"output.sourcemapFile" is only supported for single-file builds'));
17123
17276
  if (!outputOptions.amd.autoId && outputOptions.amd.id)
17124
- onWarn(errorInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead'));
17277
+ log(LOGLEVEL_WARN, logInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead'));
17125
17278
  }
17126
17279
  function getIncludedModules(modulesById) {
17127
17280
  const includedModules = [];
@@ -17154,7 +17307,7 @@ function getExternalChunkByModule(modulesById, outputOptions, inputBase) {
17154
17307
  function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
17155
17308
  const existingAlias = manualChunkAliasByEntry.get(module);
17156
17309
  if (typeof existingAlias === 'string' && existingAlias !== alias) {
17157
- return error(errorCannotAssignModuleToChunk(module.id, alias, existingAlias));
17310
+ return error(logCannotAssignModuleToChunk(module.id, alias, existingAlias));
17158
17311
  }
17159
17312
  manualChunkAliasByEntry.set(module, alias);
17160
17313
  }
@@ -22938,9 +23091,9 @@ const NO_CACHE = {
22938
23091
  function uncacheablePluginError(pluginName) {
22939
23092
  if (pluginName.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
22940
23093
  pluginName.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX)) {
22941
- return error(errorAnonymousPluginCache());
23094
+ return error(logAnonymousPluginCache());
22942
23095
  }
22943
- return error(errorDuplicatePluginName(pluginName));
23096
+ return error(logDuplicatePluginName(pluginName));
22944
23097
  }
22945
23098
  function getCacheForUncacheablePlugin(pluginName) {
22946
23099
  return {
@@ -22959,7 +23112,154 @@ function getCacheForUncacheablePlugin(pluginName) {
22959
23112
  };
22960
23113
  }
22961
23114
 
22962
- async function transform(source, module, pluginDriver, warn) {
23115
+ async function asyncFlatten(array) {
23116
+ do {
23117
+ array = (await Promise.all(array)).flat(Infinity);
23118
+ } while (array.some((v) => v?.then));
23119
+ return array;
23120
+ }
23121
+
23122
+ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
23123
+ const { onwarn, onLog } = config;
23124
+ const defaultOnLog = getDefaultOnLog(printLog, onwarn);
23125
+ if (onLog) {
23126
+ const minimalPriority = logLevelPriority[logLevel];
23127
+ return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
23128
+ if (level === LOGLEVEL_ERROR) {
23129
+ return error(normalizeLog(handledLog));
23130
+ }
23131
+ if (logLevelPriority[level] >= minimalPriority) {
23132
+ defaultOnLog(level, normalizeLog(handledLog));
23133
+ }
23134
+ });
23135
+ }
23136
+ return defaultOnLog;
23137
+ };
23138
+ const getDefaultOnLog = (printLog, onwarn) => onwarn
23139
+ ? (level, log) => {
23140
+ if (level === LOGLEVEL_WARN) {
23141
+ onwarn(addLogToString(log), warning => printLog(LOGLEVEL_WARN, normalizeLog(warning)));
23142
+ }
23143
+ else {
23144
+ printLog(level, log);
23145
+ }
23146
+ }
23147
+ : printLog;
23148
+ const addLogToString = (log) => {
23149
+ Object.defineProperty(log, 'toString', {
23150
+ value: () => getExtendedLogMessage(log),
23151
+ writable: true
23152
+ });
23153
+ return log;
23154
+ };
23155
+ const normalizeLog = (log) => typeof log === 'string'
23156
+ ? { message: log }
23157
+ : typeof log === 'function'
23158
+ ? normalizeLog(log())
23159
+ : log;
23160
+ const getExtendedLogMessage = (log) => {
23161
+ let prefix = '';
23162
+ if (log.plugin) {
23163
+ prefix += `(${log.plugin} plugin) `;
23164
+ }
23165
+ if (log.loc) {
23166
+ prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
23167
+ }
23168
+ return prefix + log.message;
23169
+ };
23170
+ const defaultPrintLog = (level, log) => {
23171
+ const message = getExtendedLogMessage(log);
23172
+ switch (level) {
23173
+ case LOGLEVEL_WARN: {
23174
+ return console.warn(message);
23175
+ }
23176
+ case LOGLEVEL_DEBUG: {
23177
+ return console.debug(message);
23178
+ }
23179
+ default: {
23180
+ return console.info(message);
23181
+ }
23182
+ }
23183
+ };
23184
+ function warnUnknownOptions(passedOptions, validOptions, optionType, log, ignoredKeys = /$./) {
23185
+ const validOptionSet = new Set(validOptions);
23186
+ const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
23187
+ if (unknownOptions.length > 0) {
23188
+ log(LOGLEVEL_WARN, logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
23189
+ }
23190
+ }
23191
+ const treeshakePresets = {
23192
+ recommended: {
23193
+ annotations: true,
23194
+ correctVarValueBeforeDeclaration: false,
23195
+ manualPureFunctions: EMPTY_ARRAY,
23196
+ moduleSideEffects: () => true,
23197
+ propertyReadSideEffects: true,
23198
+ tryCatchDeoptimization: true,
23199
+ unknownGlobalSideEffects: false
23200
+ },
23201
+ safest: {
23202
+ annotations: true,
23203
+ correctVarValueBeforeDeclaration: true,
23204
+ manualPureFunctions: EMPTY_ARRAY,
23205
+ moduleSideEffects: () => true,
23206
+ propertyReadSideEffects: true,
23207
+ tryCatchDeoptimization: true,
23208
+ unknownGlobalSideEffects: true
23209
+ },
23210
+ smallest: {
23211
+ annotations: true,
23212
+ correctVarValueBeforeDeclaration: false,
23213
+ manualPureFunctions: EMPTY_ARRAY,
23214
+ moduleSideEffects: () => false,
23215
+ propertyReadSideEffects: false,
23216
+ tryCatchDeoptimization: false,
23217
+ unknownGlobalSideEffects: false
23218
+ }
23219
+ };
23220
+ const generatedCodePresets = {
23221
+ es2015: {
23222
+ arrowFunctions: true,
23223
+ constBindings: true,
23224
+ objectShorthand: true,
23225
+ reservedNamesAsProps: true,
23226
+ symbols: true
23227
+ },
23228
+ es5: {
23229
+ arrowFunctions: false,
23230
+ constBindings: false,
23231
+ objectShorthand: false,
23232
+ reservedNamesAsProps: true,
23233
+ symbols: false
23234
+ }
23235
+ };
23236
+ const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
23237
+ const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
23238
+ if (typeof value === 'string') {
23239
+ const preset = presets[value];
23240
+ if (preset) {
23241
+ return preset;
23242
+ }
23243
+ error(logInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
23244
+ }
23245
+ return objectifyOption(value);
23246
+ };
23247
+ const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
23248
+ const presetName = value?.preset;
23249
+ if (presetName) {
23250
+ const preset = presets[presetName];
23251
+ if (preset) {
23252
+ return { ...preset, ...value };
23253
+ }
23254
+ else {
23255
+ error(logInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
23256
+ }
23257
+ }
23258
+ return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
23259
+ };
23260
+ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
23261
+
23262
+ async function transform(source, module, pluginDriver, log) {
22963
23263
  const id = module.id;
22964
23264
  const sourcemapChain = [];
22965
23265
  let originalSourcemap = source.map === null ? null : decodedSourcemap(source.map);
@@ -22981,7 +23281,7 @@ async function transform(source, module, pluginDriver, warn) {
22981
23281
  module.updateOptions(result);
22982
23282
  if (result.code == null) {
22983
23283
  if (result.map || result.ast) {
22984
- warn(errorNoTransformMapOrAstWithoutCode(plugin.name));
23284
+ log(LOGLEVEL_WARN, logNoTransformMapOrAstWithoutCode(plugin.name));
22985
23285
  }
22986
23286
  return previousCode;
22987
23287
  }
@@ -23000,6 +23300,14 @@ async function transform(source, module, pluginDriver, warn) {
23000
23300
  }
23001
23301
  return code;
23002
23302
  }
23303
+ const getLogHandler = (handler) => (log, pos) => {
23304
+ log = normalizeLog(log);
23305
+ if (pos)
23306
+ augmentCodeLocation(log, pos, currentSource, id);
23307
+ log.id = id;
23308
+ log.hook = 'transform';
23309
+ handler(log);
23310
+ };
23003
23311
  let code;
23004
23312
  try {
23005
23313
  code = await pluginDriver.hookReduceArg0('transform', [currentSource, id], transformReducer, (pluginContext, plugin) => {
@@ -23013,6 +23321,7 @@ async function transform(source, module, pluginDriver, warn) {
23013
23321
  cache: customTransformCache
23014
23322
  ? pluginContext.cache
23015
23323
  : getTrackedPluginCache(pluginContext.cache, useCustomTransformCache),
23324
+ debug: getLogHandler(pluginContext.debug),
23016
23325
  emitFile(emittedFile) {
23017
23326
  emittedFiles.push(emittedFile);
23018
23327
  return pluginDriver.emitFile(emittedFile);
@@ -23027,7 +23336,7 @@ async function transform(source, module, pluginDriver, warn) {
23027
23336
  return pluginContext.error(error_);
23028
23337
  },
23029
23338
  getCombinedSourcemap() {
23030
- const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn);
23339
+ const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log);
23031
23340
  if (!combinedMap) {
23032
23341
  const magicString = new MagicString(originalCode);
23033
23342
  return magicString.generateMap({ hires: true, includeContent: true, source: id });
@@ -23042,23 +23351,16 @@ async function transform(source, module, pluginDriver, warn) {
23042
23351
  sourcesContent: combinedMap.sourcesContent
23043
23352
  });
23044
23353
  },
23354
+ info: getLogHandler(pluginContext.info),
23045
23355
  setAssetSource() {
23046
- return this.error(errorInvalidSetAssetSourceCall());
23356
+ return this.error(logInvalidSetAssetSourceCall());
23047
23357
  },
23048
- warn(warning, pos) {
23049
- if (typeof warning === 'string')
23050
- warning = { message: warning };
23051
- if (pos)
23052
- augmentCodeLocation(warning, pos, currentSource, id);
23053
- warning.id = id;
23054
- warning.hook = 'transform';
23055
- pluginContext.warn(warning);
23056
- }
23358
+ warn: getLogHandler(pluginContext.warn)
23057
23359
  };
23058
23360
  });
23059
23361
  }
23060
23362
  catch (error_) {
23061
- return error(errorPluginError(error_, pluginName, { hook: 'transform', id }));
23363
+ return error(logPluginError(error_, pluginName, { hook: 'transform', id }));
23062
23364
  }
23063
23365
  if (!customTransformCache && // files emitted by a transform hook need to be emitted again if the hook is skipped
23064
23366
  emittedFiles.length > 0)
@@ -23184,7 +23486,7 @@ class ModuleLoader {
23184
23486
  ? { code: source }
23185
23487
  : source != null && typeof source === 'object' && typeof source.code === 'string'
23186
23488
  ? source
23187
- : error(errorBadLoader(id));
23489
+ : error(logBadLoader(id));
23188
23490
  const cachedModule = this.graph.cachedModules.get(id);
23189
23491
  if (cachedModule &&
23190
23492
  !cachedModule.customTransformCache &&
@@ -23208,7 +23510,7 @@ class ModuleLoader {
23208
23510
  }
23209
23511
  else {
23210
23512
  module.updateOptions(sourceDescription);
23211
- module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options.onwarn));
23513
+ module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options.onLog));
23212
23514
  }
23213
23515
  }
23214
23516
  async awaitLoadModulesPromise() {
@@ -23254,7 +23556,7 @@ class ModuleLoader {
23254
23556
  const existingModule = this.modulesById.get(id);
23255
23557
  if (existingModule instanceof Module) {
23256
23558
  if (importer && doAssertionsDiffer(assertions, existingModule.info.assertions)) {
23257
- this.options.onwarn(errorInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
23559
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
23258
23560
  }
23259
23561
  await this.handleExistingModule(existingModule, isEntry, isPreload);
23260
23562
  return existingModule;
@@ -23303,10 +23605,10 @@ class ModuleLoader {
23303
23605
  this.modulesById.set(id, externalModule);
23304
23606
  }
23305
23607
  else if (!(externalModule instanceof ExternalModule)) {
23306
- return error(errorInternalIdCannotBeExternal(source, importer));
23608
+ return error(logInternalIdCannotBeExternal(source, importer));
23307
23609
  }
23308
23610
  else if (doAssertionsDiffer(externalModule.info.assertions, assertions)) {
23309
- this.options.onwarn(errorInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
23611
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
23310
23612
  }
23311
23613
  return Promise.resolve(externalModule);
23312
23614
  }
@@ -23416,9 +23718,9 @@ class ModuleLoader {
23416
23718
  handleInvalidResolvedId(resolvedId, source, importer, assertions) {
23417
23719
  if (resolvedId === null) {
23418
23720
  if (isRelative(source)) {
23419
- return error(errorUnresolvedImport(source, importer));
23721
+ return error(logUnresolvedImport(source, importer));
23420
23722
  }
23421
- this.options.onwarn(errorUnresolvedImportTreatedAsExternal(source, importer));
23723
+ this.options.onLog(LOGLEVEL_WARN, logUnresolvedImportTreatedAsExternal(source, importer));
23422
23724
  return {
23423
23725
  assertions,
23424
23726
  external: true,
@@ -23430,7 +23732,7 @@ class ModuleLoader {
23430
23732
  };
23431
23733
  }
23432
23734
  else if (resolvedId.external && resolvedId.syntheticNamedExports) {
23433
- this.options.onwarn(errorExternalSyntheticExports(source, importer));
23735
+ this.options.onLog(LOGLEVEL_WARN, logExternalSyntheticExports(source, importer));
23434
23736
  }
23435
23737
  return resolvedId;
23436
23738
  }
@@ -23438,14 +23740,14 @@ class ModuleLoader {
23438
23740
  const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT);
23439
23741
  if (resolveIdResult == null) {
23440
23742
  return error(implicitlyLoadedBefore === null
23441
- ? errorUnresolvedEntry(unresolvedId)
23442
- : errorUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
23743
+ ? logUnresolvedEntry(unresolvedId)
23744
+ : logUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
23443
23745
  }
23444
23746
  if (resolveIdResult === false ||
23445
23747
  (typeof resolveIdResult === 'object' && resolveIdResult.external)) {
23446
23748
  return error(implicitlyLoadedBefore === null
23447
- ? errorEntryCannotBeExternal(unresolvedId)
23448
- : errorImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
23749
+ ? logEntryCannotBeExternal(unresolvedId)
23750
+ : logImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
23449
23751
  }
23450
23752
  return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
23451
23753
  ? resolveIdResult
@@ -23470,7 +23772,7 @@ class ModuleLoader {
23470
23772
  const existingResolution = module.resolvedIds[specifier];
23471
23773
  if (existingResolution) {
23472
23774
  if (doAssertionsDiffer(existingResolution.assertions, assertions)) {
23473
- this.options.onwarn(errorInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
23775
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
23474
23776
  }
23475
23777
  return existingResolution;
23476
23778
  }
@@ -23538,18 +23840,18 @@ function generateAssetFileName(name, source, sourceHash, outputOptions, bundle)
23538
23840
  name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
23539
23841
  }), bundle);
23540
23842
  }
23541
- function reserveFileNameInBundle(fileName, { bundle }, warn) {
23843
+ function reserveFileNameInBundle(fileName, { bundle }, log) {
23542
23844
  if (bundle[lowercaseBundleKeys].has(fileName.toLowerCase())) {
23543
- warn(errorFileNameConflict(fileName));
23845
+ log(LOGLEVEL_WARN, logFileNameConflict(fileName));
23544
23846
  }
23545
23847
  else {
23546
23848
  bundle[fileName] = FILE_PLACEHOLDER;
23547
23849
  }
23548
23850
  }
23851
+ const emittedFileTypes = new Set(['chunk', 'asset', 'prebuilt-chunk']);
23549
23852
  function hasValidType(emittedFile) {
23550
23853
  return Boolean(emittedFile &&
23551
- (emittedFile.type === 'asset' ||
23552
- emittedFile.type === 'chunk'));
23854
+ emittedFileTypes.has(emittedFile.type));
23553
23855
  }
23554
23856
  function hasValidName(emittedFile) {
23555
23857
  const validatedName = emittedFile.fileName || emittedFile.name;
@@ -23558,13 +23860,13 @@ function hasValidName(emittedFile) {
23558
23860
  function getValidSource(source, emittedFile, fileReferenceId) {
23559
23861
  if (!(typeof source === 'string' || source instanceof Uint8Array)) {
23560
23862
  const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
23561
- return error(errorFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
23863
+ return error(logFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
23562
23864
  }
23563
23865
  return source;
23564
23866
  }
23565
23867
  function getAssetFileName(file, referenceId) {
23566
23868
  if (typeof file.fileName !== 'string') {
23567
- return error(errorAssetNotFinalisedForFileName(file.name || referenceId));
23869
+ return error(logAssetNotFinalisedForFileName(file.name || referenceId));
23568
23870
  }
23569
23871
  return file.fileName;
23570
23872
  }
@@ -23575,7 +23877,7 @@ function getChunkFileName(file, facadeChunkByModule) {
23575
23877
  if (facadeChunkByModule) {
23576
23878
  return facadeChunkByModule.get(file.module).getFileName();
23577
23879
  }
23578
- return error(errorChunkNotGeneratedForFileName(file.fileName || file.name));
23880
+ return error(logChunkNotGeneratedForFileName(file.fileName || file.name));
23579
23881
  }
23580
23882
  class FileEmitter {
23581
23883
  constructor(graph, options, baseFileEmitter) {
@@ -23587,10 +23889,13 @@ class FileEmitter {
23587
23889
  this.outputFileEmitters = [];
23588
23890
  this.emitFile = (emittedFile) => {
23589
23891
  if (!hasValidType(emittedFile)) {
23590
- return error(errorFailedValidation(`Emitted files must be of type "asset" or "chunk", received "${emittedFile && emittedFile.type}".`));
23892
+ return error(logFailedValidation(`Emitted files must be of type "asset", "chunk" or "prebuilt-chunk", received "${emittedFile && emittedFile.type}".`));
23893
+ }
23894
+ if (emittedFile.type === 'prebuilt-chunk') {
23895
+ return this.emitPrebuiltChunk(emittedFile);
23591
23896
  }
23592
23897
  if (!hasValidName(emittedFile)) {
23593
- return error(errorFailedValidation(`The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
23898
+ return error(logFailedValidation(`The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
23594
23899
  }
23595
23900
  if (emittedFile.type === 'chunk') {
23596
23901
  return this.emitChunk(emittedFile);
@@ -23600,27 +23905,30 @@ class FileEmitter {
23600
23905
  this.finaliseAssets = () => {
23601
23906
  for (const [referenceId, emittedFile] of this.filesByReferenceId) {
23602
23907
  if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
23603
- return error(errorNoAssetSourceSet(emittedFile.name || referenceId));
23908
+ return error(logNoAssetSourceSet(emittedFile.name || referenceId));
23604
23909
  }
23605
23910
  };
23606
23911
  this.getFileName = (fileReferenceId) => {
23607
23912
  const emittedFile = this.filesByReferenceId.get(fileReferenceId);
23608
23913
  if (!emittedFile)
23609
- return error(errorFileReferenceIdNotFoundForFilename(fileReferenceId));
23914
+ return error(logFileReferenceIdNotFoundForFilename(fileReferenceId));
23610
23915
  if (emittedFile.type === 'chunk') {
23611
23916
  return getChunkFileName(emittedFile, this.facadeChunkByModule);
23612
23917
  }
23918
+ if (emittedFile.type === 'prebuilt-chunk') {
23919
+ return emittedFile.fileName;
23920
+ }
23613
23921
  return getAssetFileName(emittedFile, fileReferenceId);
23614
23922
  };
23615
23923
  this.setAssetSource = (referenceId, requestedSource) => {
23616
23924
  const consumedFile = this.filesByReferenceId.get(referenceId);
23617
23925
  if (!consumedFile)
23618
- return error(errorAssetReferenceIdNotFoundForSetSource(referenceId));
23926
+ return error(logAssetReferenceIdNotFoundForSetSource(referenceId));
23619
23927
  if (consumedFile.type !== 'asset') {
23620
- return error(errorFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
23928
+ return error(logFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
23621
23929
  }
23622
23930
  if (consumedFile.source !== undefined) {
23623
- return error(errorAssetSourceAlreadySet(consumedFile.name || referenceId));
23931
+ return error(logAssetSourceAlreadySet(consumedFile.name || referenceId));
23624
23932
  }
23625
23933
  const source = getValidSource(requestedSource, consumedFile, referenceId);
23626
23934
  if (this.output) {
@@ -23644,7 +23952,7 @@ class FileEmitter {
23644
23952
  });
23645
23953
  for (const emittedFile of this.filesByReferenceId.values()) {
23646
23954
  if (emittedFile.fileName) {
23647
- reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
23955
+ reserveFileNameInBundle(emittedFile.fileName, output, this.options.onLog);
23648
23956
  }
23649
23957
  }
23650
23958
  const consumedAssetsByHash = new Map();
@@ -23658,6 +23966,9 @@ class FileEmitter {
23658
23966
  getOrCreate(consumedAssetsByHash, sourceHash, () => []).push(consumedFile);
23659
23967
  }
23660
23968
  }
23969
+ else if (consumedFile.type === 'prebuilt-chunk') {
23970
+ this.output.bundle[consumedFile.fileName] = this.createPrebuiltChunk(consumedFile);
23971
+ }
23661
23972
  }
23662
23973
  for (const [sourceHash, consumedFiles] of consumedAssetsByHash) {
23663
23974
  this.finalizeAssetsWithSameSource(consumedFiles, sourceHash, output);
@@ -23684,6 +23995,27 @@ class FileEmitter {
23684
23995
  }
23685
23996
  return referenceId;
23686
23997
  }
23998
+ createPrebuiltChunk(prebuiltChunk) {
23999
+ return {
24000
+ code: prebuiltChunk.code,
24001
+ dynamicImports: [],
24002
+ exports: prebuiltChunk.exports || [],
24003
+ facadeModuleId: null,
24004
+ fileName: prebuiltChunk.fileName,
24005
+ implicitlyLoadedBefore: [],
24006
+ importedBindings: {},
24007
+ imports: [],
24008
+ isDynamicEntry: false,
24009
+ isEntry: false,
24010
+ isImplicitEntry: false,
24011
+ map: prebuiltChunk.map || null,
24012
+ moduleIds: [],
24013
+ modules: {},
24014
+ name: prebuiltChunk.fileName,
24015
+ referencedFiles: [],
24016
+ type: 'chunk'
24017
+ };
24018
+ }
23687
24019
  emitAsset(emittedAsset) {
23688
24020
  const source = emittedAsset.source === undefined
23689
24021
  ? undefined
@@ -23710,7 +24042,7 @@ class FileEmitter {
23710
24042
  emitAssetWithReferenceId(consumedAsset, output) {
23711
24043
  const { fileName, source } = consumedAsset;
23712
24044
  if (fileName) {
23713
- reserveFileNameInBundle(fileName, output, this.options.onwarn);
24045
+ reserveFileNameInBundle(fileName, output, this.options.onLog);
23714
24046
  }
23715
24047
  if (source !== undefined) {
23716
24048
  this.finalizeAdditionalAsset(consumedAsset, source, output);
@@ -23718,10 +24050,10 @@ class FileEmitter {
23718
24050
  }
23719
24051
  emitChunk(emittedChunk) {
23720
24052
  if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
23721
- return error(errorInvalidRollupPhaseForChunkEmission());
24053
+ return error(logInvalidRollupPhaseForChunkEmission());
23722
24054
  }
23723
24055
  if (typeof emittedChunk.id !== 'string') {
23724
- return error(errorFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
24056
+ return error(logFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
23725
24057
  }
23726
24058
  const consumedChunk = {
23727
24059
  fileName: emittedChunk.fileName,
@@ -23739,6 +24071,29 @@ class FileEmitter {
23739
24071
  });
23740
24072
  return this.assignReferenceId(consumedChunk, emittedChunk.id);
23741
24073
  }
24074
+ emitPrebuiltChunk(emitPrebuiltChunk) {
24075
+ if (typeof emitPrebuiltChunk.code !== 'string') {
24076
+ return error(logFailedValidation(`Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}".`));
24077
+ }
24078
+ if (typeof emitPrebuiltChunk.fileName !== 'string' ||
24079
+ isPathFragment(emitPrebuiltChunk.fileName)) {
24080
+ return error(logFailedValidation(`The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}".`));
24081
+ }
24082
+ const consumedPrebuiltChunk = {
24083
+ code: emitPrebuiltChunk.code,
24084
+ exports: emitPrebuiltChunk.exports,
24085
+ fileName: emitPrebuiltChunk.fileName,
24086
+ map: emitPrebuiltChunk.map,
24087
+ referenceId: '',
24088
+ type: 'prebuilt-chunk'
24089
+ };
24090
+ const referenceId = this.assignReferenceId(consumedPrebuiltChunk, consumedPrebuiltChunk.fileName);
24091
+ if (this.output) {
24092
+ this.output.bundle[consumedPrebuiltChunk.fileName] =
24093
+ this.createPrebuiltChunk(consumedPrebuiltChunk);
24094
+ }
24095
+ return referenceId;
24096
+ }
23742
24097
  finalizeAdditionalAsset(consumedFile, source, { bundle, fileNamesBySource, outputOptions }) {
23743
24098
  let { fileName, needsCodeReference, referenceId } = consumedFile;
23744
24099
  // Deduplicate assets if an explicit fileName is not provided
@@ -23797,7 +24152,26 @@ class FileEmitter {
23797
24152
  }
23798
24153
  }
23799
24154
 
24155
+ function getLogHandler(level, code, logger, pluginName, logLevel) {
24156
+ if (logLevelPriority[level] < logLevelPriority[logLevel]) {
24157
+ return doNothing;
24158
+ }
24159
+ return (log, pos) => {
24160
+ if (pos != null) {
24161
+ logger(LOGLEVEL_WARN, logInvalidLogPosition(pluginName));
24162
+ }
24163
+ log = normalizeLog(log);
24164
+ if (log.code && !log.pluginCode) {
24165
+ log.pluginCode = log.code;
24166
+ }
24167
+ log.code = code;
24168
+ log.plugin = pluginName;
24169
+ logger(level, log);
24170
+ };
24171
+ }
24172
+
23800
24173
  function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
24174
+ const { logLevel, onLog } = options;
23801
24175
  let cacheable = true;
23802
24176
  if (typeof plugin.cacheKey !== 'string') {
23803
24177
  if (plugin.name.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
@@ -23823,19 +24197,21 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
23823
24197
  return {
23824
24198
  addWatchFile(id) {
23825
24199
  if (graph.phase >= BuildPhase.GENERATE) {
23826
- return this.error(errorInvalidRollupPhaseForAddWatchFile());
24200
+ return this.error(logInvalidRollupPhaseForAddWatchFile());
23827
24201
  }
23828
24202
  graph.watchFiles[id] = true;
23829
24203
  },
23830
24204
  cache: cacheInstance,
24205
+ debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', onLog, plugin.name, logLevel),
23831
24206
  emitFile: fileEmitter.emitFile.bind(fileEmitter),
23832
24207
  error(error_) {
23833
- return error(errorPluginError(error_, plugin.name));
24208
+ return error(logPluginError(normalizeLog(error_), plugin.name));
23834
24209
  },
23835
24210
  getFileName: fileEmitter.getFileName,
23836
24211
  getModuleIds: () => graph.modulesById.keys(),
23837
24212
  getModuleInfo: graph.getModuleInfo,
23838
24213
  getWatchFiles: () => Object.keys(graph.watchFiles),
24214
+ info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', onLog, plugin.name, logLevel),
23839
24215
  load(resolvedId) {
23840
24216
  return graph.moduleLoader.preloadModule(resolvedId);
23841
24217
  },
@@ -23857,15 +24233,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
23857
24233
  return graph.moduleLoader.resolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
23858
24234
  },
23859
24235
  setAssetSource: fileEmitter.setAssetSource,
23860
- warn(warning) {
23861
- if (typeof warning === 'string')
23862
- warning = { message: warning };
23863
- if (warning.code)
23864
- warning.pluginCode = warning.code;
23865
- warning.code = 'PLUGIN_WARNING';
23866
- warning.plugin = plugin.name;
23867
- options.onwarn(warning);
23868
- }
24236
+ warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel)
23869
24237
  };
23870
24238
  }
23871
24239
 
@@ -23877,6 +24245,7 @@ const inputHookNames = {
23877
24245
  closeWatcher: 1,
23878
24246
  load: 1,
23879
24247
  moduleParsed: 1,
24248
+ onLog: 1,
23880
24249
  options: 1,
23881
24250
  resolveDynamicImport: 1,
23882
24251
  resolveId: 1,
@@ -23908,7 +24277,7 @@ class PluginDriver {
23908
24277
  for (const plugin of userPlugins) {
23909
24278
  for (const hook of inputHooks) {
23910
24279
  if (hook in plugin) {
23911
- options.onwarn(errorInputHookInOutputPlugin(plugin.name, hook));
24280
+ options.onLog(LOGLEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
23912
24281
  }
23913
24282
  }
23914
24283
  }
@@ -24055,7 +24424,7 @@ class PluginDriver {
24055
24424
  // action considered to be fulfilled since error being handled
24056
24425
  this.unfulfilledActions.delete(action);
24057
24426
  }
24058
- return error(errorPluginError(error_, plugin.name, { hook: hookName }));
24427
+ return error(logPluginError(error_, plugin.name, { hook: hookName }));
24059
24428
  });
24060
24429
  }
24061
24430
  /**
@@ -24077,7 +24446,7 @@ class PluginDriver {
24077
24446
  return handler.apply(context, parameters);
24078
24447
  }
24079
24448
  catch (error_) {
24080
- return error(errorPluginError(error_, plugin.name, { hook: hookName }));
24449
+ return error(logPluginError(error_, plugin.name, { hook: hookName }));
24081
24450
  }
24082
24451
  }
24083
24452
  }
@@ -24109,12 +24478,12 @@ function getSortedValidatedPlugins(hookName, plugins, validateHandler = validate
24109
24478
  }
24110
24479
  function validateFunctionPluginHandler(handler, hookName, plugin) {
24111
24480
  if (typeof handler !== 'function') {
24112
- error(errorInvalidFunctionPluginHook(hookName, plugin.name));
24481
+ error(logInvalidFunctionPluginHook(hookName, plugin.name));
24113
24482
  }
24114
24483
  }
24115
24484
  function validateAddonPluginHandler(handler, hookName, plugin) {
24116
24485
  if (typeof handler !== 'string' && typeof handler !== 'function') {
24117
- return error(errorInvalidAddonPluginHook(hookName, plugin.name));
24486
+ return error(logInvalidAddonPluginHook(hookName, plugin.name));
24118
24487
  }
24119
24488
  }
24120
24489
  function noReturn() { }
@@ -24326,7 +24695,7 @@ class Graph {
24326
24695
  for (const module of this.implicitEntryModules) {
24327
24696
  for (const dependant of module.implicitlyLoadedAfter) {
24328
24697
  if (!(dependant.info.isEntry || dependant.isIncluded())) {
24329
- error(errorImplicitDependantIsNotIncluded(dependant));
24698
+ error(logImplicitDependantIsNotIncluded(dependant));
24330
24699
  }
24331
24700
  }
24332
24701
  }
@@ -24334,7 +24703,7 @@ class Graph {
24334
24703
  sortModules() {
24335
24704
  const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
24336
24705
  for (const cyclePath of cyclePaths) {
24337
- this.options.onwarn(errorCircularDependency(cyclePath));
24706
+ this.options.onLog(LOGLEVEL_WARN, logCircularDependency(cyclePath));
24338
24707
  }
24339
24708
  this.modules = orderedModules;
24340
24709
  for (const module of this.modules) {
@@ -24347,7 +24716,7 @@ class Graph {
24347
24716
  for (const importDescription of module.importDescriptions.values()) {
24348
24717
  if (importDescription.name !== '*' &&
24349
24718
  !importDescription.module.getVariableForExportName(importDescription.name)[0]) {
24350
- module.warn(errorMissingExport(importDescription.name, module.id, importDescription.module.id), importDescription.start);
24719
+ module.log(LOGLEVEL_WARN, logMissingExport(importDescription.name, module.id, importDescription.module.id), importDescription.start);
24351
24720
  }
24352
24721
  }
24353
24722
  }
@@ -24376,25 +24745,68 @@ function formatAction([pluginName, hookName, parameters]) {
24376
24745
  }
24377
24746
  return action;
24378
24747
  }
24379
- // We do not directly listen on process to avoid max listeners warnings for
24380
- // complicated build processes
24381
- const beforeExitEvent = 'beforeExit';
24382
- const beforeExitEmitter = new EventEmitter();
24383
- beforeExitEmitter.setMaxListeners(0);
24384
- process$1.on(beforeExitEvent, () => beforeExitEmitter.emit(beforeExitEvent));
24748
+ let handleBeforeExit = null;
24749
+ const rejectByPluginDriver = new Map();
24385
24750
  async function catchUnfinishedHookActions(pluginDriver, callback) {
24386
- let handleEmptyEventLoop;
24387
24751
  const emptyEventLoopPromise = new Promise((_, reject) => {
24388
- handleEmptyEventLoop = () => {
24389
- const unfulfilledActions = pluginDriver.getUnfulfilledHookActions();
24390
- reject(new Error(`Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:\n` +
24391
- [...unfulfilledActions].map(formatAction).join('\n')));
24392
- };
24393
- beforeExitEmitter.once(beforeExitEvent, handleEmptyEventLoop);
24752
+ rejectByPluginDriver.set(pluginDriver, reject);
24753
+ if (!handleBeforeExit) {
24754
+ // We only ever create a single event listener to avoid max listener and
24755
+ // other issues
24756
+ handleBeforeExit = () => {
24757
+ for (const [pluginDriver, reject] of rejectByPluginDriver) {
24758
+ const unfulfilledActions = pluginDriver.getUnfulfilledHookActions();
24759
+ reject(new Error(`Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:\n` +
24760
+ [...unfulfilledActions].map(formatAction).join('\n')));
24761
+ }
24762
+ };
24763
+ process$1.once('beforeExit', handleBeforeExit);
24764
+ }
24394
24765
  });
24395
- const result = await Promise.race([callback(), emptyEventLoopPromise]);
24396
- beforeExitEmitter.off(beforeExitEvent, handleEmptyEventLoop);
24397
- return result;
24766
+ try {
24767
+ return await Promise.race([callback(), emptyEventLoopPromise]);
24768
+ }
24769
+ finally {
24770
+ rejectByPluginDriver.delete(pluginDriver);
24771
+ if (rejectByPluginDriver.size === 0) {
24772
+ process$1.off('beforeExit', handleBeforeExit);
24773
+ handleBeforeExit = null;
24774
+ }
24775
+ }
24776
+ }
24777
+
24778
+ function getLogger(plugins, onLog, watchMode, logLevel) {
24779
+ plugins = getSortedValidatedPlugins('onLog', plugins);
24780
+ const minimalPriority = logLevelPriority[logLevel];
24781
+ const logger = (level, log, skipped = EMPTY_SET) => {
24782
+ const logPriority = logLevelPriority[level];
24783
+ if (logPriority < minimalPriority) {
24784
+ return;
24785
+ }
24786
+ for (const plugin of plugins) {
24787
+ if (skipped.has(plugin))
24788
+ continue;
24789
+ const { onLog: pluginOnLog } = plugin;
24790
+ const getLogHandler = (level) => {
24791
+ if (logLevelPriority[level] < minimalPriority) {
24792
+ return doNothing;
24793
+ }
24794
+ return log => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
24795
+ };
24796
+ const handler = 'handler' in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
24797
+ if (handler.call({
24798
+ debug: getLogHandler(LOGLEVEL_DEBUG),
24799
+ error: (log) => error(normalizeLog(log)),
24800
+ info: getLogHandler(LOGLEVEL_INFO),
24801
+ meta: { rollupVersion: version$1, watchMode },
24802
+ warn: getLogHandler(LOGLEVEL_WARN)
24803
+ }, level, log) === false) {
24804
+ return;
24805
+ }
24806
+ }
24807
+ onLog(level, log);
24808
+ };
24809
+ return logger;
24398
24810
  }
24399
24811
 
24400
24812
  const leftCurlyBrace = "{".charCodeAt(0);
@@ -24493,7 +24905,7 @@ function importAssertions(Parser) {
24493
24905
  if (this.type !== tt.string) { this.unexpected(); }
24494
24906
  node.source = this.parseExprAtom();
24495
24907
 
24496
- if (this.type === this.assertToken) {
24908
+ if (this.type === this.assertToken || this.type === tt._with) {
24497
24909
  this.next();
24498
24910
  const assertions = this.parseImportAssertions();
24499
24911
  if (assertions) {
@@ -24537,7 +24949,7 @@ function importAssertions(Parser) {
24537
24949
  if (this.type !== tt.string) { this.unexpected(); }
24538
24950
  node.source = this.parseExprAtom();
24539
24951
 
24540
- if (this.type === this.assertToken) {
24952
+ if (this.type === this.assertToken || this.type === tt._with) {
24541
24953
  this.next();
24542
24954
  const assertions = this.parseImportAssertions();
24543
24955
  if (assertions) {
@@ -24574,7 +24986,7 @@ function importAssertions(Parser) {
24574
24986
  this.type === tt.string ? this.parseExprAtom() : this.unexpected();
24575
24987
  }
24576
24988
 
24577
- if (this.type === this.assertToken) {
24989
+ if (this.type === this.assertToken || this.type == tt._with) {
24578
24990
  this.next();
24579
24991
  const assertions = this.parseImportAssertions();
24580
24992
  if (assertions) {
@@ -24648,100 +25060,16 @@ function ensureArray(items) {
24648
25060
  return [];
24649
25061
  }
24650
25062
 
24651
- async function asyncFlatten(array) {
24652
- do {
24653
- array = (await Promise.all(array)).flat(Infinity);
24654
- } while (array.some((v) => v?.then));
24655
- return array;
24656
- }
24657
-
24658
- const defaultOnWarn = warning => console.warn(warning.message || warning);
24659
- function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignoredKeys = /$./) {
24660
- const validOptionSet = new Set(validOptions);
24661
- const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
24662
- if (unknownOptions.length > 0) {
24663
- warn(errorUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
24664
- }
24665
- }
24666
- const treeshakePresets = {
24667
- recommended: {
24668
- annotations: true,
24669
- correctVarValueBeforeDeclaration: false,
24670
- manualPureFunctions: EMPTY_ARRAY,
24671
- moduleSideEffects: () => true,
24672
- propertyReadSideEffects: true,
24673
- tryCatchDeoptimization: true,
24674
- unknownGlobalSideEffects: false
24675
- },
24676
- safest: {
24677
- annotations: true,
24678
- correctVarValueBeforeDeclaration: true,
24679
- manualPureFunctions: EMPTY_ARRAY,
24680
- moduleSideEffects: () => true,
24681
- propertyReadSideEffects: true,
24682
- tryCatchDeoptimization: true,
24683
- unknownGlobalSideEffects: true
24684
- },
24685
- smallest: {
24686
- annotations: true,
24687
- correctVarValueBeforeDeclaration: false,
24688
- manualPureFunctions: EMPTY_ARRAY,
24689
- moduleSideEffects: () => false,
24690
- propertyReadSideEffects: false,
24691
- tryCatchDeoptimization: false,
24692
- unknownGlobalSideEffects: false
24693
- }
24694
- };
24695
- const generatedCodePresets = {
24696
- es2015: {
24697
- arrowFunctions: true,
24698
- constBindings: true,
24699
- objectShorthand: true,
24700
- reservedNamesAsProps: true,
24701
- symbols: true
24702
- },
24703
- es5: {
24704
- arrowFunctions: false,
24705
- constBindings: false,
24706
- objectShorthand: false,
24707
- reservedNamesAsProps: true,
24708
- symbols: false
24709
- }
24710
- };
24711
- const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
24712
- const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
24713
- if (typeof value === 'string') {
24714
- const preset = presets[value];
24715
- if (preset) {
24716
- return preset;
24717
- }
24718
- error(errorInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
24719
- }
24720
- return objectifyOption(value);
24721
- };
24722
- const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
24723
- const presetName = value?.preset;
24724
- if (presetName) {
24725
- const preset = presets[presetName];
24726
- if (preset) {
24727
- return { ...preset, ...value };
24728
- }
24729
- else {
24730
- error(errorInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
24731
- }
24732
- }
24733
- return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
24734
- };
24735
- const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
24736
-
24737
- async function normalizeInputOptions(config) {
25063
+ async function normalizeInputOptions(config, watchMode) {
24738
25064
  // These are options that may trigger special warnings or behaviour later
24739
25065
  // if the user did not select an explicit value
24740
25066
  const unsetOptions = new Set();
24741
25067
  const context = config.context ?? 'undefined';
24742
- const onwarn = getOnwarn(config);
25068
+ const plugins = await normalizePluginOption(config.plugins);
25069
+ const logLevel = config.logLevel || LOGLEVEL_INFO;
25070
+ const onLog = getLogger(plugins, getOnLog(config, logLevel), watchMode, logLevel);
24743
25071
  const strictDeprecations = config.strictDeprecations || false;
24744
- const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
25072
+ const maxParallelFileOps = getMaxParallelFileOps(config, onLog, strictDeprecations);
24745
25073
  const options = {
24746
25074
  acorn: getAcorn(config),
24747
25075
  acornInjectPlugins: getAcornInjectPlugins(config),
@@ -24750,43 +25078,28 @@ async function normalizeInputOptions(config) {
24750
25078
  experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
24751
25079
  experimentalLogSideEffects: config.experimentalLogSideEffects || false,
24752
25080
  external: getIdMatcher(config.external),
24753
- inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
25081
+ inlineDynamicImports: getInlineDynamicImports$1(config, onLog, strictDeprecations),
24754
25082
  input: getInput(config),
25083
+ logLevel,
24755
25084
  makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
24756
- manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
25085
+ manualChunks: getManualChunks$1(config, onLog, strictDeprecations),
24757
25086
  maxParallelFileOps,
24758
25087
  maxParallelFileReads: maxParallelFileOps,
24759
25088
  moduleContext: getModuleContext(config, context),
24760
- onwarn,
25089
+ onLog,
25090
+ onwarn: warning => onLog(LOGLEVEL_WARN, warning),
24761
25091
  perf: config.perf || false,
24762
- plugins: await normalizePluginOption(config.plugins),
25092
+ plugins,
24763
25093
  preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only',
24764
- preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
25094
+ preserveModules: getPreserveModules$1(config, onLog, strictDeprecations),
24765
25095
  preserveSymlinks: config.preserveSymlinks || false,
24766
25096
  shimMissingExports: config.shimMissingExports || false,
24767
25097
  strictDeprecations,
24768
25098
  treeshake: getTreeshake(config)
24769
25099
  };
24770
- warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', options.onwarn, /^(output)$/);
25100
+ warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', onLog, /^(output)$/);
24771
25101
  return { options, unsetOptions };
24772
25102
  }
24773
- const getOnwarn = (config) => {
24774
- const { onwarn } = config;
24775
- return onwarn
24776
- ? warning => {
24777
- warning.toString = () => {
24778
- let warningString = '';
24779
- if (warning.plugin)
24780
- warningString += `(${warning.plugin} plugin) `;
24781
- if (warning.loc)
24782
- warningString += `${relativeId(warning.loc.file)} (${warning.loc.line}:${warning.loc.column}) `;
24783
- warningString += warning.message;
24784
- return warningString;
24785
- };
24786
- onwarn(warning, defaultOnWarn);
24787
- }
24788
- : defaultOnWarn;
24789
- };
24790
25103
  const getAcorn = (config) => ({
24791
25104
  ecmaVersion: 'latest',
24792
25105
  sourceType: 'module',
@@ -24821,10 +25134,10 @@ const getIdMatcher = (option) => {
24821
25134
  }
24822
25135
  return () => false;
24823
25136
  };
24824
- const getInlineDynamicImports$1 = (config, warn, strictDeprecations) => {
25137
+ const getInlineDynamicImports$1 = (config, log, strictDeprecations) => {
24825
25138
  const configInlineDynamicImports = config.inlineDynamicImports;
24826
25139
  if (configInlineDynamicImports) {
24827
- warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', URL_OUTPUT_INLINEDYNAMICIMPORTS, true, warn, strictDeprecations);
25140
+ warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', URL_OUTPUT_INLINEDYNAMICIMPORTS, true, log, strictDeprecations);
24828
25141
  }
24829
25142
  return configInlineDynamicImports;
24830
25143
  };
@@ -24832,17 +25145,17 @@ const getInput = (config) => {
24832
25145
  const configInput = config.input;
24833
25146
  return configInput == null ? [] : typeof configInput === 'string' ? [configInput] : configInput;
24834
25147
  };
24835
- const getManualChunks$1 = (config, warn, strictDeprecations) => {
25148
+ const getManualChunks$1 = (config, log, strictDeprecations) => {
24836
25149
  const configManualChunks = config.manualChunks;
24837
25150
  if (configManualChunks) {
24838
- warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', URL_OUTPUT_MANUALCHUNKS, true, warn, strictDeprecations);
25151
+ warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', URL_OUTPUT_MANUALCHUNKS, true, log, strictDeprecations);
24839
25152
  }
24840
25153
  return configManualChunks;
24841
25154
  };
24842
- const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
25155
+ const getMaxParallelFileOps = (config, log, strictDeprecations) => {
24843
25156
  const maxParallelFileReads = config.maxParallelFileReads;
24844
25157
  if (typeof maxParallelFileReads === 'number') {
24845
- warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', URL_MAXPARALLELFILEOPS, true, warn, strictDeprecations);
25158
+ warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', URL_MAXPARALLELFILEOPS, true, log, strictDeprecations);
24846
25159
  }
24847
25160
  const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
24848
25161
  if (typeof maxParallelFileOps === 'number') {
@@ -24866,10 +25179,10 @@ const getModuleContext = (config, context) => {
24866
25179
  }
24867
25180
  return () => context;
24868
25181
  };
24869
- const getPreserveModules$1 = (config, warn, strictDeprecations) => {
25182
+ const getPreserveModules$1 = (config, log, strictDeprecations) => {
24870
25183
  const configPreserveModules = config.preserveModules;
24871
25184
  if (configPreserveModules) {
24872
- warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', URL_OUTPUT_PRESERVEMODULES, true, warn, strictDeprecations);
25185
+ warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', URL_OUTPUT_PRESERVEMODULES, true, log, strictDeprecations);
24873
25186
  }
24874
25187
  return configPreserveModules;
24875
25188
  };
@@ -24906,7 +25219,7 @@ const getHasModuleSideEffects = (moduleSideEffectsOption) => {
24906
25219
  return id => ids.has(id);
24907
25220
  }
24908
25221
  if (moduleSideEffectsOption) {
24909
- error(errorInvalidOption('treeshake.moduleSideEffects', URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array'));
25222
+ error(logInvalidOption('treeshake.moduleSideEffects', URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array'));
24910
25223
  }
24911
25224
  return () => true;
24912
25225
  };
@@ -24946,7 +25259,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
24946
25259
  entryFileNames: getEntryFileNames(config, unsetOptions),
24947
25260
  esModule: config.esModule ?? 'if-default-prop',
24948
25261
  experimentalDeepDynamicChunkOptimization: getExperimentalDeepDynamicChunkOptimization(config, inputOptions),
24949
- experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
25262
+ experimentalMinChunkSize: config.experimentalMinChunkSize ?? 1,
24950
25263
  exports: getExports(config, unsetOptions),
24951
25264
  extend: config.extend || false,
24952
25265
  externalImportAssertions: config.externalImportAssertions ?? true,
@@ -24992,17 +25305,17 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
24992
25305
  systemNullSetters: config.systemNullSetters ?? true,
24993
25306
  validate: config.validate || false
24994
25307
  };
24995
- warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
25308
+ warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onLog);
24996
25309
  return { options: outputOptions, unsetOptions };
24997
25310
  }
24998
25311
  const getFile = (config, preserveModules, inputOptions) => {
24999
25312
  const { file } = config;
25000
25313
  if (typeof file === 'string') {
25001
25314
  if (preserveModules) {
25002
- return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
25315
+ return error(logInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
25003
25316
  }
25004
25317
  if (!Array.isArray(inputOptions.input))
25005
- return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when providing named inputs'));
25318
+ return error(logInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when providing named inputs'));
25006
25319
  }
25007
25320
  return file;
25008
25321
  };
@@ -25029,7 +25342,7 @@ const getFormat = (config) => {
25029
25342
  return configFormat;
25030
25343
  }
25031
25344
  default: {
25032
- return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, configFormat));
25345
+ return error(logInvalidOption('output.format', URL_OUTPUT_FORMAT, `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, configFormat));
25033
25346
  }
25034
25347
  }
25035
25348
  };
@@ -25037,7 +25350,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
25037
25350
  const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
25038
25351
  const { input } = inputOptions;
25039
25352
  if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
25040
- return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
25353
+ return error(logInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
25041
25354
  }
25042
25355
  return inlineDynamicImports;
25043
25356
  };
@@ -25045,10 +25358,10 @@ const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
25045
25358
  const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
25046
25359
  if (preserveModules) {
25047
25360
  if (inlineDynamicImports) {
25048
- return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, `this option is not supported for "output.preserveModules"`));
25361
+ return error(logInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, `this option is not supported for "output.preserveModules"`));
25049
25362
  }
25050
25363
  if (inputOptions.preserveEntrySignatures === false) {
25051
- return error(errorInvalidOption('preserveEntrySignatures', URL_PRESERVEENTRYSIGNATURES, 'setting this option to false is not supported for "output.preserveModules"'));
25364
+ return error(logInvalidOption('preserveEntrySignatures', URL_PRESERVEENTRYSIGNATURES, 'setting this option to false is not supported for "output.preserveModules"'));
25052
25365
  }
25053
25366
  }
25054
25367
  return preserveModules;
@@ -25076,10 +25389,10 @@ const getAmd = (config) => {
25076
25389
  ...config.amd
25077
25390
  };
25078
25391
  if ((mergedOption.autoId || mergedOption.basePath) && mergedOption.id) {
25079
- return error(errorInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
25392
+ return error(logInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
25080
25393
  }
25081
25394
  if (mergedOption.basePath && !mergedOption.autoId) {
25082
- return error(errorInvalidOption('output.amd.basePath', URL_OUTPUT_AMD_BASEPATH, 'this option only works with "output.amd.autoId"'));
25395
+ return error(logInvalidOption('output.amd.basePath', URL_OUTPUT_AMD_BASEPATH, 'this option only works with "output.amd.autoId"'));
25083
25396
  }
25084
25397
  return mergedOption.autoId
25085
25398
  ? {
@@ -25106,7 +25419,7 @@ const getAddon = (config, name) => {
25106
25419
  const getDir = (config, file) => {
25107
25420
  const { dir } = config;
25108
25421
  if (typeof dir === 'string' && typeof file === 'string') {
25109
- return error(errorInvalidOption('output.dir', URL_OUTPUT_DIR, 'you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks'));
25422
+ return error(logInvalidOption('output.dir', URL_OUTPUT_DIR, 'you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks'));
25110
25423
  }
25111
25424
  return dir;
25112
25425
  };
@@ -25115,7 +25428,7 @@ const getDynamicImportFunction = (config, inputOptions, format) => {
25115
25428
  if (configDynamicImportFunction) {
25116
25429
  warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, URL_RENDERDYNAMICIMPORT, true, inputOptions);
25117
25430
  if (format !== 'es') {
25118
- inputOptions.onwarn(errorInvalidOption('output.dynamicImportFunction', URL_OUTPUT_DYNAMICIMPORTFUNCTION, 'this option is ignored for formats other than "es"'));
25431
+ inputOptions.onLog(LOGLEVEL_WARN, logInvalidOption('output.dynamicImportFunction', URL_OUTPUT_DYNAMICIMPORTFUNCTION, 'this option is ignored for formats other than "es"'));
25119
25432
  }
25120
25433
  }
25121
25434
  return configDynamicImportFunction;
@@ -25140,7 +25453,7 @@ function getExports(config, unsetOptions) {
25140
25453
  unsetOptions.add('exports');
25141
25454
  }
25142
25455
  else if (!['default', 'named', 'none', 'auto'].includes(configExports)) {
25143
- return error(errorInvalidExportOptionValue(configExports));
25456
+ return error(logInvalidExportOptionValue(configExports));
25144
25457
  }
25145
25458
  return configExports || 'auto';
25146
25459
  }
@@ -25183,7 +25496,7 @@ const getInterop = (config) => {
25183
25496
  };
25184
25497
  const validateInterop = (interop) => {
25185
25498
  if (!ALLOWED_INTEROP_TYPES.has(interop)) {
25186
- return error(errorInvalidOption('output.interop', URL_OUTPUT_INTEROP,
25499
+ return error(logInvalidOption('output.interop', URL_OUTPUT_INTEROP,
25187
25500
  // eslint-disable-next-line unicorn/prefer-spread
25188
25501
  `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
25189
25502
  }
@@ -25193,10 +25506,10 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
25193
25506
  const configManualChunks = config.manualChunks || inputOptions.manualChunks;
25194
25507
  if (configManualChunks) {
25195
25508
  if (inlineDynamicImports) {
25196
- return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.inlineDynamicImports"'));
25509
+ return error(logInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.inlineDynamicImports"'));
25197
25510
  }
25198
25511
  if (preserveModules) {
25199
- return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.preserveModules"'));
25512
+ return error(logInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.preserveModules"'));
25200
25513
  }
25201
25514
  }
25202
25515
  return configManualChunks || {};
@@ -25214,9 +25527,9 @@ const getSourcemapBaseUrl = (config) => {
25214
25527
  const { sourcemapBaseUrl } = config;
25215
25528
  if (sourcemapBaseUrl) {
25216
25529
  if (isValidUrl(sourcemapBaseUrl)) {
25217
- return sourcemapBaseUrl;
25530
+ return addTrailingSlashIfMissed(sourcemapBaseUrl);
25218
25531
  }
25219
- return error(errorInvalidOption('output.sourcemapBaseUrl', URL_OUTPUT_SOURCEMAPBASEURL, `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
25532
+ return error(logInvalidOption('output.sourcemapBaseUrl', URL_OUTPUT_SOURCEMAPBASEURL, `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
25220
25533
  }
25221
25534
  };
25222
25535
 
@@ -25264,13 +25577,13 @@ async function rollupInternal(rawInputOptions, watcher) {
25264
25577
  closed: false,
25265
25578
  async generate(rawOutputOptions) {
25266
25579
  if (result.closed)
25267
- return error(errorAlreadyClosed());
25580
+ return error(logAlreadyClosed());
25268
25581
  return handleGenerateWrite(false, inputOptions, unsetInputOptions, rawOutputOptions, graph);
25269
25582
  },
25270
25583
  watchFiles: Object.keys(graph.watchFiles),
25271
25584
  async write(rawOutputOptions) {
25272
25585
  if (result.closed)
25273
- return error(errorAlreadyClosed());
25586
+ return error(logAlreadyClosed());
25274
25587
  return handleGenerateWrite(true, inputOptions, unsetInputOptions, rawOutputOptions, graph);
25275
25588
  }
25276
25589
  };
@@ -25278,21 +25591,34 @@ async function rollupInternal(rawInputOptions, watcher) {
25278
25591
  result.getTimings = getTimings;
25279
25592
  return result;
25280
25593
  }
25281
- async function getInputOptions(rawInputOptions, watchMode) {
25282
- if (!rawInputOptions) {
25594
+ async function getInputOptions(initialInputOptions, watchMode) {
25595
+ if (!initialInputOptions) {
25283
25596
  throw new Error('You must supply an options object to rollup');
25284
25597
  }
25285
- const rawPlugins = getSortedValidatedPlugins('options', await normalizePluginOption(rawInputOptions.plugins));
25286
- const { options, unsetOptions } = await normalizeInputOptions(await rawPlugins.reduce(applyOptionHook(watchMode), Promise.resolve(rawInputOptions)));
25598
+ const processedInputOptions = await getProcessedInputOptions(initialInputOptions, watchMode);
25599
+ const { options, unsetOptions } = await normalizeInputOptions(processedInputOptions, watchMode);
25287
25600
  normalizePlugins(options.plugins, ANONYMOUS_PLUGIN_PREFIX);
25288
25601
  return { options, unsetOptions };
25289
25602
  }
25290
- function applyOptionHook(watchMode) {
25291
- return async (inputOptions, plugin) => {
25292
- const handler = 'handler' in plugin.options ? plugin.options.handler : plugin.options;
25293
- return ((await handler.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) ||
25294
- inputOptions);
25295
- };
25603
+ async function getProcessedInputOptions(inputOptions, watchMode) {
25604
+ const plugins = getSortedValidatedPlugins('options', await normalizePluginOption(inputOptions.plugins));
25605
+ const logLevel = inputOptions.logLevel || LOGLEVEL_INFO;
25606
+ const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), watchMode, logLevel);
25607
+ for (const plugin of plugins) {
25608
+ const { name, options } = plugin;
25609
+ const handler = 'handler' in options ? options.handler : options;
25610
+ const processedOptions = await handler.call({
25611
+ debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', logger, name, logLevel),
25612
+ error: (error_) => error(logPluginError(normalizeLog(error_), name, { hook: 'onLog' })),
25613
+ info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', logger, name, logLevel),
25614
+ meta: { rollupVersion: version$1, watchMode },
25615
+ warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', logger, name, logLevel)
25616
+ }, inputOptions);
25617
+ if (processedOptions) {
25618
+ inputOptions = processedOptions;
25619
+ }
25620
+ }
25621
+ return inputOptions;
25296
25622
  }
25297
25623
  function normalizePlugins(plugins, anonymousPrefix) {
25298
25624
  for (const [index, plugin] of plugins.entries()) {
@@ -25309,7 +25635,7 @@ async function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, raw
25309
25635
  if (isWrite) {
25310
25636
  timeStart('WRITE', 1);
25311
25637
  if (!outputOptions.dir && !outputOptions.file) {
25312
- return error(errorMissingFileOrDirOption());
25638
+ return error(logMissingFileOrDirOption());
25313
25639
  }
25314
25640
  await Promise.all(Object.values(generated).map(chunk => graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions))));
25315
25641
  await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
@@ -25332,7 +25658,7 @@ async function getOutputOptionsAndPluginDriver(rawOutputOptions, inputPluginDriv
25332
25658
  }
25333
25659
  function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, outputPluginDriver) {
25334
25660
  return normalizeOutputOptions(outputPluginDriver.hookReduceArg0Sync('outputOptions', [rawOutputOptions], (outputOptions, result) => result || outputOptions, pluginContext => {
25335
- const emitError = () => pluginContext.error(errorCannotEmitFromOptionsHook());
25661
+ const emitError = () => pluginContext.error(logCannotEmitFromOptionsHook());
25336
25662
  return {
25337
25663
  ...pluginContext,
25338
25664
  emitFile: emitError,