2021-01-11 19:22

Don't bundle Vue with nativescript-vue

We should not bundle Vue with nativescript-vue, and use the version installed in the {N} app.

Vue uses aliases internally, which fail when required directly, a possible solution would be to bundle on the app side via a hook.

Even though it's not recommended by Vue to use internal parts, seems like we have to use them, since some functions / utils / parts are not exported in the bundled Vue files.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • weixin_39869791 weixin_39869791 4月前

    Closing because at this point we are not able to do this, will re-visit once Vue is broken up into smaller pieces according to plans.

    点赞 评论 复制链接分享
  • weixin_39700215 weixin_39700215 4月前

    We are locking this issue because it has been closed for more than 14 days.

    If the issue comes up again please open a new issue with additional details.

    点赞 评论 复制链接分享
  • weixin_39542850 weixin_39542850 4月前

    Which internals do you need access to?

    点赞 评论 复制链接分享
  • weixin_39869791 weixin_39869791 4月前

    For example in https://github.com/rigor789/nativescript-vue/blob/master/nativescript-vue/platform/nativescript/runtime/patch.js I'm importing createPatchFunction from core. Or https://github.com/rigor789/nativescript-vue/blob/master/nativescript-vue/platform/nativescript/compiler.js exports directly from vue core. These things should be left unexported though. I think, it is very rare that someone would actually need to use these.

    Only issue with this is that it requires me to set up a roll-up config that sets up the same aliases as vue, so when bundling I don't get errors of unknown modules due to aliases.

    点赞 评论 复制链接分享
  • weixin_39542850 weixin_39542850 4月前

    Understood. I agree and also don't see a better alternative, though granted, I have a very limited understanding of NativeScript.

    点赞 评论 复制链接分享
  • weixin_39603132 weixin_39603132 4月前

    I'm more familiar with how we do things in Angular + NativeScript, which is to use elements of Angular/core with NativeScript's bridge to Angular, as set up in package.json like this:

    "dependencies": {
        "/common": "4.1.1",
        "/compiler": "4.1.1",
        "/core": "4.1.1",
        "/forms": "4.1.1",
        "/http": "4.1.1",
        "/platform-browser": "4.1.1",
        "/platform-browser-dynamic": "4.1.1",
        "/router": "4.1.1",
        "nativescript-angular": "3.0.0",
        "nativescript-ngx-fonticon": "~2.2.0",
        "reflect-metadata": "~0.1.10",
        "rxjs": "~5.3.1",
        "tns-core-modules": "3.0.0",
        "zone.js": "~0.8.10"

    --can we follow a similar strategy with Vue? ?

    点赞 评论 复制链接分享
  • weixin_39869791 weixin_39869791 4月前

    Unfortunately, vue doesn't utilize sub modules like angular does.

    On one hand it really does make it harder to integrate, but on the other hand from a end user perspective I'd much rather have one dependency, than multiple that I have to keep track of.

    点赞 评论 复制链接分享
  • weixin_39542850 weixin_39542850 4月前

    Anything that ties into Vue internals and we expose as an independent package will be here. That includes a template compiler and server renderer.

    The vue-loader package is a great place to look for an example of consuming the template compiler, parsing single-file components, etc.

    点赞 评论 复制链接分享
  • weixin_39869791 weixin_39869791 4月前

    One of the possible solutions to not having to bundle Vue is if there was an official package for creating custom renderers. I opened an thread in the vue repository to get the conversation going: https://github.com/vuejs/vue/issues/7005

    点赞 评论 复制链接分享