Skip to content

Commit 7504e28

Browse files
bfangerkazupon
authored andcommitted
When name isn’t specified use the filename as the component name. (vuejs#495)
Improves the Vue.js devtools experience, no more “< Anonymous Component >”
1 parent 03a3139 commit 7504e28

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/loader.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ module.exports = function (content) {
256256
// add filename in dev
257257
(isProduction ? '' : ('__vue_options__.__file = ' + JSON.stringify(filePath))) + '\n'
258258

259+
// add component name based on the filename
260+
exports +=
261+
'if(typeof __vue_options__.name === "undefined") {\n' +
262+
' __vue_options__.name = ' + JSON.stringify(path.parse(filePath).name) + '\n' +
263+
'}'
264+
259265
// add require for template
260266
var template = parts.template
261267
if (template) {

test/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ describe('vue-loader', function () {
107107
test({
108108
entry: './test/fixtures/basic.vue'
109109
}, function (window, module, rawModule) {
110+
expect(module.name).to.equal('basic')
110111
var vnode = mockRender(module, {
111112
msg: 'hi'
112113
})

0 commit comments

Comments
 (0)