@@ -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