File tree 4 files changed +30
-4
lines changed
4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ export default class TemplateRenderer {
224
224
if ( this . clientManifest ) {
225
225
const initial = this . preloadFiles . filter ( ( { file } ) => isJS ( file ) )
226
226
const async = ( this . getUsedAsyncFiles ( context ) || [ ] ) . filter ( ( { file } ) => isJS ( file ) )
227
- const needed = [ initial [ 0 ] ] . concat ( async , initial . slice ( 1 ) )
227
+ const needed = [ ] . concat ( initial [ 0 ] ? [ initial [ 0 ] ] : [ ] , async , initial . slice ( 1 ) ) ;
228
228
return needed . map ( ( { file } ) => {
229
229
return `<script src="${ this . publicPath } ${ file } " defer></script>`
230
230
} ) . join ( '' )
Original file line number Diff line number Diff line change 1
1
const hash = require ( 'hash-sum' )
2
2
const uniq = require ( 'lodash.uniq' )
3
3
import { isJS , isCSS , onEmit } from './util'
4
+ import { isObject } from 'shared/util'
4
5
5
6
export default class VueSSRClientPlugin {
6
7
constructor ( options = { } ) {
@@ -19,6 +20,13 @@ export default class VueSSRClientPlugin {
19
20
const initialFiles = uniq ( Object . keys ( stats . entrypoints )
20
21
. map ( name => stats . entrypoints [ name ] . assets )
21
22
. reduce ( ( assets , all ) => all . concat ( assets ) , [ ] )
23
+ . map ( file => {
24
+ if ( isObject ( file ) && file . name ) {
25
+ return file . name ;
26
+ } else {
27
+ return file ;
28
+ }
29
+ } )
22
30
. filter ( ( file ) => isJS ( file ) || isCSS ( file ) ) )
23
31
24
32
const asyncFiles = allFiles
Original file line number Diff line number Diff line change 1
1
import { validate , isJS , onEmit } from './util'
2
+ import { isObject } from 'shared/util'
2
3
3
4
export default class VueSSRServerPlugin {
4
5
constructor ( options = { } ) {
@@ -20,7 +21,14 @@ export default class VueSSRServerPlugin {
20
21
return cb ( )
21
22
}
22
23
23
- const entryAssets = entryInfo . assets . filter ( isJS )
24
+ const entryAssets = entryInfo . assets
25
+ . map ( file => {
26
+ if ( isObject ( file ) && file . name ) {
27
+ return file . name ;
28
+ } else {
29
+ return file ;
30
+ }
31
+ } ) . filter ( isJS )
24
32
25
33
if ( entryAssets . length > 1 ) {
26
34
throw new Error (
@@ -45,6 +53,9 @@ export default class VueSSRServerPlugin {
45
53
stats . assets . forEach ( asset => {
46
54
if ( isJS ( asset . name ) ) {
47
55
bundle . files [ asset . name ] = compilation . assets [ asset . name ] . source ( )
56
+ if ( asset . info && asset . info . related && asset . info . related . sourceMap ) {
57
+ bundle . maps [ asset . info . related . sourceMap . replace ( / \. m a p $ / , '' ) ] = JSON . parse ( compilation . assets [ asset . info . related . sourceMap ] . source ( ) ) ;
58
+ }
48
59
} else if ( asset . name . match ( / \. j s \. m a p $ / ) ) {
49
60
bundle . maps [ asset . name . replace ( / \. m a p $ / , '' ) ] = JSON . parse ( compilation . assets [ asset . name ] . source ( ) )
50
61
}
Original file line number Diff line number Diff line change @@ -9,8 +9,15 @@ export const validate = compiler => {
9
9
warn ( 'webpack config `target` should be "node".' )
10
10
}
11
11
12
- if ( compiler . options . output && compiler . options . output . libraryTarget !== 'commonjs2' ) {
13
- warn ( 'webpack config `output.libraryTarget` should be "commonjs2".' )
12
+ if ( compiler . options . output ) {
13
+ // Webpack < 5.0.0
14
+ if ( compiler . options . output . libraryTarget && compiler . options . output . libraryTarget !== 'commonjs2' ) {
15
+ warn ( 'webpack config `output.libraryTarget` should be "commonjs2".' )
16
+ }
17
+ // Webpack >= 5.0.0
18
+ else if ( compiler . options . output . library && compiler . options . output . library . type !== 'commonjs2' ) {
19
+ warn ( 'webpack config `output.libraryTarget` should be "commonjs2".' )
20
+ }
14
21
}
15
22
16
23
if ( ! compiler . options . externals ) {
You can’t perform that action at this time.
0 commit comments