require-vuejs icon indicating copy to clipboard operation
require-vuejs copied to clipboard

customize "vue!"

Open williamsharkey opened this issue 7 years ago • 4 comments

I found it slightly confusing when starting to use this library because the main app.js would require both Vue (the standard library) and vue (this project which is for requiring vue).

I was wondering if one may customize the name of "vue" to make it more obvious. For example, change:

  paths: {
    "Vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.1/vue",          //for dev
    "vue": "https://rawgit.com/edgardleal/require-vue/master/dist/require-vuejs",
  },

into:

  paths: {
    "Vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.1/vue",          //for dev
    "reqV": "https://rawgit.com/edgardleal/require-vue/master/dist/require-vuejs",
  },

So instead of using vue! you could use reqV!, if you prefer.

I tried this and it breaks require-vuejs. The error I see in my browser console:

require.js:968 Uncaught TypeError: Cannot read property 'normalize' of undefined
    at b.<anonymous> (require.js:968)
    at require.js:134
    at require.js:1189
    at each (require.js:59)
    at b.emit (require.js:1188)
    at b.check (require.js:938)
    at b.enable (require.js:1176)
    at b.init (require.js:788)
    at h (require.js:1203)
    at Object.completeLoad (require.js:1611)

Is there a reason why the name "vue!" shouldn't be customizable? Granite, I don't have much experience with require.js, and I don't know the "right" way to do things.

williamsharkey avatar Dec 20 '17 16:12 williamsharkey

I will work on it and tell you when it is ready. Thank you again for your feedback.

edgardleal avatar Dec 20 '17 20:12 edgardleal

Here is where i register the component vue In your code you can do some thing like this:

Create a file named reqV.js :

define( ['vue'], function(plugin) {
      return plugin;
});

Now you can import your components using this code:

  define(["reqV!componentA", "reqV!componentB"], function(A, B) {

  });

This is not the better way to do this, but i will try to find some thing better.

edgardleal avatar Dec 22 '17 18:12 edgardleal

Thanks, that gives me a better understanding. Also, don't feel obliged to work on this issue, it is not a huge deal. If I have some extra time I may work on it and send a pull request. I think this project is small enough that it should not be so difficult for outsiders to make contributions. Thanks again, Wm

williamsharkey avatar Dec 23 '17 13:12 williamsharkey

Ok. Thanks !

edgardleal avatar Dec 26 '17 12:12 edgardleal