@@ -16,6 +16,10 @@ function getFactoryFuncName(options) {
1616}
1717
1818function getArgsString ( source , sourcemap , options ) {
19+ if ( options . targetPlatform === 'base64' ) {
20+ return Buffer . from ( source , options . enableUnicode ? 'utf16le' : 'utf8' ) . toString ( 'base64' ) ;
21+ }
22+
1923 if ( options . inline ) {
2024 const sourcemapArg = sourcemap ? `'${ sourcemap . toUrl ( ) } '` : 'null' ;
2125 if ( options . preserveSource ) {
@@ -27,10 +31,15 @@ function getArgsString(source, sourcemap, options) {
2731 return `'${ source } '` ;
2832}
2933
30- function buildWorkerCode ( source , sourcemap = null , optionsArg = kDefaultsOptions ) {
31- const options = Object . assign ( { } , kDefaultsOptions , optionsArg ) ;
32- const factoryFuncName = getFactoryFuncName ( options ) ;
33- const argsString = getArgsString ( source , sourcemap , options ) ;
34+ function buildWorkerSource ( options , factoryFuncName , argsString ) {
35+ if ( options . targetPlatform === 'base64' ) {
36+ return `
37+ /* eslint-disable */
38+ var base64 = '${ argsString } ';
39+ export default base64;
40+ /* eslint-enable */\n` ;
41+ }
42+
3443 return `
3544/* eslint-disable */
3645import {${ factoryFuncName } } from '\0rollup-plugin-web-worker-loader::helper::${ options . targetPlatform } ::${ factoryFuncName } ';
@@ -39,4 +48,11 @@ export default WorkerFactory;
3948/* eslint-enable */\n` ;
4049}
4150
51+ function buildWorkerCode ( source , sourcemap = null , optionsArg = kDefaultsOptions ) {
52+ const options = Object . assign ( { } , kDefaultsOptions , optionsArg ) ;
53+ const factoryFuncName = getFactoryFuncName ( options ) ;
54+ const argsString = getArgsString ( source , sourcemap , options ) ;
55+ return buildWorkerSource ( options , factoryFuncName , argsString ) ;
56+ }
57+
4258module . exports = buildWorkerCode ;
0 commit comments