File tree Expand file tree Collapse file tree 3 files changed +1583
-1846
lines changed Expand file tree Collapse file tree 3 files changed +1583
-1846
lines changed Original file line number Diff line number Diff line change @@ -170,10 +170,15 @@ var component = normalizer(
170170 code += `\n` + genHotReloadCode ( id , hasFunctional , templateRequest )
171171 }
172172
173- // Expose filename. This is used by the devtools and vue runtime warnings.
174- if ( ! isProduction ) {
175- code += `\ncomponent.options.__file = ${ JSON . stringify ( rawShortFilePath ) } `
176- }
173+ // Expose filename. This is used by the devtools and Vue runtime warnings.
174+ code += `\ncomponent.options.__file = ${
175+ isProduction
176+ // For security reasons, only expose the file's basename in production.
177+ ? JSON . stringify ( filename )
178+ // Expose the file's full path in development, so that it can be opened
179+ // from the devtools.
180+ : JSON . stringify ( rawShortFilePath )
181+ } `
177182
178183 code += `\nexport default component.exports`
179184 // console.log(code)
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ test('inherit queries on files', done => {
4646 } )
4747} )
4848
49- test ( 'expose filename ' , done => {
49+ test ( 'expose file path as __file outside production ' , done => {
5050 mockBundleAndRun ( {
5151 entry : 'basic.vue'
5252 } , ( { module } ) => {
@@ -55,6 +55,21 @@ test('expose filename', done => {
5555 } )
5656} )
5757
58+ test ( 'expose file basename as __file in production' , done => {
59+ const origNodeEnv = process . env . NODE_ENV
60+ process . env . NODE_ENV = 'production'
61+ mockBundleAndRun (
62+ {
63+ entry : 'basic.vue'
64+ } ,
65+ ( { module } ) => {
66+ expect ( module . __file ) . toBe ( 'basic.vue' )
67+ process . env . NODE_ENV = origNodeEnv
68+ done ( )
69+ }
70+ )
71+ } )
72+
5873test ( 'source map' , done => {
5974 bundle ( {
6075 entry : 'basic.vue' ,
You can’t perform that action at this time.
0 commit comments