File tree 3 files changed +1583
-1846
lines changed
3 files changed +1583
-1846
lines changed Original file line number Diff line number Diff line change @@ -170,10 +170,15 @@ var component = normalizer(
170
170
code += `\n` + genHotReloadCode ( id , hasFunctional , templateRequest )
171
171
}
172
172
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
+ } `
177
182
178
183
code += `\nexport default component.exports`
179
184
// console.log(code)
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ test('inherit queries on files', done => {
46
46
} )
47
47
} )
48
48
49
- test ( 'expose filename ' , done => {
49
+ test ( 'expose file path as __file outside production ' , done => {
50
50
mockBundleAndRun ( {
51
51
entry : 'basic.vue'
52
52
} , ( { module } ) => {
@@ -55,6 +55,21 @@ test('expose filename', done => {
55
55
} )
56
56
} )
57
57
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
+
58
73
test ( 'source map' , done => {
59
74
bundle ( {
60
75
entry : 'basic.vue' ,
You can’t perform that action at this time.
0 commit comments