Skip to content

Samples refactoring to use a bundle app with webpack and support HMR and .vue files #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ After cloning the repo, run:
# Commonly used NPM scripts

```bash
$ # watch and auto re-build samples/app/nativescript-vue.js
$ # watch and auto re-build dist/index.js
$ npm run dev
```

Expand All @@ -39,6 +39,8 @@ To test the sample applications provided in the repository, you need to `npm run

Next, open up a new terminal window and run `npm run samples`. This will bring up a list of all the available sample applications which you can choose from with your arrow keys. Pressing enter/return will select that sample, and prompt you to choose the platform you'd like to run the sample on. After selecting the platform the application should start on your emulator, and the output will be in your terminal.

If you want to test the sample apps with HMR activated, please run `npm run samples -- --hmr` instead. Actually, we can pass any arguments to the `tns debug platform` command placing them after the `--` separator.

# Project Structure

- `build`: Directory for the custom tooling for managing and building the project
Expand All @@ -57,7 +59,7 @@ Next, open up a new terminal window and run `npm run samples`. This will bring u

There is [currently] a bug in devDependencies husky 0.15 beta that aborts `npm install` if `.git/hooks` is missing.

https://github.com/typicode/husky/issues/195
https://github.com/typicode/husky/issues/195

```
> husky@0.15.0-rc.3 postinstall /.../nativescript-vue/node_modules/husky
Expand Down
5 changes: 3 additions & 2 deletions build/sample-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const samplePackage = require('../samples/app/package.json')
const originalMain = samplePackage.main

let tns
let args = process.argv.slice(2)

const files = fs
.readdirSync(path.resolve(__dirname, '../samples/app'))
Expand Down Expand Up @@ -40,11 +41,11 @@ inquirer
})

function runPlatform(platform) {
tns = spawn('tns', ['debug', platform], {
tns = spawn('tns', ['debug', platform, '--syncAllFiles', '--bundle'].concat(args), {
cwd: path.resolve(__dirname, '../samples')
})

tns.on('error', err => console.log(err))
tns.on('error', err => console.error(err))
tns.stdout.on('data', data => process.stdout.write(platform + ': ' +data))
}

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"test": "jest",
"tdd": "jest --watch",
"samples": "node build/sample-runner.js",
"dev": "rollup -c build/config.js -w --o samples/app/nativescript-vue.js --environment TARGET:nativescript-vue",
"dev:dist": "rollup -c build/config.js -w --o dist/index.js --environment TARGET:nativescript-vue",
"dev": "rollup -c build/config.js -w --o dist/index.js --environment TARGET:nativescript-vue",
"build": "node build/build.js",
"build:docs": "cd docs && npm run build",
"prettier": "prettier --no-semi --single-quote --write \"{{platform,__test__}/**/*.js,samples/app/*.js}\"",
Expand Down
2 changes: 1 addition & 1 deletion samples/app/127.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/171.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.silent = false

Expand Down
2 changes: 1 addition & 1 deletion samples/app/217.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/220.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/229.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.silent = false

Expand Down
2 changes: 1 addition & 1 deletion samples/app/231.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.silent = false

Expand Down
2 changes: 1 addition & 1 deletion samples/app/240.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/272.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/339.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/344.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueDevtools = require('nativescript-vue-devtools')
Vue.use(VueDevtools)
Vue.config.debug = true
Expand Down
4 changes: 2 additions & 2 deletions samples/app/445.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand All @@ -14,7 +14,7 @@ new Vue({
template: `
<StackLayout :color="counter < 5 ? 'red' : 'blue'">
<slot :counter="counter"/>

<Button text="+1" @tap="counter++"/>
</StackLayout>
`
Expand Down
2 changes: 1 addition & 1 deletion samples/app/76.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-to-check-android-events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const application = require('tns-core-modules/application')
const platform = require('tns-core-modules/platform')

Expand Down
15 changes: 15 additions & 0 deletions samples/app/app-to-check-hmr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Vue = require('nativescript-vue')
const application = require('tns-core-modules/application')
const platform = require('tns-core-modules/platform')

Vue.config.silent = false
Vue.config.debug = true

import Home from './components/Home'

new Vue({
components: {
Home
},
render: h => h('frame', [h(Home)])
}).$start()
13 changes: 13 additions & 0 deletions samples/app/app-to-check-v-slot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const Vue = require('nativescript-vue')

Vue.config.silent = false
Vue.config.debug = true

import VSlot from './components/VSlot'

new Vue({
components: {
VSlot
},
render: h => h('frame', [h(VSlot)])
}).$start()
2 changes: 1 addition & 1 deletion samples/app/app-with-all-components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const frame = require('tns-core-modules/ui/frame')
const platform = require('tns-core-modules/platform')
const utils = require('tns-core-modules/utils/utils')
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-android-ios.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

new Vue({
template: `
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-formatted-string.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

new Vue({
template: `
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-frame.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueDevtools = require('nativescript-vue-devtools')

Vue.use(VueDevtools)
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-frames.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.silent = false
Vue.config.debug = true
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-gauge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('vue-router')
const application = require('tns-core-modules/application')
const observable_array = require('tns-core-modules/data/observable-array')
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-http-requests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const http = require('http')

Vue.config.debug = true
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-list-view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const http = require('http')

Vue.config.debug = true
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-nested-object-list-view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

new Vue({
template: `
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-ns-router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('vue-router')

Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-page-routing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('vue-router')

Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-pager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const Pager = require('nativescript-pager/vue')

Vue.use(Pager)
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-pages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true
Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-radsidedrawer-tabs-and-router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('vue-router')
const application = require('tns-core-modules/application')

Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-router-component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('./vue-router')

Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-router-pages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('vue-router')

Vue.use(VueRouter)
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-router-v2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('vue-router')

Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueRouter = require('vue-router')

Vue.config.silent = false
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-shared-actionbar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const VueDevtools = require('nativescript-vue-devtools')

Vue.use(VueDevtools)
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-tab-view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.debug = true

Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-v-template-components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.config.silent = false
Vue.config.debug = true
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-v-template.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

new Vue({
data() {
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-view-directive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.registerElement(
'RadSideDrawer',
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-vmodel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

new Vue({
data: {
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app-with-vuex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')
const Vuex = require('vuex')

Vue.use(Vuex)
Expand Down
2 changes: 0 additions & 2 deletions samples/app/app.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import 'nativescript-theme-core/css/core.light.css';

/* Your CSS goes here */

.even {
Expand Down
2 changes: 1 addition & 1 deletion samples/app/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Vue = require('./nativescript-vue')
const Vue = require('nativescript-vue')

Vue.component('image-viewer', {
props: ['imgSrc'],
Expand Down
16 changes: 16 additions & 0 deletions samples/app/components/ComponentWithSlot.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<StackLayout :color="counter < 5 ? 'red' : 'blue'">
<slot :counter="counter"/>
<Button text="+1" @tap="counter++"/>
</StackLayout>
</template>

<script>
export default {
data() {
return {
counter: 0
}
},
}
</script>
23 changes: 23 additions & 0 deletions samples/app/components/Details.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<Page>
<ActionBar class="action-bar" title="Details Page">
<ActionItem text="Action"></ActionItem>
</ActionBar>
<StackLayout>
<Label :text="'Details ' + Math.random()" />
<Button text="another" @tap="openDetails" />
<Button text="back" @tap="goBack" />
</StackLayout>
</Page>
</template>

<script>
const page = {
methods: {
openDetails() {
this.$navigateTo(page)
}
}
}
export default page;
</script>
Loading