Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit 541a824

Browse files
committed
fix: Use basename for __file in production mode
1 parent 8ef7d8f commit 541a824

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/assembler.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SourceMapGenerator } from 'source-map'
22
import { SFCCompiler, DescriptorCompileResult } from './compiler'
33
import { merge } from './source-map'
4+
import * as path from 'path'
45

56
// const merge = require('merge-source-map')
67

@@ -221,9 +222,8 @@ export function assembleFromSource(
221222
) {
222223
const component = (typeof script === 'function' ? script.options : script) || {}
223224
224-
if (${e(!compiler.template.isProduction)}) {
225-
component.__file = ${e(filename)}
226-
}
225+
// For security concerns, we use only base name in production mode.
226+
component.__file = ${compiler.template.isProduction ? e(path.basename(filename)) : e(filename)}
227227
228228
if (!component.render) {
229229
component.render = template.render
@@ -302,7 +302,7 @@ export function assembleFromSource(
302302
.replace('var staticRenderFns =', 'var __vue_staticRenderFns__ =')
303303
.replace('render._withStripped =', '__vue_render__._withStripped =')}
304304
/* style */
305-
const __vue_inject_styles__ = ${hasStyle} ? function (inject) {
305+
const __vue_inject_styles__ = ${hasStyle ? `function (inject) {
306306
if (!inject) return
307307
${styles.map((style, index) => {
308308
const source = IDENTIFIER.test(style.source)
@@ -333,7 +333,7 @@ export function assembleFromSource(
333333
: '')
334334
)
335335
})}
336-
} : undefined
336+
}` : 'undefined'}
337337
/* scoped */
338338
const __vue_scope_id__ = ${hasScopedStyle ? e(scopeId) : 'undefined'}
339339
/* module identifier */

0 commit comments

Comments
 (0)