bare-module 7.0.3 → 7.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/README.md CHANGED
@@ -301,7 +301,9 @@ options = {
301
301
  // The import attributes which instruct how the file or module should be loaded.
302
302
  // `type` is one of the strings `script`, `module`, `json`, `bundle`, `addon`,
303
303
  // `binary` and `text`. A type that is not one of them is turned down rather
304
- // than passed over, as is a `type` that is not a string.
304
+ // than passed over, as is a `type` that is not a string. `imports` is the
305
+ // specifier of an "imports" map to apply to the module and its dependencies,
306
+ // resolved relative to the module calling `require()`.
305
307
  with: { type: 'json' }
306
308
  }
307
309
  ```
@@ -314,10 +316,26 @@ The module representing the entry script where the program was launched.
314
316
 
315
317
  The registry of loaded modules for this module's graph, keyed by URL href.
316
318
 
317
- ### `const path = require.resolve(specifier[, parentURL])`
319
+ ### `const path = require.resolve(specifier[, parentURL][, options])`
318
320
 
319
321
  Use the internal machinery of `require()` to resolve the `specifier` string relative to the URL `parentURL` and return the path string.
320
322
 
323
+ Options include:
324
+
325
+ ```js
326
+ options = {
327
+ // The import attributes which instruct how the file or module would be
328
+ // loaded, as for `require()`. If passed, the graph of the resolved module is
329
+ // linked, but not evaluated, with the attributes applied so that its
330
+ // resolutions are recorded in `module.resolutions`. This allows the module to
331
+ // later be prepared from its path alone, such as when spawning a thread with
332
+ // an imports map applied.
333
+ with: { imports: './imports.json' }
334
+ }
335
+ ```
336
+
337
+ When `parentURL` is passed, the resolutions are recorded for `parentURL` rather than the calling module. This is useful when resolving on behalf of another module.
338
+
321
339
  ### `require.addon([specifier][, parentURL])`
322
340
 
323
341
  Also used to import modules but specifically loads only addon modules. `specifier` is resolved relative to `parentURL` using the [addon resolution](https://github.com/holepunchto/bare-addon-resolve#algorithm) algorithm.
@@ -379,10 +397,12 @@ The directory name of the current module.
379
397
 
380
398
  The file name of the current module.
381
399
 
382
- ### `const href = import.meta.resolve(specifier[, parentURL])`
400
+ ### `const href = import.meta.resolve(specifier[, parentURL][, options])`
383
401
 
384
402
  A module-relative resolution function which returns the URL string for the module. The `specifier` is a string which is resolved relative to the `parentURL` which is a WHATWG URL.
385
403
 
404
+ Options are the same as for [`require.resolve()`](#const-path--requireresolvespecifier-parenturl-options).
405
+
386
406
  ### `import.meta.addon([specifier][, parentURL])`
387
407
 
388
408
  Also used to import modules but specifically loads only addon modules. `specifier` is resolved relative to `parentURL` using the [addon resolution](https://github.com/holepunchto/bare-addon-resolve#algorithm) algorithm.
@@ -589,6 +609,18 @@ Link the module graph rooted at `entry`, a WHATWG `URL`, awaiting each read thro
589
609
 
590
610
  The synchronous equivalent of `loader.link()`. It drives the protocol's synchronous methods (`resolveSync`, `existsSync`, `readSync`, and `listSync`), which throw an `UNEXPECTED_PROMISE` error when the protocol can only answer asynchronously.
591
611
 
612
+ ### `const modules = await loader.instantiate(urls[, options])`
613
+
614
+ Compile the modules at `urls` and everything they reach, without evaluating any of them. `urls` is a WHATWG `URL`, a string, or any number of either. Returns the module records.
615
+
616
+ This is the phase `loader.link()` performs on the way to an entry, for modules the graph already holds and is not entering through, so it answers whether a source can be run at all without any of the consequences of running it. Unlike `link()` it does not set `loader.main`.
617
+
618
+ A module the graph has already compiled is left as it is, so this is asked after a `patch()` rather than before one. What it answers is whether the source compiles, and not whether everything it names exists: an unresolved specifier is deferred, which is what lets a module name something that is not there on this platform and never ask for it.
619
+
620
+ ### `const modules = loader.instantiateSync(urls[, options])`
621
+
622
+ The synchronous equivalent of `loader.instantiate()`.
623
+
592
624
  ### `const exports = await loader.import(entry[, options])`
593
625
 
594
626
  Link and evaluate the graph rooted at `entry`, returning its exports. Awaits the entry's evaluation, so a top-level `await` in the entry settles before the exports are returned.
@@ -597,6 +629,16 @@ Link and evaluate the graph rooted at `entry`, returning its exports. Awaits the
597
629
 
598
630
  The synchronous equivalent of `loader.import()`. It cannot await, so a top-level `await` in the entry is unsupported.
599
631
 
632
+ ### `const urls = loader.patch(bundle)`
633
+
634
+ Make the contents of `bundle` what the graph reads, in front of whatever it read before, and forget what it knew about each key. Returns the URLs the patch covers. A later patch of the same key wins over an earlier one.
635
+
636
+ Forgetting a module is not re-reading it: nothing runs again until something asks for it, and whoever already imported it keeps what it exported. Reaching a patched module through an importer the graph still holds requires evicting that importer too.
637
+
638
+ ### `const urls = loader.evict(urls)`
639
+
640
+ Forget what the graph knows about the modules at `urls`, a WHATWG `URL`, a string, or any number of either, so that they are read and resolved again when next asked for. Returns the URLs that were known.
641
+
600
642
  ### `const module = loader.get(url)`
601
643
 
602
644
  Return the module record cached under `url`, a WHATWG `URL`, or `null` if none is loaded.
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Buffer from 'bare-buffer'
2
2
  import URL from 'bare-url'
3
+ import { ResolutionsMap } from 'bare-module-resolve'
3
4
  import { constants } from 'bare-module-traverse'
4
5
  import Protocol from './lib/protocol'
5
6
  import Loader from './lib/loader'
@@ -21,7 +22,12 @@ interface Attributes {
21
22
  * How the module should be loaded: one of `'script'`, `'module'`, `'json'`, `'bundle'`,
22
23
  * `'addon'`, `'binary'`, or `'text'`.
23
24
  */
24
- type: Lowercase<keyof typeof constants>
25
+ type?: Lowercase<keyof typeof constants>
26
+ /**
27
+ * The specifier of an `"imports"` map to apply to the module and its dependencies, resolved
28
+ * relative to the parent URL.
29
+ */
30
+ imports?: string
25
31
  }
26
32
 
27
33
  interface Module {
@@ -38,6 +44,11 @@ interface Module {
38
44
  * [Protocols](https://github.com/holepunchto/bare-module#protocols) for usage.
39
45
  */
40
46
  readonly protocol: Protocol
47
+ /**
48
+ * The resolutions map of the module graph, with keys being serialized parent URLs and values
49
+ * being `"imports"` maps.
50
+ */
51
+ readonly resolutions: ResolutionsMap
41
52
  /** The WHATWG `URL` identifier of the module. */
42
53
  readonly url: URL
43
54
  }
@@ -92,7 +103,22 @@ declare namespace Module {
92
103
  (parentURL: string | URL, opts?: RequireOptions): unknown
93
104
  main: Module
94
105
  cache: Cache
95
- resolve: (specifier: string, parentURL?: URL) => string
106
+ /**
107
+ * Resolve `specifier` relative to `parentURL` without evaluating the matching module. If
108
+ * import attributes are passed, the graph of the module is linked with them so that its
109
+ * resolutions are recorded.
110
+ * @param specifier - The module specifier to resolve.
111
+ * @param parentURL - The WHATWG `URL` to resolve `specifier` relative to. Defaults to the URL
112
+ * of the module that `require()` was created for.
113
+ * @param opts - Resolve options; `with` holds the import attributes.
114
+ * @returns The path of the resolved module.
115
+ * @throws {MODULE_NOT_FOUND} no module matching `specifier` could be found relative to
116
+ * `parentURL`.
117
+ */
118
+ resolve: {
119
+ (specifier: string, opts?: RequireOptions): string
120
+ (specifier: string, parentURL?: string | URL, opts?: RequireOptions): string
121
+ }
96
122
  /**
97
123
  * Resolve `specifier` relative to `parentURL` and evaluate the matching addon.
98
124
  * @param specifier - The addon specifier to resolve. Defaults to `'.'`.
package/lib/loader.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import Buffer from 'bare-buffer'
2
+ import Bundle from 'bare-bundle'
2
3
  import URL from 'bare-url'
3
4
  import { Builtins, ImportsMap, ResolutionsMap } from 'bare-module-resolve'
4
- import { Attributes, Cache, Module } from '..'
5
+ import Module, { Attributes, Cache } from '..'
5
6
  import Protocol from './protocol'
6
7
 
7
8
  interface ModuleLoader {
@@ -20,11 +21,27 @@ interface ModuleLoader {
20
21
 
21
22
  get(url: URL): Module | null
22
23
 
23
- link(entry: URL, source?: Buffer | string | null, opts?: LinkOptions): Promise<Module>
24
- linkSync(entry: URL, source?: Buffer | string | null, opts?: LinkOptions): Module
24
+ patch(bundle: Bundle): URL[]
25
+ evict(urls: URL | string | Iterable<URL | string>): URL[]
25
26
 
26
- import(entry: URL, opts?: ImportOptions): Promise<unknown>
27
- importSync(entry: URL, opts?: ImportOptions): unknown
27
+ instantiate(
28
+ urls: URL | string | Iterable<URL | string>,
29
+ opts?: ModuleLoader.LinkOptions
30
+ ): Promise<Module[]>
31
+ instantiateSync(
32
+ urls: URL | string | Iterable<URL | string>,
33
+ opts?: ModuleLoader.LinkOptions
34
+ ): Module[]
35
+
36
+ link(
37
+ entry: URL,
38
+ source?: Buffer | string | null,
39
+ opts?: ModuleLoader.LinkOptions
40
+ ): Promise<Module>
41
+ linkSync(entry: URL, source?: Buffer | string | null, opts?: ModuleLoader.LinkOptions): Module
42
+
43
+ import(entry: URL, opts?: ModuleLoader.ImportOptions): Promise<unknown>
44
+ importSync(entry: URL, opts?: ModuleLoader.ImportOptions): unknown
28
45
  }
29
46
 
30
47
  declare class ModuleLoader {
package/lib/loader.js CHANGED
@@ -98,6 +98,14 @@ function assertURL(url, name) {
98
98
  throw new TypeError(`${name} must be a URL. Received type ${typeof url} (${url})`)
99
99
  }
100
100
 
101
+ function* eachURL(urls) {
102
+ if (isURL(urls) || typeof urls === 'string') urls = [urls]
103
+
104
+ for (const url of urls) {
105
+ yield assertURL(typeof url === 'string' ? new URL(url) : url, 'URL')
106
+ }
107
+ }
108
+
101
109
  function typeAttributeFor(attributes) {
102
110
  if (attributes === undefined || attributes === null) return undefined
103
111
 
@@ -180,6 +188,7 @@ module.exports = class ModuleLoader {
180
188
  this._resolutions = resolutionsFor(resolutions)
181
189
  this._manifests = Object.create(null)
182
190
  this._bundles = []
191
+ this._patches = null
183
192
  this._visited = new Set()
184
193
  this._packages = new Map()
185
194
  this._prefixes = new Map()
@@ -220,6 +229,73 @@ module.exports = class ModuleLoader {
220
229
  return this._cached(assertURL(url, 'URL').href) || null
221
230
  }
222
231
 
232
+ patch(bundle) {
233
+ if (this._patches === null) {
234
+ this._patches = new Map()
235
+ this._protocol = patching(this._protocol, this._patches)
236
+ }
237
+
238
+ const patched = []
239
+
240
+ for (const href of bundle.keys()) {
241
+ const url = new URL(href)
242
+
243
+ this._patches.set(href, bundle)
244
+
245
+ this._forget(url)
246
+
247
+ const imports = bundle.resolutions[href]
248
+
249
+ if (imports) this._resolutions[href] = imports
250
+
251
+ patched.push(url)
252
+ }
253
+
254
+ return patched
255
+ }
256
+
257
+ evict(urls) {
258
+ const evicted = []
259
+
260
+ for (const url of eachURL(urls)) {
261
+ if (this._forget(url)) evicted.push(url)
262
+
263
+ delete this._resolutions[url.href]
264
+ }
265
+
266
+ return evicted
267
+ }
268
+
269
+ async instantiate(urls, opts = {}) {
270
+ const records = []
271
+
272
+ for (const url of eachURL(urls)) {
273
+ if (url.protocol === 'builtin:') this._lookup(url)
274
+ else await this._link(this._root(url, null, opts), this._protocolFor(url))
275
+
276
+ records.push(this._lookup(traverse.alias(url, opts)))
277
+ }
278
+
279
+ this._instantiate()
280
+
281
+ return records
282
+ }
283
+
284
+ instantiateSync(urls, opts = {}) {
285
+ const records = []
286
+
287
+ for (const url of eachURL(urls)) {
288
+ if (url.protocol === 'builtin:') this._lookup(url)
289
+ else this._linkSync(this._root(url, null, opts), this._protocolFor(url))
290
+
291
+ records.push(this._lookup(traverse.alias(url, opts)))
292
+ }
293
+
294
+ this._instantiate()
295
+
296
+ return records
297
+ }
298
+
223
299
  async link(entry, source = null, opts = {}) {
224
300
  assertURL(entry, 'Entry')
225
301
 
@@ -397,6 +473,24 @@ module.exports = class ModuleLoader {
397
473
  return null
398
474
  }
399
475
 
476
+ _forget(url) {
477
+ const { href } = url
478
+
479
+ const known = href in this._cache
480
+
481
+ delete this._cache[href]
482
+
483
+ this._visited.delete(href)
484
+ this._packages.delete(href)
485
+
486
+ this._answers.listed.delete(href)
487
+ this._answers.resolved.delete(href)
488
+
489
+ if (this._main !== null && this._main.url.href === href) this._main = null
490
+
491
+ return known
492
+ }
493
+
400
494
  _builtinRecord(url) {
401
495
  const name = url.pathname
402
496
 
@@ -450,6 +544,7 @@ module.exports = class ModuleLoader {
450
544
  engines,
451
545
  ...opts,
452
546
  deferUnresolved: true,
547
+ resolutions: this._resolutions,
453
548
  packages: this._packages,
454
549
  prefixes: this._prefixes,
455
550
  resolve: traverse.resolve.bare
@@ -559,6 +654,10 @@ module.exports = class ModuleLoader {
559
654
  _linkBundle(bundle) {
560
655
  this._bundles.push(bundle)
561
656
 
657
+ for (const href in bundle.resolutions) {
658
+ if (href in this._resolutions === false) this._resolutions[href] = bundle.resolutions[href]
659
+ }
660
+
562
661
  const protocol = this._protocol.extend({
563
662
  exists(context, url) {
564
663
  if (bundleOwns(bundle, url)) return true
@@ -601,13 +700,7 @@ module.exports = class ModuleLoader {
601
700
  }
602
701
  })
603
702
 
604
- this._linkSync(
605
- this._root(new URL(bundle.main), null, {
606
- imports: bundle.imports,
607
- resolutions: bundle.resolutions
608
- }),
609
- protocol
610
- )
703
+ this._linkSync(this._root(new URL(bundle.main), null, { imports: bundle.imports }), protocol)
611
704
  }
612
705
 
613
706
  _ingest(dependency) {
@@ -687,24 +780,20 @@ module.exports = class ModuleLoader {
687
780
  require.main = loader.main
688
781
  require.cache = loader.cache
689
782
 
690
- require.resolve = function (specifier, parentURL = referrer.url) {
691
- return urlToPath(loader._resolveSync(specifier, toURL(parentURL, referrer.url), 'require'))
783
+ require.resolve = function (specifier, parentURL, opts) {
784
+ return urlToPath(loader._resolveModule(referrer, specifier, 'require', parentURL, opts))
692
785
  }
693
786
 
694
- require.asset = function (specifier, parentURL = referrer.url) {
695
- return urlToPath(
696
- loader._resolveArtifact(referrer, specifier, 'asset', toURL(parentURL, referrer.url))
697
- )
787
+ require.asset = function (specifier, parentURL) {
788
+ return urlToPath(loader._resolveArtifact(referrer, specifier, 'asset', parentURL))
698
789
  }
699
790
 
700
- require.addon = function (specifier = '.', parentURL = referrer.url) {
701
- return loader._addon(referrer, specifier, toURL(parentURL, referrer.url))
791
+ require.addon = function (specifier = '.', parentURL) {
792
+ return loader._addon(referrer, specifier, parentURL)
702
793
  }
703
794
 
704
- require.addon.resolve = function (specifier = '.', parentURL = referrer.url) {
705
- return urlToPath(
706
- loader._resolveArtifact(referrer, specifier, 'addon', toURL(parentURL, referrer.url))
707
- )
795
+ require.addon.resolve = function (specifier = '.', parentURL) {
796
+ return urlToPath(loader._resolveArtifact(referrer, specifier, 'addon', parentURL))
708
797
  }
709
798
 
710
799
  require.addon.host = Bare.Addon.host
@@ -732,7 +821,10 @@ module.exports = class ModuleLoader {
732
821
  let record = this._lookup(url)
733
822
 
734
823
  if (record === null) {
735
- this.linkSync(url, null, { attributes, importType: lex.constants.REQUIRE })
824
+ this.linkSync(url, null, {
825
+ attributes: this._resolveAttributesSync(attributes, parentURL),
826
+ importType: lex.constants.REQUIRE
827
+ })
736
828
 
737
829
  record = this.get(url)
738
830
  }
@@ -749,13 +841,11 @@ module.exports = class ModuleLoader {
749
841
  }
750
842
 
751
843
  _cacheResolution(parentURL, specifier, condition, url) {
752
- let imports = this._resolutions[parentURL.href]
753
-
754
- if (typeof imports !== 'object' || imports === null) {
755
- imports = this._resolutions[parentURL.href] = Object.create(null)
756
- }
844
+ const imports = this._resolutions[parentURL.href]
757
845
 
758
- if (specifier in imports) return
846
+ // An entry is taken as every import of its module when that module is
847
+ // linked, so none is started for a module that isn't linked yet.
848
+ if (typeof imports !== 'object' || imports === null || specifier in imports) return
759
849
 
760
850
  imports[specifier] = { [condition]: url.href }
761
851
  }
@@ -890,13 +980,67 @@ module.exports = class ModuleLoader {
890
980
  throw notFound(condition, specifier, parentURL, candidates)
891
981
  }
892
982
 
893
- _resolveArtifact(referrer, specifier, condition, parentURL = referrer.url) {
983
+ _resolveModule(referrer, specifier, condition, parentURL, opts) {
984
+ if (isOptions(parentURL)) {
985
+ opts = parentURL
986
+ parentURL = undefined
987
+ }
988
+
989
+ parentURL = parentURLFor(referrer, parentURL)
990
+
991
+ const url = this._resolveSync(specifier, parentURL, condition)
992
+
993
+ const attributes = opts && opts.with
994
+
995
+ // The graph is linked as it would be when the resolved module is loaded,
996
+ // without being evaluated, so that its resolutions are recorded for anyone
997
+ // preparing it from the resolved URL alone.
998
+ if (attributes !== undefined && attributes !== null) {
999
+ const importType =
1000
+ lex.constants.RESOLVE |
1001
+ (condition === 'require' ? lex.constants.REQUIRE : lex.constants.IMPORT)
1002
+
1003
+ this._linkResolved(url, parentURL, attributes, importType)
1004
+ }
1005
+
1006
+ return url
1007
+ }
1008
+
1009
+ _linkResolved(url, parentURL, attributes, importType) {
1010
+ if (this._lookup(url) !== null) return
1011
+
1012
+ attributes = this._resolveAttributesSync(attributes, parentURL)
1013
+
1014
+ this._linkSync(this._root(url, null, { attributes, importType }), this._protocolFor(url))
1015
+
1016
+ this._instantiate()
1017
+ }
1018
+
1019
+ _resolveAttributesSync(attributes, parentURL) {
1020
+ if (!hasImportsAttribute(attributes)) return attributes
1021
+
1022
+ const url = this._resolveSync(attributes.imports, parentURL, 'default')
1023
+
1024
+ return { ...attributes, imports: url.href }
1025
+ }
1026
+
1027
+ async _resolveAttributes(attributes, parentURL) {
1028
+ if (!hasImportsAttribute(attributes)) return attributes
1029
+
1030
+ const url = await this._resolve(attributes.imports, parentURL, 'default')
1031
+
1032
+ return { ...attributes, imports: url.href }
1033
+ }
1034
+
1035
+ _resolveArtifact(referrer, specifier, condition, parentURL) {
1036
+ parentURL = parentURLFor(referrer, parentURL)
1037
+
894
1038
  const url = parentURL === referrer.url ? referrer._resolve(specifier, condition) : null
895
1039
 
896
1040
  return url === null ? this._resolveSync(specifier, parentURL, condition) : url
897
1041
  }
898
1042
 
899
- _addon(referrer, specifier, parentURL = referrer.url) {
1043
+ _addon(referrer, specifier, parentURL) {
900
1044
  const url = this._resolveArtifact(referrer, specifier, 'addon', parentURL)
901
1045
 
902
1046
  const record = this._lookup(url) || this._addonRecord(url)
@@ -1184,6 +1328,30 @@ function resolveEntry(specifier, condition) {
1184
1328
  return { type, specifier, names: [], attributes: {}, position: [0, 0, 0] }
1185
1329
  }
1186
1330
 
1331
+ function patching(protocol, patches) {
1332
+ return protocol.extend({
1333
+ exists(context, url) {
1334
+ return patches.has(url.href) || context.exists(url)
1335
+ },
1336
+
1337
+ existsSync(context, url) {
1338
+ return patches.has(url.href) || context.existsSync(url)
1339
+ },
1340
+
1341
+ read(context, url) {
1342
+ const patch = patches.get(url.href)
1343
+
1344
+ return patch === undefined ? context.read(url) : patch.read(url.href)
1345
+ },
1346
+
1347
+ readSync(context, url) {
1348
+ const patch = patches.get(url.href)
1349
+
1350
+ return patch === undefined ? context.readSync(url) : patch.read(url.href)
1351
+ }
1352
+ })
1353
+ }
1354
+
1187
1355
  function toURL(value, base) {
1188
1356
  if (isURL(value)) return value
1189
1357
 
@@ -1200,6 +1368,20 @@ function bundleOwns(bundle, url) {
1200
1368
  return bundle.exists(url.href)
1201
1369
  }
1202
1370
 
1371
+ function parentURLFor(referrer, parentURL) {
1372
+ return parentURL === undefined ? referrer.url : toURL(parentURL, referrer.url)
1373
+ }
1374
+
1375
+ function isOptions(value) {
1376
+ return typeof value === 'object' && value !== null && !URL.isURL(value)
1377
+ }
1378
+
1379
+ function hasImportsAttribute(attributes) {
1380
+ return (
1381
+ typeof attributes === 'object' && attributes !== null && typeof attributes.imports === 'string'
1382
+ )
1383
+ }
1384
+
1203
1385
  function isTerminalResolution(url, condition) {
1204
1386
  const protocol = url.protocol
1205
1387
 
package/lib/module.js CHANGED
@@ -63,6 +63,10 @@ module.exports = exports = class Module {
63
63
  return this._loader._protocolFor(this.url)
64
64
  }
65
65
 
66
+ get resolutions() {
67
+ return this._loader._resolutions
68
+ }
69
+
66
70
  // For Node.js compatibility
67
71
  get filename() {
68
72
  return urlToPath(this.url)
@@ -281,7 +285,7 @@ async function ondynamicimport(specifier, attributes, referrerName, id) {
281
285
  url = await loader._resolve(specifier, referrer.url, 'import')
282
286
 
283
287
  record = await loader.link(url, null, {
284
- attributes,
288
+ attributes: await loader._resolveAttributes(attributes, referrer.url),
285
289
  importType: lex.constants.IMPORT | lex.constants.DYNAMIC
286
290
  })
287
291
  } else {
@@ -339,24 +343,20 @@ function onmeta(id, meta) {
339
343
  meta.dirname = record.dirname
340
344
  meta.filename = record.filename
341
345
 
342
- meta.resolve = function (specifier) {
343
- const url = record._resolve(specifier, 'import')
344
-
345
- return url === null
346
- ? record._loader._resolveSync(specifier, record.url, 'import').href
347
- : url.href
346
+ meta.resolve = function (specifier, parentURL, opts) {
347
+ return record._loader._resolveModule(record, specifier, 'import', parentURL, opts).href
348
348
  }
349
349
 
350
- meta.asset = function (specifier) {
351
- return record._loader._resolveArtifact(record, specifier, 'asset').href
350
+ meta.asset = function (specifier, parentURL) {
351
+ return record._loader._resolveArtifact(record, specifier, 'asset', parentURL).href
352
352
  }
353
353
 
354
- meta.addon = function (specifier = '.') {
355
- return record._loader._addon(record, specifier)
354
+ meta.addon = function (specifier = '.', parentURL) {
355
+ return record._loader._addon(record, specifier, parentURL)
356
356
  }
357
357
 
358
- meta.addon.resolve = function (specifier = '.') {
359
- return record._loader._resolveArtifact(record, specifier, 'addon').href
358
+ meta.addon.resolve = function (specifier = '.', parentURL) {
359
+ return record._loader._resolveArtifact(record, specifier, 'addon', parentURL).href
360
360
  }
361
361
 
362
362
  meta.addon.host = Bare.Addon.host
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "7.0.3",
3
+ "version": "7.2.0",
4
4
  "description": "The module system that powers Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -47,9 +47,9 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "bare-bundle": "^1.11.0",
50
- "bare-module-lexer": "^1.6.1",
50
+ "bare-module-lexer": "^1.7.0",
51
51
  "bare-module-resolve": "^1.12.3",
52
- "bare-module-traverse": "~2.5.5",
52
+ "bare-module-traverse": "~2.5.7",
53
53
  "bare-path": "^3.0.0",
54
54
  "bare-type-stripper": "^0.1.2",
55
55
  "bare-url": "^2.0.1",