Repository navigation
Description
Why?
Provide an automated way to migrate imports and require statements from:
tns-core-modulesto@nativescript/core;- and
nativescript-angularto@nativescript/angular.
How?
The above can be achieved by providing an ESLint rule that detects the old type of imports and recommends using the new one. It should also provide an autofix that migrates the imports.
Migration description
JS/TS
The rule should work for both JS and TS projects.
tns-core-modules -> @nativescript/core
The rule should migrate the imports from that package in the following way:
for imports from application, application-settings, connectivity, image-asset, trace:
import { run } from "tns-core-modules/application"->
import { Application } from "@nativescript/core"const run = require("tns-core-modules/application").run->
const Application = require("@nativescript/core/application")
In cases 1 and 2, the rule should also change all uses of run in the code to Application.run.
import * as application from "tns-core-modules/application"->
import { Application } from "@nativescript/core"const application = require("tns-core-modules/application")->
const Application = require("@nativescript/core").Application
In cases 3 and 4, the rule should also change all uses of application in the code to Application.
for imports from utils/utils:
The same as application with this exception:
import * as utils from "tns-core-modules/utils/utils";
utils.ad;
->
import { Utils } from "@nativescript/core";
Utils.android;
`
for imports from profiling:
Migrate to import { Profiling } from @nativescript/core for the methods that are now exported through the Profiling constant from @nativescript/core:
NativeScript/nativescript-core/index.ts
Lines 69 to 76 in 8d2dd2e
| export const Profiling = { | |
| enable: profilingEnable, | |
| disable: profilingDisable, | |
| time, uptime, | |
| start, stop, isRunning, | |
| dumpProfiles, resetProfiles, | |
| profile, startCPUProfile, stopCPUProfile, | |
| }; |
Migrate to import { SomeInterface } from '@nativescript/core' for all symbols that are now directly exported from @nativescript/core:
NativeScript/nativescript-core/index.ts
Line 60 in 8d2dd2e
| export { InstrumentationMode, TimerInfo } from "./profiling"; |
for imports from trace:
Migrate to import { Trace } from @nativescript/core for the methods that are now exported through the Trace constant from @nativescript/core:
NativeScript/nativescript-core/index.ts
Lines 88 to 93 in 8d2dd2e
| export const Trace = { | |
| messageType, categories, setCategories, addCategories, | |
| addWriter, removeWriter, clearWriters, | |
| setErrorHandler, | |
| write, error, enable, disable, isEnabled | |
| }; |
Migrate to import { SomeInterface } from '@nativescript/core' for all symbols that are now directly exported from @nativescript/core:
NativeScript/nativescript-core/index.ts
Line 80 in 8d2dd2e
| export { DefaultErrorHandler, ErrorHandler, TraceWriter } from "./trace"; |
for imports from http:
Migrate to import { Http } from @nativescript/core for the methods that are now exported through the Http constant from @nativescript/core:
NativeScript/nativescript-core/index.ts
Line 52 in 8d2dd2e
| export const Http = { getFile, getImage, getJSON, getString: httpGetString, request }; |
Migrate to
import { SomeInterface } from '@nativescript/core' for all symbols that are now directly exported from @nativescript/core:NativeScript/nativescript-core/index.ts
Line 49 in 8d2dd2e
| export { HttpRequestOptions, HttpResponse, Headers, HttpResponseEncoding, HttpContent } from "./http"; |
for imports from platform:
For isAndroid and isIOS migrate to @nativescript/core.
For screen and device migrate to import { Screen, Device } from '@nativescript/core';.
For any other path migrate to @nativescript/core/platform.
for imports from ui/*, data/observable-array, data/observable, file-system, color, image-asset, image-source, text, xml:
import { Observable } from "tns-core-modules/data/observable"->
import { Observable } from "@nativescript/core"const Observable = require("tns-core-modules/data/observable")->
const Observable = require("@nativescript/core").Observable
Activity
NathanWalker commentedon Oct 23, 2026
Closing as obsolete: the move from
tns-core-modulesto@nativescript/coreis long complete, and the migration tooling (ns migrate) handles imports for remaining projects. Thanks for the detailed spec!