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

Vue JSX does not support spread. #25

Closed
nickmessing opened this issue Jul 20, 2017 · 2 comments
Closed

Vue JSX does not support spread. #25

nickmessing opened this issue Jul 20, 2017 · 2 comments

Comments

@nickmessing
Copy link

When using spread vue's JSX transform adds an import which can not be handled at the moment. You can replicate that by trying:

const App = {
  data: () => ({
  	sel: 2
  }),
  render() {
    return (
      <input type="checkbox" {...{}} />
    );
  }
}

new Vue({
  el: '#app',
  render: h => h(App)
})
@egoist
Copy link
Owner

egoist commented Jul 20, 2017

I just added a view compiled button so that you could know what happened behind the scene more easily:

2017-07-20 4 49 48

2017-07-20 4 49 37

I guess we can simply:

import merge from '!somehow-load-as-umd-loader!babel-helper-vue-jsx-merge-props'

transformedCode.replace(/import _mergeJSXProps from "babel-helper-vue-jsx-merge-props";/, merge)

Do you have any better idea?

@nickmessing
Copy link
Author

nickmessing commented Jul 20, 2017

I was thinking of:

import('babel-helper-vue-jsx-merge-props').then(vueMergeJSXProps => window.vueMergeJSXProps = vueMergeJSXProps)

/*...*/

transformedCode.replace(/import ([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*) from ['"]babel-helper-vue-jsx-merge-props['"];?/, 'const $1 = window.vueMergeJSXProps')

I guess " and ; are not likely to disappear but babel's naming is unpredictable with their versions and should be universal.

@egoist egoist closed this as completed in 78a6fd1 Jul 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants