@@ -73,12 +73,21 @@ export async function createSFCModule(source : string, filename : string, option
73
73
74
74
const hasScoped = descriptor . styles . some ( e => e . scoped ) ;
75
75
76
+ // https://github.com/vuejs/vue-loader/blob/b53ae44e4b9958db290f5918248071e9d2445d38/lib/runtime/componentNormalizer.js#L36
77
+ if ( hasScoped ) {
78
+ Object . assign ( component , { _scopeId : scopeId } ) ;
79
+ }
80
+
76
81
const compileTemplateOptions : TemplateCompileOptions = descriptor . template ? {
77
82
// hack, since sourceMap is not configurable an we want to get rid of source-map dependency. see genSourcemap
78
83
source : descriptor . template . content ,
79
84
filename,
80
85
compiler : vueTemplateCompiler as VueTemplateCompiler ,
81
- compilerOptions : undefined ,
86
+ compilerOptions : {
87
+ outputSourceRange : true ,
88
+ scopeId : hasScoped ? scopeId : null ,
89
+ comments : true
90
+ } as any ,
82
91
preprocessLang : descriptor . template . lang ,
83
92
isProduction : isProd ,
84
93
prettify : false
@@ -139,7 +148,7 @@ export async function createSFCModule(source : string, filename : string, option
139
148
140
149
const template = sfc_compileTemplate ( compileTemplateOptions ) ;
141
150
// "@vue/component-compiler-utils" does NOT assume any module system, and expose render in global scope.
142
- template . code += "\nmodule.exports = {render: render, staticRenderFns: staticRenderFns}"
151
+ template . code += `\nexport { render, staticRenderFns }`
143
152
144
153
if ( template . errors . length ) {
145
154
0 commit comments