File tree 2 files changed +19
-13
lines changed
2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -76,15 +76,16 @@ const loader: webpack.loader.Loader = function(source: string) {
76
76
const isServer = target === 'node'
77
77
const isProduction = mode === 'production'
78
78
79
- let descriptor
80
- try {
81
- descriptor = parse ( source , {
82
- filename : resourcePath ,
83
- sourceMap
79
+ const { descriptor, errors } = parse ( source , {
80
+ filename : resourcePath ,
81
+ sourceMap
82
+ } )
83
+
84
+ if ( errors . length ) {
85
+ errors . forEach ( err => {
86
+ formatError ( err , source , resourcePath )
87
+ loaderContext . emitError ( err )
84
88
} )
85
- } catch ( e ) {
86
- formatError ( e , source , resourcePath )
87
- loaderContext . emitError ( e )
88
89
return ``
89
90
}
90
91
@@ -125,7 +126,7 @@ const loader: webpack.loader.Loader = function(source: string) {
125
126
const attrsQuery = attrsToQuery ( descriptor . template . attrs )
126
127
const query = `?vue&type=template${ idQuery } ${ scopedQuery } ${ attrsQuery } ${ resourceQuery } `
127
128
templateRequest = stringifyRequest ( src + query )
128
- templateImport = `import render from ${ templateRequest } `
129
+ templateImport = `import { render } from ${ templateRequest } `
129
130
}
130
131
131
132
// script
Original file line number Diff line number Diff line change @@ -83,17 +83,22 @@ pitcher.pitch = function() {
83
83
84
84
// Rewrite request. Technically this should only be done when we have deduped
85
85
// loaders. But somehow this is required for block source maps to work.
86
- return genProxyModule ( loaders , context )
86
+ return genProxyModule ( loaders , context , query . type !== 'template' )
87
87
}
88
88
89
89
function genProxyModule (
90
90
loaders : Loader [ ] ,
91
- context : webpack . loader . LoaderContext
91
+ context : webpack . loader . LoaderContext ,
92
+ exportDefault = true
92
93
) {
93
94
const request = genRequest ( loaders , context )
94
95
// return a proxy module which simply re-exports everything from the
95
- // actual request.
96
- return `export { default } from ${ request } ; export * from ${ request } `
96
+ // actual request. Note for template blocks the compiled module has no
97
+ // default export.
98
+ return (
99
+ ( exportDefault ? `export { default } from ${ request } ; ` : `` ) +
100
+ `export * from ${ request } `
101
+ )
97
102
}
98
103
99
104
function genRequest ( loaders : Loader [ ] , context : webpack . loader . LoaderContext ) {
You can’t perform that action at this time.
0 commit comments