requirejs-esm 4.1.0 → 4.2.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.
package/dist/api.js CHANGED
@@ -86337,17 +86337,25 @@
86337
86337
 
86338
86338
  // Updates dependency paths to be prefixed by `esm!` or otherwise updated.
86339
86339
  function updateAmdDeps(amd, options) {
86340
- options.onBeforeUpdate?.(amd);
86340
+ let updated = options.onBeforeUpdate?.({
86341
+ ...options,
86342
+ amd
86343
+ });
86341
86344
 
86342
86345
  const { deps } = amd;
86343
- if (!deps) return
86346
+ if (!deps) {
86347
+ afterUpdate();
86348
+ return updated
86349
+ }
86344
86350
 
86345
86351
  const { sourceFileName: parentName } = options;
86346
86352
  const { elements } = deps;
86347
- if (!elements.length) return
86353
+ if (!elements.length) {
86354
+ afterUpdate();
86355
+ return updated
86356
+ }
86348
86357
 
86349
86358
  const { resolvePath } = options;
86350
- let updated;
86351
86359
  for (const element of elements) {
86352
86360
  if (element.type === 'Literal') {
86353
86361
  const moduleName = element.value;
@@ -86359,9 +86367,27 @@
86359
86367
  }
86360
86368
  }
86361
86369
 
86362
- updated ||= options.onAfterUpdate?.(amd);
86370
+ afterUpdate();
86363
86371
 
86364
86372
  return updated
86373
+
86374
+ function afterUpdate() {
86375
+ const updatedNow = options.onAfterUpdate?.({
86376
+ ...options,
86377
+ amd
86378
+ });
86379
+ updated ||= updatedNow;
86380
+ }
86381
+ }
86382
+
86383
+ function callAmdUpdateHooks(amd, options) {
86384
+ options = {
86385
+ ...options,
86386
+ amd
86387
+ };
86388
+ const updatedBefore = options.onBeforeUpdate?.(options);
86389
+ const updatedAfter = options.onAfterUpdate?.(options);
86390
+ return updatedBefore || updatedAfter
86365
86391
  }
86366
86392
 
86367
86393
  function _generateUid(name, i) {
@@ -86889,10 +86915,11 @@
86889
86915
  const result = {};
86890
86916
  if (length) {
86891
86917
  result.amd = true;
86892
- if (options.resolvePath) {
86893
- for (const amd of amds) {
86894
- result.updated ||= updateAmdDeps(amd, options);
86895
- }
86918
+ for (const amd of amds) {
86919
+ const updated = options.resolvePath
86920
+ ? updateAmdDeps(amd, options)
86921
+ : callAmdUpdateHooks(amd, options);
86922
+ result.updated ||= updated;
86896
86923
  }
86897
86924
  } else {
86898
86925
  transformEsmToAmd(program, options);