Skip to content
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

support for Vue 2.6 #445

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .babelrc
@@ -1,8 +1,8 @@
{
"presets": ["env"],
"presets": ["@babel/preset-env"],
"env": {
"test": {
"presets": ["env"],
"presets": ["@babel/preset-env"],
"plugins": ["transform-flow-strip-types"]
}
}
Expand Down
5 changes: 2 additions & 3 deletions build/build.js
Expand Up @@ -37,11 +37,10 @@ function build(builds) {
function buildEntry(config) {
const output = config.output
const { file } = output

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
14 changes: 11 additions & 3 deletions build/config.js
Expand Up @@ -17,6 +17,12 @@ const banner = (name, version) => `
* Released under the MIT license.
*/
`
const intro = `
if (!this['process']) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug any reason you are not checking for global.process? In this case I believe it does the same thing, since we are in a global context - but still curious if there is something I'm not aware of! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well to be honest i am not sure how "process" is handled in Nativescript. What i know is that VueJs checks process and not global.process. That's why i used this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug process is not defined in NativeScript by default, and the reason we're adding it manually is that some vue plugins check for process.env which then causes issues since it's trying to access property env of undefined. Checking if it exists on global and then adding to it ensures that both global.process and just process are defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rigor789 VueJs 2.6 also uses it. So you are saying that i should do?:

if (!global['process']) {
  global.process = process = {env:{}}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug yeah that looks good to me, just change this['process'] to global['process']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, testing global.process

global.process = process = {env:{}}
}
`

const resolveVue = p => {
return path.resolve(process.cwd(), 'node_modules', 'vue/src/', p) + '/'
}
Expand All @@ -36,6 +42,7 @@ const builds = {
entry: './platform/nativescript/framework.js',
dest: './dist/index.js',
moduleName: 'NativeScript-Vue',
intro: intro,
banner: banner('NativeScript-Vue'),
external(id) {
return id.startsWith('tns-core-modules') || id.startsWith('weex')
Expand All @@ -57,6 +64,8 @@ const genConfig = (name) => {
input: opts.entry,
external: opts.external,
output: {
strict: false,
farfromrefug marked this conversation as resolved.
Show resolved Hide resolved
intro: opts.intro,
file: opts.dest,
format: opts.format || 'cjs',
banner: opts.banner,
Expand All @@ -72,10 +81,9 @@ const genConfig = (name) => {
replace({
__WEEX__: false,
__VERSION__: VueVersion,
'process.env.NODE_ENV': "'development'",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug Does this remove all the development related help messages that vue prints? If so - can this be re-enabled while developing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well it s the user choice by replacing within his weback config. that code was making the appear always, even in prod

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug alright, so as far as I understand this change, this should still allow the help messages to appear unless webpack sets the env to "production"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rigor789 indeed it will appear by default because it checks for NODE_ENV !== 'production' which is the case as NODE_ENV is not defined.
However that change allow the user tu define NODE_ENV to production when building for production, and thus remove all the warning.
It is just moved to userland

'let _isServer': 'let _isServer = false',
'process.env.VUE_VERSION': `'${VueVersion}'`,
'process.env.NS_VUE_VERSION': `'${NSVueVersion}'`
'process.env.VUE_VERSION': `process.env.VUE_VERSION || '${VueVersion}'`,
'process.env.NS_VUE_VERSION': `process.env.NS_VUE_VERSION || '${NSVueVersion}'`
}),
flow(),
buble(),
Expand Down
46 changes: 23 additions & 23 deletions package.json
Expand Up @@ -51,35 +51,35 @@
},
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^6.1.0",
"@commitlint/config-conventional": "^6.1.0",
"babel-jest": "^22.1.0",
"@babel/preset-env": "7.3.4",
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"babel-jest": "^24.1.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-env": "^1.6.1",
"chalk": "^2.3.0",
"commitizen": "^2.10.1",
"conventional-changelog-cli": "^1.3.14",
"chalk": "^2.4.2",
"commitizen": "^3.0.7",
"conventional-changelog-cli": "^2.0.12",
"cz-conventional-changelog": "^2.1.0",
"husky": "^0.15.0-rc.3",
"inquirer": "^5.0.1",
"jest": "^23.6.0",
"jest-junit": "^3.5.0",
"lint-staged": "^6.1.0",
"prettier": "^1.10.2",
"rollup": "^0.62.0",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-commonjs": "^9.1.3",
"husky": "^1.3.1",
"inquirer": "^6.2.2",
"jest": "^24.1.0",
"jest-junit": "^6.3.0",
"lint-staged": "^8.1.4",
"prettier": "^1.16.4",
"rollup": "^1.3.1",
"rollup-plugin-alias": "^1.5.1",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^9.2.1",
"rollup-plugin-flow-no-whitespace": "^1.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-resolve-aliases": "^0.2.0",
"rollup-watch": "^4.3.1",
"semver": "^5.5.0",
"set-value": "^2.0.0",
"tns-core-modules": "4.2.0",
"semver": "^5.6.0",
"set-value": "^3.0.0",
"tns-core-modules": "5.2.1",
"util-inspect": "^0.1.8",
"vue": "^2.5.17"
"vue": "^2.6.7"
},
"jest": {
"verbose": true,
Expand Down
3 changes: 2 additions & 1 deletion platform/nativescript/compiler.js
@@ -1,3 +1,4 @@
export { parseComponent } from './compiler/sfc/parser'
export { compile, compileToFunctions } from './compiler/index'
export { registerElement } from './element-registry'
// register all components
export { registerElement } from './compiler/element-registry'
2 changes: 1 addition & 1 deletion platform/nativescript/compiler/directives/model.js
@@ -1,5 +1,5 @@
import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
import { isKnownView, getViewMeta } from '../../element-registry'
import { isKnownView, getViewMeta } from '../../element-register'
import { addHandler, addAttr } from 'compiler/helpers'

export default function model(el, dir) {
Expand Down
211 changes: 211 additions & 0 deletions platform/nativescript/compiler/element-registry.js
@@ -0,0 +1,211 @@
import { registerElement } from '../element-register'
export { registerElement }

registerElement(
'AbsoluteLayout',
() => require('tns-core-modules/ui/layouts/absolute-layout').AbsoluteLayout
)
registerElement(
'ActivityIndicator',
() => require('tns-core-modules/ui/activity-indicator').ActivityIndicator
)
registerElement('Border', () => require('tns-core-modules/ui/border').Border)
registerElement('Button', () => require('tns-core-modules/ui/button').Button)
registerElement(
'ContentView',
() => require('tns-core-modules/ui/content-view').ContentView
)
registerElement(
'DatePicker',
() => require('tns-core-modules/ui/date-picker').DatePicker,
{
model: {
prop: 'date',
event: 'dateChange'
}
}
)
registerElement(
'DockLayout',
() => require('tns-core-modules/ui/layouts/dock-layout').DockLayout
)
registerElement(
'GridLayout',
() => require('tns-core-modules/ui/layouts/grid-layout').GridLayout
)
registerElement(
'HtmlView',
() => require('tns-core-modules/ui/html-view').HtmlView
)
registerElement('Image', () => require('tns-core-modules/ui/image').Image)
registerElement('img', () => require('tns-core-modules/ui/image').Image)
registerElement('Label', () => require('tns-core-modules/ui/label').Label)
registerElement(
'ListPicker',
() => require('tns-core-modules/ui/list-picker').ListPicker,
{
model: {
prop: 'selectedIndex',
event: 'selectedIndexChange'
}
}
)
registerElement(
'NativeActionBar',
() => require('tns-core-modules/ui/action-bar').ActionBar
)
registerElement(
'NativeActionItem',
() => require('tns-core-modules/ui/action-bar').ActionItem
)
registerElement(
'NativeListView',
() => require('tns-core-modules/ui/list-view').ListView
)
registerElement(
'NativeNavigationButton',
() => require('tns-core-modules/ui/action-bar').NavigationButton
)
registerElement('Page', () => require('tns-core-modules/ui/page').Page, {
skipAddToDom: true
})
registerElement(
'Placeholder',
() => require('tns-core-modules/ui/placeholder').Placeholder
)
registerElement(
'Progress',
() => require('tns-core-modules/ui/progress').Progress
)
registerElement(
'ProxyViewContainer',
() => require('tns-core-modules/ui/proxy-view-container').ProxyViewContainer
)
registerElement(
'Repeater',
() => require('tns-core-modules/ui/repeater').Repeater
)
registerElement(
'ScrollView',
() => require('tns-core-modules/ui/scroll-view').ScrollView
)
registerElement(
'SearchBar',
() => require('tns-core-modules/ui/search-bar').SearchBar,
{
model: {
prop: 'text',
event: 'textChange'
}
}
)
registerElement(
'SegmentedBar',
() => require('tns-core-modules/ui/segmented-bar').SegmentedBar,
{
model: {
prop: 'selectedIndex',
event: 'selectedIndexChange'
}
}
)
registerElement(
'SegmentedBarItem',
() => require('tns-core-modules/ui/segmented-bar').SegmentedBarItem
)
registerElement('Slider', () => require('tns-core-modules/ui/slider').Slider, {
model: {
prop: 'value',
event: 'valueChange'
}
})
registerElement(
'StackLayout',
() => require('tns-core-modules/ui/layouts/stack-layout').StackLayout
)
registerElement(
'FlexboxLayout',
() => require('tns-core-modules/ui/layouts/flexbox-layout').FlexboxLayout
)
registerElement('Switch', () => require('tns-core-modules/ui/switch').Switch, {
model: {
prop: 'checked',
event: 'checkedChange'
}
})

registerElement(
'NativeTabView',
() => require('tns-core-modules/ui/tab-view').TabView,
{
model: {
prop: 'selectedIndex',
event: 'selectedIndexChange'
}
}
)
registerElement(
'NativeTabViewItem',
() => require('tns-core-modules/ui/tab-view').TabViewItem,
{
skipAddToDom: true
}
)

registerElement(
'TextField',
() => require('tns-core-modules/ui/text-field').TextField
)
registerElement(
'TextView',
() => require('tns-core-modules/ui/text-view').TextView
)
registerElement(
'TimePicker',
() => require('tns-core-modules/ui/time-picker').TimePicker,
{
model: {
prop: 'time',
event: 'timeChange'
}
}
)
registerElement(
'WebView',
() => require('tns-core-modules/ui/web-view').WebView
)
registerElement(
'WrapLayout',
() => require('tns-core-modules/ui/layouts/wrap-layout').WrapLayout
)
registerElement(
'FormattedString',
() => require('text/formatted-string').FormattedString
)
registerElement('Span', () => require('text/span').Span)

registerElement(
'DetachedContainer',
() => require('tns-core-modules/ui/proxy-view-container').ProxyViewContainer,
{
skipAddToDom: true
}
)
registerElement(
'DetachedText',
() => require('tns-core-modules/ui/placeholder').Placeholder,
{
skipAddToDom: true
}
)
registerElement(
'Comment',
() => require('tns-core-modules/ui/placeholder').Placeholder
)
registerElement(
'Document',
() => require('tns-core-modules/ui/proxy-view-container').ProxyViewContainer,
{
skipAddToDom: true
}
)
4 changes: 2 additions & 2 deletions platform/nativescript/compiler/index.js
@@ -1,6 +1,6 @@
import { createCompiler } from 'compiler/index'
import { genStaticKeys } from 'shared/util'

import { registerElement } from '../element-register'
import modules from './modules/index'
import directives from './directives/index'

Expand All @@ -25,4 +25,4 @@ export const baseOptions = {
}

const { compile, compileToFunctions } = createCompiler(baseOptions)
export { compile, compileToFunctions }
export { compile, compileToFunctions, registerElement }
22 changes: 11 additions & 11 deletions platform/nativescript/compiler/modules/class.js
Expand Up @@ -4,17 +4,17 @@ import { parseText } from 'compiler/parser/text-parser'
function transformNode(el, options) {
const warn = options.warn || baseWarn
const staticClass = getAndRemoveAttr(el, 'class')
if (process.env.NODE_ENV !== 'production' && staticClass) {
const expression = parseText(staticClass, options.delimiters)
if (expression) {
warn(
`class="${staticClass}": ` +
'Interpolation inside attributes has been removed. ' +
'Use v-bind or the colon shorthand instead. For example, ' +
'instead of <div class="{{ val }}">, use <div :class="val">.'
)
}
}
// if (process.env.NODE_ENV !== 'production' && staticClass) {
// const expression = parseText(staticClass, options.delimiters)
// if (expression) {
// warn(
// `class="${staticClass}": ` +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug any reason this has been removed? Interpolation in attributes should not be used - and should be warned about

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it was a deprecation warning that was implying a regexp test on every transform node. Seemed like it was time to remove it. But i can bring it back if you prefer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug Just checked and it is still present in vue (web), so let's keep it there until even vue removes it! :)

https://github.com/vuejs/vue/blob/ebc1893faccd1a9d953a8e8feddcb49cf1b9004d/src/platforms/web/compiler/modules/class.js#L16-L22

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// 'Interpolation inside attributes has been removed. ' +
// 'Use v-bind or the colon shorthand instead. For example, ' +
// 'instead of <div class="{{ val }}">, use <div :class="val">.'
// )
// }
// }
if (staticClass) {
el.staticClass = JSON.stringify(staticClass)
}
Expand Down