NativeScript uses the
require or TypeScript's
Here is an example for using
tns-core-modules in a NativeScript application:
The last few versions of NativeScript brought a ton of new features including the Preview app, extended Webpack support, Hot Module Replacement, cloud builds via CLI, and so on. The complexity of some features and the concept that Webpack should be available out-of-the-box for all NativeScript applications required the team to deprecate short imports!
Q: Wait a minute! What is a short import?
A: An import that is shortened from
Example of short import:
The above code should be rewritten to:
Historically, the short imports were a feature in NativeScript from day one. The idea was to ease the developer's experience. However, the short imports are inconvenient for some reasons:
Technical debt - Any new feature that requires access to
tns-core-modules should consider if the path is short or full and if the plugin is external or embedded (e.g. using import in the Preview app).
Usability - NativeScript developers might be confused when using a short import. In the following example, you might think that we are importing from a standalone library when in fact, this is a module from the
import * as http from "http"; // this is actually a short import for
These are the reasons why its time to say goodbye to the short imports. With NativeScript 5.2 these are now deprecated.
Q: Should I take any steps?
A: If you are an application developer, make sure to migrate all short imports to full imports. If you own a NativeScript plugin, you will have to migrate the plugin imports from short to the full syntax as well.
The NativeScript teams have already migrated the plugins under the NativeScript organization to use full imports. The next step is to iterate through the community plugins and to inform the plugin authors about the needed change.