Skip to content

Commit cd8bf60

Browse files
committed
[HOOKS] Uses functions rather than aero functions for the hooks
1 parent 4152c92 commit cd8bf60

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

src/index.js

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function workerLoaderPlugin(config = null) {
1717
return {
1818
name: 'worker-loader',
1919

20-
options: options => {
20+
options(options ) {
2121
if (!projectOptions) {
2222
projectOptions = Object.assign({}, options);
2323
if (options.plugins && options.plugins.length) {
@@ -35,7 +35,7 @@ module.exports = function workerLoaderPlugin(config = null) {
3535
return null;
3636
},
3737

38-
resolveId: (importee, importer) => {
38+
resolveId(importee, importer) {
3939
if (importee === 'rollup-plugin-web-worker-loader-helper') {
4040
return path.resolve(__dirname, 'createWorkerFactory.js');
4141
} else if (importee.indexOf('web-worker:') === 0) {
@@ -56,39 +56,44 @@ module.exports = function workerLoaderPlugin(config = null) {
5656
return null;
5757
},
5858

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+
}
7274
}
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);
7984
}
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+
},
9095

91-
transform: (code, id) => {
96+
transform(code, id) {
9297
if (idMap.has(id) && !exclude.has(id)) {
9398
const inputOptions = idMap.get(id);
9499
return { code, map: `{"version":3,"file":"${path.basename(inputOptions.input)}","sources":[],"sourcesContent":[],"names":[],"mappings":""}` };

0 commit comments

Comments
 (0)