Sen descrición

halfnelson b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
app b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
.gitignore b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
LICENSE b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
Readme.md b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
package-lock.json b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
package.json b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
tsconfig.json b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
tsconfig.tns.json b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos
webpack.config.js b8ce36d378 Create template using tns command %!s(int64=6) %!d(string=hai) anos

Readme.md

This is barebones svelte native project template created directly from a nativescript core project template

Usage

You can get started with this using degit

$ degit halfnelson/svelte-native-template myapp

Recreating From Scratch

This was created using:

Create ns core app

    tns create svelte-ns-testapp --appid sntest.halfnelson.github.io --ts

Install svelte, svelte-native, svelte-loader

    $ npm install svelte@beta
    $ npm install svelte-native
    $ npm install svelte-loader

Append svelte-loader to end module rules

{
    test: /\.svelte$/,
    exclude: /node_modules/,
    use: 'svelte-loader'
}

Remove nativescript files from app except for package.json and app.ts and app.css

make the following changes to the app folder:

add svelte-components.d.ts:

declare module "*.svelte" {
    export default SvelteComponent;
}

change app.ts to:

import { svelteNative } from "svelte-native";
import App from  "./App.svelte";
svelteNative(App, {});

add App.svelte:

<page xmlns="tns" class="page">
    <actionBar title="My App" icon="" class="action-bar">
    </actionBar>
    <stackLayout class="p-20">
        <label text="Tap the button" class="h1 text-center"/>
        <button text="TAP" on:tap="{ onTap }" class="btn btn-primary btn-active"/>
        <label text="{ message }" class="h2 text-center" textWrap="true"/>
    </stackLayout>
</page>

<script>
    let counter = 42;
    let message;
    $: message = (counter <= 0) 
                    ? "Hoorraaay! You unlocked the Svelte-Native clicker achievement!"
                    : `${counter} taps left`
    
    const onTap = () => counter--;
</script>

Run the app with an ensure it worked

tns run android --bundle