bare-module 7.0.0 → 7.0.2

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/lib/loader.js CHANGED
@@ -358,11 +358,11 @@ module.exports = class ModuleLoader {
358
358
  },
359
359
 
360
360
  list(context, url) {
361
- return [] // TODO
361
+ return bundleOwns(bundle, url) ? [url] : context.list(url)
362
362
  },
363
363
 
364
364
  listSync(context, url) {
365
- return [] // TODO
365
+ return bundleOwns(bundle, url) ? [url] : context.listSync(url)
366
366
  }
367
367
  })
368
368
  }
@@ -781,6 +781,8 @@ module.exports = class ModuleLoader {
781
781
  this._resolveOptions()
782
782
  )
783
783
 
784
+ const candidates = []
785
+
784
786
  let next = resolver.next()
785
787
 
786
788
  while (next.done !== true) {
@@ -803,6 +805,8 @@ module.exports = class ModuleLoader {
803
805
  } else {
804
806
  const url = value.resolution
805
807
 
808
+ candidates.push(url)
809
+
806
810
  if (url.protocol === 'builtin:' || url.protocol === 'data:' || this.get(url) !== null) {
807
811
  this._cacheResolution(parentURL, specifier, condition, url)
808
812
 
@@ -821,7 +825,7 @@ module.exports = class ModuleLoader {
821
825
  }
822
826
  }
823
827
 
824
- throw notFound(condition, specifier, parentURL)
828
+ throw notFound(condition, specifier, parentURL, candidates)
825
829
  }
826
830
 
827
831
  async _resolve(specifier, parentURL, condition) {
@@ -833,6 +837,8 @@ module.exports = class ModuleLoader {
833
837
  this._resolveOptions()
834
838
  )
835
839
 
840
+ const candidates = []
841
+
836
842
  let next = resolver.next()
837
843
 
838
844
  while (next.done !== true) {
@@ -863,6 +869,8 @@ module.exports = class ModuleLoader {
863
869
  } else {
864
870
  const url = value.resolution
865
871
 
872
+ candidates.push(url)
873
+
866
874
  if (url.protocol === 'builtin:' || url.protocol === 'data:' || this.get(url) !== null) {
867
875
  this._cacheResolution(parentURL, specifier, condition, url)
868
876
 
@@ -883,7 +891,7 @@ module.exports = class ModuleLoader {
883
891
  }
884
892
  }
885
893
 
886
- throw notFound(condition, specifier, parentURL)
894
+ throw notFound(condition, specifier, parentURL, candidates)
887
895
  }
888
896
 
889
897
  _resolveArtifact(referrer, specifier, condition, parentURL = referrer.url) {
@@ -973,14 +981,29 @@ async function drive(generator, protocol, driveLink, semaphore, answers = null)
973
981
  return next.value
974
982
  }
975
983
 
976
- function notFound(condition, specifier, parentURL) {
984
+ function notFound(condition, specifier, parentURL, candidates = []) {
977
985
  switch (condition) {
978
986
  case 'addon':
979
- return errors.ADDON_NOT_FOUND(`Cannot find addon '${specifier}'`, specifier, parentURL)
987
+ return errors.ADDON_NOT_FOUND(
988
+ `Cannot find addon '${specifier}'`,
989
+ specifier,
990
+ parentURL,
991
+ candidates
992
+ )
980
993
  case 'asset':
981
- return errors.ASSET_NOT_FOUND(`Cannot find asset '${specifier}'`, specifier, parentURL)
994
+ return errors.ASSET_NOT_FOUND(
995
+ `Cannot find asset '${specifier}'`,
996
+ specifier,
997
+ parentURL,
998
+ candidates
999
+ )
982
1000
  default:
983
- return errors.MODULE_NOT_FOUND(`Cannot find module '${specifier}'`, specifier, parentURL)
1001
+ return errors.MODULE_NOT_FOUND(
1002
+ `Cannot find module '${specifier}'`,
1003
+ specifier,
1004
+ parentURL,
1005
+ candidates
1006
+ )
984
1007
  }
985
1008
  }
986
1009
 
package/lib/module.js CHANGED
@@ -57,7 +57,7 @@ module.exports = exports = class Module {
57
57
  }
58
58
 
59
59
  get protocol() {
60
- return this._loader.protocol
60
+ return this._loader._protocolFor(this.url)
61
61
  }
62
62
 
63
63
  // For Node.js compatibility
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "The module system that powers Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",