@@ -17,7 +17,7 @@ module.exports = function workerLoaderPlugin(config = null) {
17
17
return {
18
18
name : 'worker-loader' ,
19
19
20
- options : options => {
20
+ options ( options ) {
21
21
if ( ! projectOptions ) {
22
22
projectOptions = Object . assign ( { } , options ) ;
23
23
if ( options . plugins && options . plugins . length ) {
@@ -35,7 +35,7 @@ module.exports = function workerLoaderPlugin(config = null) {
35
35
return null ;
36
36
} ,
37
37
38
- resolveId : ( importee , importer ) => {
38
+ resolveId ( importee , importer ) {
39
39
if ( importee === 'rollup-plugin-web-worker-loader-helper' ) {
40
40
return path . resolve ( __dirname , 'createWorkerFactory.js' ) ;
41
41
} else if ( importee . indexOf ( 'web-worker:' ) === 0 ) {
@@ -56,39 +56,44 @@ module.exports = function workerLoaderPlugin(config = null) {
56
56
return null ;
57
57
} ,
58
58
59
- load : id => new Promise ( ( resolve , reject ) => {
60
- if ( idMap . has ( id ) && ! exclude . has ( id ) ) {
61
- const inputOptions = idMap . get ( id ) ;
62
- exclude . set ( id , true ) ;
63
- rollup . rollup ( inputOptions ) . then ( bundle => {
64
- exclude . delete ( id ) ;
65
- bundle . generate ( { format : 'es' , name : id , sourcemap : true } ) . then ( result => {
66
- const output = result . output ;
67
- let chunk = null ;
68
- for ( const ch of output ) {
69
- if ( ! ch . isAsset ) {
70
- chunk = ch ;
71
- break ;
59
+ load ( id ) {
60
+ return new Promise ( ( resolve , reject ) => {
61
+ if ( idMap . has ( id ) && ! exclude . has ( id ) ) {
62
+ const inputOptions = idMap . get ( id ) ;
63
+ exclude . set ( id , true ) ;
64
+ rollup . rollup ( inputOptions ) . then ( bundle => {
65
+ exclude . delete ( id ) ;
66
+ bundle . generate ( { format : 'es' , name : id , sourcemap : true } ) . then ( result => {
67
+ const output = result . output ;
68
+ let chunk = null ;
69
+ for ( const ch of output ) {
70
+ if ( ! ch . isAsset ) {
71
+ chunk = ch ;
72
+ break ;
73
+ }
72
74
}
73
- }
74
- if ( chunk !== null ) {
75
- let source = utils . extractSource ( chunk . code , chunk . exports ) ;
76
- let map = null ;
77
- if ( sourcemap ) {
78
- map = utils . fixMapSources ( chunk , basePath ) ;
75
+ if ( chunk !== null ) {
76
+ let source = utils . extractSource ( chunk . code , chunk . exports ) ;
77
+ let map = null ;
78
+ if ( sourcemap ) {
79
+ map = utils . fixMapSources ( chunk , basePath ) ;
80
+ }
81
+ resolve ( { code : utils . buildWorkerCode ( source , map ) } ) ;
82
+ } else {
83
+ resolve ( null ) ;
79
84
}
80
- resolve ( { code : utils . buildWorkerCode ( source , map ) } ) ;
81
- } else {
82
- resolve ( null ) ;
83
- }
84
- } ) . catch ( reject ) ;
85
- } ) . catch ( reason => { exclude . delete ( id ) ; reject ( reason ) ; } ) ;
86
- } else {
87
- resolve ( null ) ;
88
- }
89
- } ) ,
85
+ } ) . catch ( reject ) ;
86
+ } ) . catch ( reason => {
87
+ exclude . delete ( id ) ;
88
+ reject ( reason ) ;
89
+ } ) ;
90
+ } else {
91
+ resolve ( null ) ;
92
+ }
93
+ } )
94
+ } ,
90
95
91
- transform : ( code , id ) => {
96
+ transform ( code , id ) {
92
97
if ( idMap . has ( id ) && ! exclude . has ( id ) ) {
93
98
const inputOptions = idMap . get ( id ) ;
94
99
return { code, map : `{"version":3,"file":"${ path . basename ( inputOptions . input ) } ","sources":[],"sourcesContent":[],"names":[],"mappings":""}` } ;
0 commit comments