File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 11module . exports = function normalizeComponent (
2- scriptExports ,
2+ rawScriptExports ,
33 compiledTemplate ,
44 scopeId ,
55 cssModules
66) {
7- scriptExports = scriptExports || { }
7+ var esModule
8+ var scriptExports = rawScriptExports = rawScriptExports || { }
89
910 // ES6 modules interop
10- var type = typeof scriptExports . default
11+ var type = typeof rawScriptExports . default
1112 if ( type === 'object' || type === 'function' ) {
12- // check named exports
13- if ( process . env . NODE_ENV !== 'production' ) {
14- if ( Object . keys ( scriptExports ) . some ( function ( key ) {
15- return key !== 'default' && key !== '__esModule'
16- } ) ) {
17- console . error ( 'named exports are not supported in *.vue files.' )
18- }
19- }
20- scriptExports = scriptExports . default
13+ esModule = rawScriptExports
14+ scriptExports = rawScriptExports . default
2115 }
2216
2317 // Vue.extend constructor export interop
@@ -46,6 +40,7 @@ module.exports = function normalizeComponent (
4640 }
4741
4842 return {
43+ esModule : esModule ,
4944 exports : scriptExports ,
5045 options : options
5146 }
Original file line number Diff line number Diff line change @@ -299,6 +299,13 @@ module.exports = function (content) {
299299 if ( ! isProduction ) {
300300 // add filename in dev
301301 output += 'Component.options.__file = ' + JSON . stringify ( filePath ) + '\n'
302+ // check named exports
303+ output +=
304+ 'if (Component.esModule && Object.keys(Component.esModule).some(function (key) {' +
305+ 'return key !== "default" && key !== "__esModule"' +
306+ '})) {' +
307+ 'console.error("named exports are not supported in *.vue files.")' +
308+ '}\n'
302309 // check functional components used with templates
303310 if ( template ) {
304311 output +=
You can’t perform that action at this time.
0 commit comments