Skip to content

Commit 9a90f9f

Browse files
author
Guillaume Chau
committed
Fixed component auto naming
1 parent 3d1ea62 commit 9a90f9f

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

packages/vue-component/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.10.3 -2017-07-16
4+
5+
- Fixed component auto naming
6+
37
## 0.10.1 - 2017-07-15
48

59
- Support `>>>` and `/deep/` scope-piercing combinators inside `<style scoped>`

packages/vue-component/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package.describe({
22
name: 'akryum:vue-component',
3-
version: '0.10.2',
3+
version: '0.10.3',
44
summary: 'VueJS single-file components that hot-reloads',
55
git: 'https://github.com/Akryum/meteor-vue-component',
66
documentation: 'README.md'

packages/vue-component/plugin/vue-compiler.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,31 @@ function generateJs (vueId, inputFile, compileResult, isHotReload = false) {
635635
// Package context
636636
js += `__vue_options__.packageName = '${inputFile.getPackageName()}';`;
637637

638+
// Auto register
639+
let isGlobalName = globalFileNameReg.test(inputFilePath);
640+
let ext = (isGlobalName ? '.global' : '') + '.vue';
641+
642+
let name = Plugin.path.basename(inputFilePath);
643+
name = name.substring(0, name.lastIndexOf(ext));
644+
645+
// Remove special characters
646+
name = name.replace(nonWordCharReg, match => {
647+
if (match !== '-') {
648+
return ''
649+
} else {
650+
return match
651+
}
652+
});
653+
654+
// Kebab case
655+
name = name.replace(capitalLetterReg, (match) => {
656+
return '-' + match.toLowerCase();
657+
});
658+
name = name.replace(trimDashReg, '');
659+
660+
// Auto default name
661+
js += `\n__vue_options__.name = __vue_options__.name || '${name}';`
662+
638663
// Export
639664
js += `module.export('default', exports.default = __vue_script__);exports.__esModule = true;`;
640665

@@ -649,30 +674,6 @@ function generateJs (vueId, inputFile, compileResult, isHotReload = false) {
649674
}`;
650675
}
651676

652-
// Auto register
653-
let isGlobalName = globalFileNameReg.test(inputFilePath);
654-
let ext = (isGlobalName ? '.global' : '') + '.vue';
655-
656-
let name = Plugin.path.basename(inputFilePath);
657-
name = name.substring(0, name.lastIndexOf(ext));
658-
659-
// Remove special characters
660-
name = name.replace(nonWordCharReg, match => {
661-
if (match !== '-') {
662-
return ''
663-
} else {
664-
return match
665-
}
666-
});
667-
668-
// Kebab case
669-
name = name.replace(capitalLetterReg, (match) => {
670-
return '-' + match.toLowerCase();
671-
});
672-
name = name.replace(trimDashReg, '');
673-
674-
// Auto default name
675-
js += `\n__vue_options__.name = __vue_options__.name || '${name}';`
676677
let isOutsideImports = inputFilePath.split('/').indexOf('imports') === -1;
677678
if (isOutsideImports || isGlobalName) {
678679
// Component registration

0 commit comments

Comments
 (0)