Importing scoped packages with an alias

Hello everyone,

I have a question regarding importing package in StealJS.

As of today, I am importing a package in my project, and many of its sub-modules. So I have this lots of imports such as:

import "package/ui"
import "package/main"
import "package/service"
...

Now, this package is going to be scoped, and renamed @scoped/package. My question is :

Is there any way to define an alias in the steal configuration from @scoped/package to package so that I don’t have to modify each and every import line ?

I have tried to use the map option in steal config: "map": { "package": "@scoped/package" } without success.

Arnaud

No, there’s no way to alias the package name. We created the ~ operator in Steal 1.0 for this problem. http://stealjs.com/docs/tilde.html

Just use ~ instead of the package name like import '~/ui'

Yes I have used the ~ operator for calls within the mentioned package, but I was looking at the problem of importing from outside the package. Say I am in package2, I want to import a module in package like this import "package/service" and I don’t want to switch to import "@scope/package/service".

Too bad if that’s not possible. Thanks for the answer anyway.

Ah, in that case there isn’t a solution for that. This might be possible if we add a packages config: https://github.com/stealjs/rfcs/issues/14 but not sure when/if that will happen.

Luckily changing package names doesn’t happen very often. I can understand that it’s annoying when it does happen.