@@ -2,28 +2,24 @@ import evalInContext from "./evalInContext";
22import requireAtRuntime from "./requireAtRuntime" ;
33
44export default function getVueConfigObject ( compiledCode , listVars , requires ) {
5- const exampleComponentCode = `
6- let __component__ = {}
7-
8- // When we do new Vue({name: 'MyComponent'}) the comfig object
9- // is set to __component__
10- function Vue(params){ __component__ = params; }
11- eval(${ JSON . stringify (
12- `${
13- // run script for SFC and full scripts
14- // and set config object in __component__
15- // if the structure is vsg mode, define local variables
16- // to set them up in the next step
17- compiledCode
18- } ;__component__.data = __component__.data || function() {return {${
19- // add local vars in data
20- // this is done through an object like {varName: varName}
21- // since each varName is defined in compiledCode, it can be used to init
22- // the data object here
23- listVars . map ( varName => `${ varName } : ${ varName } ` ) . join ( "," )
24- } };};`
25- ) } );
26- return __component__;` ;
5+ const exampleComponentCode = `let __component__ = {};${
6+ // run script for SFC and full scripts
7+ // and set config object in __component__
8+ // if the structure is vsg mode, define local variables
9+ // to set them up in the next step
10+ compiledCode
11+ } ;__component__.data = __component__.data || function() {return {${
12+ // add local vars in data
13+ // this is done through an object like {varName: varName}
14+ // since each varName is defined in compiledCode, it can be used to init
15+ // the data object here
16+ listVars . map ( varName => `${ varName } : ${ varName } ` ) . join ( "," )
17+ } }};${
18+ // When we do new Vue({name: 'MyComponent'}) the comfig object
19+ // is set to __component__
20+ `function Vue(params){ __component__ = params; }
21+ return __component__;`
22+ } `;
2723 return evalInContext ( exampleComponentCode , filepath =>
2824 requireAtRuntime ( requires , filepath )
2925 ) ;
0 commit comments