@@ -142,6 +142,31 @@ export function compileVueToRn(resource, filename = 'sfc.vue') {
142142 originalCodeCursor ++
143143 }
144144
145+ // Mapping the contents in between export default and script opening tag
146+
147+ let lineOfRVOptionsInOutput = getLineOfRVOptions ( output )
148+ let lineOfFirstImportInScript =
149+ getLineOfFirstImport ( parsedSFC . script . content ) + 1
150+ let lineOfExpDefaultInScript = scriptTagLineNumber
151+
152+ if ( lineOfFirstImportInScript !== 0 ) {
153+ while ( lineOfExpDefaultInScript >= lineOfFirstImportInScript ) {
154+ mappings . addMapping ( {
155+ source : mappings . _hashedFilename ,
156+ generated : {
157+ line : lineOfRVOptionsInOutput ,
158+ column : 0 ,
159+ } ,
160+ original : {
161+ line : lineOfExpDefaultInScript ,
162+ column : 0 ,
163+ } ,
164+ } )
165+ lineOfRVOptionsInOutput --
166+ lineOfExpDefaultInScript --
167+ }
168+ }
169+
145170 // add render funtion
146171 let beautifiedRender = beautify (
147172 addvm ( generatedTemplateCode . render , { indent_size : 2 } ) ,
@@ -283,6 +308,23 @@ function getLineOfExport(content) {
283308 } )
284309 return lineOfExport
285310}
311+
312+ function getLineOfFirstImport ( content ) {
313+ var lineOfImport = 0
314+ if ( ! content . includes ( 'import' ) ) {
315+ return - 1
316+ }
317+ content . split ( newLine ) . some ( ( line , index ) => {
318+ if ( line . includes ( 'import' ) ) {
319+ lineOfImport = index
320+ return true
321+ } else {
322+ return false
323+ }
324+ } )
325+ return lineOfImport
326+ }
327+
286328function getLineOfRVOptions ( content ) {
287329 var lineOfRVOptions = 0
288330 content . split ( newLine ) . some ( ( line , index ) => {
0 commit comments