Skip to content

[WIP] feat: upgrade to vue 2.6 #487

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 10 commits into from
May 31, 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
8 changes: 4 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"presets": ["env"],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"presets": ["env"],
"plugins": ["transform-flow-strip-types"]
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-transform-flow-strip-types"]
}
}
}
}
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: node:9.5
- image: node:10.1.0
steps:
- checkout

Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

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
6 changes: 0 additions & 6 deletions __tests__/util/enttity-decoder.test.js

This file was deleted.

6 changes: 3 additions & 3 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function buildEntry(config) {

return rollup.rollup(config)
.then(bundle => bundle.generate(output))
.then(({ code }) => {
return write(file, code)
.then((res) => {
return write(file, res.output[0].code)
})
}

Expand Down Expand Up @@ -84,4 +84,4 @@ function copyHooks() {

fs.copyFileSync(sourcePath, targetPath);
});
}
}
154 changes: 91 additions & 63 deletions build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,84 +17,112 @@ const banner = (name, version) => `
* Released under the MIT license.
*/
`

// This is required because some of the third party plugins rely on this
// and cause errors since there is no process variable in {N}.
const intro = `
global.process = global.process || {}
global.process.env = global.process.env || {}
`

const resolveVue = p => {
return path.resolve(process.cwd(), 'node_modules', 'vue/src/', p) + '/'
return path.resolve(process.cwd(), 'node_modules', 'vue/src/', p) + '/'
}
const aliases = {
vue: resolveVue('core/index'),
compiler: resolveVue('compiler'),
web: resolveVue('platforms/web'),
core: resolveVue('core'),
shared: resolveVue('shared'),
sfc: resolveVue('sfc'),
//he: path.resolve(__dirname, 'node_modules', 'he', 'he')
he: path.resolve(__dirname, '..', 'platform/nativescript/util/entity-decoder')
vue: resolveVue('core/index'),
compiler: resolveVue('compiler'),
web: resolveVue('platforms/web'),
core: resolveVue('core'),
shared: resolveVue('shared'),
sfc: resolveVue('sfc'),
//he: path.resolve(__dirname, 'node_modules', 'he', 'he')
he: path.resolve(__dirname, '..', 'platform/nativescript/util/entity-decoder')
}

const builds = {
'nativescript-vue': {
entry: './platform/nativescript/framework.js',
dest: './dist/index.js',
moduleName: 'NativeScript-Vue',
banner: banner('NativeScript-Vue'),
external(id) {
return id.startsWith('tns-core-modules') || id.startsWith('weex')
}
'nativescript-vue': {
entry: './platform/nativescript/framework.js',
dest: './dist/index.js',
moduleName: 'NativeScript-Vue',
banner: banner('NativeScript-Vue'),
intro,
external(id) {
return id.startsWith('tns-core-modules') || id.startsWith('weex')
},
'nativescript-vue-template-compiler': {
entry: './platform/nativescript/compiler.js',
dest: './packages/nativescript-vue-template-compiler/index.js',
moduleName: 'NativeScript-Vue-Template-Compiler',
banner: banner('NativeScript-Vue-Template-Compiler'),
external: Object.keys(require('../packages/nativescript-vue-template-compiler/package.json').dependencies)
}
},
'nativescript-vue-template-compiler': {
entry: './platform/nativescript/compiler.js',
dest: './packages/nativescript-vue-template-compiler/index.js',
moduleName: 'NativeScript-Vue-Template-Compiler',
banner: banner('NativeScript-Vue-Template-Compiler'),
external: Object.keys(require('../packages/nativescript-vue-template-compiler/package.json').dependencies)
}
}


const genConfig = (name) => {
const opts = builds[name]
const config = {
input: opts.entry,
external: opts.external,
output: {
file: opts.dest,
format: opts.format || 'cjs',
banner: opts.banner,
name: opts.moduleName
},
treeshake: {
pureExternalModules: id => id.startsWith('weex')
},
watch: {
chokidar: false
},
plugins: [
replace({
__WEEX__: false,
__VERSION__: VueVersion,
'process.env.NODE_ENV': "'development'",
'let _isServer': 'let _isServer = false',
'process.env.VUE_VERSION': `'${VueVersion}'`,
'process.env.NS_VUE_VERSION': `'${NSVueVersion}'`
}),
flow(),
buble(),
alias(aliases),
resolve(),
commonjs(),
],
}
const opts = builds[name]
const config = {
input: opts.entry,
external: opts.external,
output: {
intro: opts.intro,
file: opts.dest,
format: opts.format || 'cjs',
banner: opts.banner,
name: opts.moduleName
},
// https://github.com/rollup/rollup/issues/2271#issuecomment-455129819
onwarn(warning) {
if (
warning.code === 'CIRCULAR_DEPENDENCY' && [
'vue',
'element-registry',
'patch' // v-template
].some(d => warning.importer.includes(d))
) {
return
} else if (
warning.message.includes('weex')
) {
return
}

console.warn(warning.message)
},
treeshake: {
pureExternalModules: id => id.startsWith('weex')
},
plugins: [
replace({
__WEEX__: false,
__VERSION__: VueVersion,
// 'process.env.NODE_ENV': "'development'",
'let _isServer': 'let _isServer = false',
// Vue 2.6 new slot syntax must be enabled via env.
'process.env.NEW_SLOT_SYNTAX': `true`,
'process.env.VBIND_PROP_SHORTHAND': `false`,
'process.env.VUE_VERSION': `process.env.VUE_VERSION || '${VueVersion}'`,
'process.env.NS_VUE_VERSION': `process.env.NS_VUE_VERSION || '${NSVueVersion}'`
}),
flow(),
buble(),
alias(aliases),
resolve(),
commonjs(),
],
}

Object.defineProperty(config, '_name', {
enumerable: false,
value: name
})
Object.defineProperty(config, '_name', {
enumerable: false,
value: name
})

return config;
return config;
}

if (process.env.TARGET) {
module.exports = genConfig(process.env.TARGET)
module.exports = genConfig(process.env.TARGET)
} else {
module.exports.getAllBuilds = () => Object.keys(builds).map(genConfig)
module.exports.getAllBuilds = () => Object.keys(builds).map(genConfig)
}
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
Loading