Isolating a package and all of its dependencies

24 views
Skip to the first unread message

mikec...@gmail.com

unread,
29 Mar 2016, 10:32:21 am29/3/16
to SystemJS
Is there a way to "isolate" a package, and all of its dependencies, so that all of its dependencies are loaded from a base-url/path that I specify?

For example, in a situation where an "external" script/package is imported from a different (but known) domain, and it has named dependencies. I do not necessarily know what these dependencies are, but I know that they are all stored under a particular base URL on that domain.

I would like all package references, within the external script/package to be normalized within this base URL, even if that package is already defined by the top-most scope (where systemjs itself defined, in the System.config()).

I can use packages & map to get there partially, but it requires that I map each dependency individually (and I do not know all of the dependencies in this usage context). Map does not seem to support wildcards or "/". For example:

packages: {
'https://sub.domain': {
map: {
'some-dep': 'https://sub.domain/deps/some-dep',
'some-vendor': 'https://sub.domain/deps/some-vendor', //does work for package 'some-vendor/package'
'*': 'https://sub.domain/deps', //doesn't work
'/': 'https://sub.domain/deps' //doesn't work either
}
}
}

Guy Bedford

unread,
29 Mar 2016, 11:08:38 am29/3/16
to mikec...@gmail.com, SystemJS
There is no way to set a per-package baseURL. The baseURL can only be set globally.

One way around this is to set the baseURL globally to `https://sub.domain/deps`, and then use wildcard paths in place of your local baseURL:

paths: {
  'local:*': '/localdeps/*'
}

where you do `import 'local:x'` instead of 'import 'x'`.

That would be the best that can be done in such a situation.

--
You received this message because you are subscribed to the Google Groups "SystemJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to systemjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mikec...@gmail.com

unread,
29 Mar 2016, 12:32:30 pm29/3/16
to SystemJS
Thanks. Is there a way to specify a contextual map that applies to all packages? It's curious that the some-vendor example works, because it is almost to the point of what I need. It's sort of a "all packages with this prefix" map.

This also is not for use during a build process, this is running in browser. I can't use the local: approach since there are multiple domains and the local packages have named deps as well.

Guy Bedford

unread,
29 Mar 2016, 1:04:42 pm29/3/16
to mikec...@gmail.com, SystemJS
A contextual map for all packages would be to use global map directly.

If you use exact custom maps for all your local deps you can get around needing a baseURL there too so the baseURL can be reserved for the external URLs.

On Tue, Mar 29, 2016 at 6:32 PM <mikec...@gmail.com> wrote:
Thanks. Is there a way to specify a contextual  map that applies to all packages? It's curious that the some-vendor example works, because it is almost to the point of what I need. It's sort of a "all packages with this prefix" map.

This also is not for use during a build process, this is running in browser. I can't use the local: approach since there are multiple domains and the local packages have named deps as well.

mikec...@gmail.com

unread,
29 Mar 2016, 4:21:37 pm29/3/16
to SystemJS
Sorry, I should have been more specific. I meant for all SUBpackages. In the example above, it would apply to all packages under 'https://sub.domain' only.
Reply all
Reply to author
Forward
0 new messages