@@ -106,7 +106,7 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) {
106
106
// slightly differently.
107
107
let runner // lazy creation so that errors can be caught by user
108
108
let initialContext
109
- return ( userContext = { } ) => new Promise ( ( resolve , reject ) => {
109
+ return ( userContext = { } ) => new Promise ( resolve => {
110
110
if ( ! runner ) {
111
111
const sandbox = runInNewContext === 'once'
112
112
? createSandbox ( )
@@ -126,27 +126,25 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) {
126
126
}
127
127
}
128
128
userContext . _registeredComponents = new Set ( )
129
+
129
130
// vue-style-loader styles imported outside of component lifecycle hooks
130
131
if ( initialContext . _styles ) {
131
132
userContext . _styles = deepClone ( initialContext . _styles )
132
- }
133
- // #6353 after the app is resolved, if the userContext doesn't have a
134
- // styles property, it means the app doesn't have any lifecycle-injected
135
- // styles, so vue-style-loader never defined the styles getter.
136
- // just expose the same styles from the initialContext.
137
- const exposeStylesAndResolve = app => {
138
- if ( ! userContext . hasOwnProperty ( 'styles' ) ) {
139
- userContext . styles = initialContext . styles
133
+ // #6353 ensure "styles" is exposed even if no styles are injected
134
+ // in component lifecycles.
135
+ // the renderStyles fn is exposed by vue-style-loader >= 3.0.3
136
+ const renderStyles = initialContext . _renderStyles
137
+ if ( renderStyles ) {
138
+ Object . defineProperty ( userContext , 'styles' , {
139
+ enumerable : true ,
140
+ get ( ) {
141
+ return renderStyles ( userContext . _styles )
142
+ }
143
+ } )
140
144
}
141
- resolve ( app )
142
145
}
143
146
144
- const res = runner ( userContext )
145
- if ( typeof res . then === 'function' ) {
146
- res . then ( exposeStylesAndResolve ) . catch ( reject )
147
- } else {
148
- exposeStylesAndResolve ( res )
149
- }
147
+ resolve ( runner ( userContext ) )
150
148
} )
151
149
}
152
150
}
0 commit comments