From b2d09daf18406b3b35689a3e39732e666c26528f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 3 Nov 2021 15:10:30 +0100 Subject: [PATCH 1/2] New api build for web workers --- javascript/gruntfile.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/javascript/gruntfile.js b/javascript/gruntfile.js index 36e833802..8486dba07 100644 --- a/javascript/gruntfile.js +++ b/javascript/gruntfile.js @@ -22,6 +22,16 @@ const BROWSER_FOOTER = [ 'module.exports = ee;' ].join('\n') + '\n'; +/** + * Web Worker build. + * - CommonJS exports. + */ +const WORKER_BANNER = ""; +const WORKER_FOOTER = [ + 'goog.Timer.defaultTimerObject = self;', + 'module.exports = ee;' +].join('\n') + '\n'; + /** * Node.js build. * - CommonJS exports. See b/77731705. @@ -59,6 +69,11 @@ grunt.initConfig({ dest: `${BUILD_DIR}/browser.js`, options: {banner: BROWSER_BANNER, footer: BROWSER_FOOTER} }, + worker: { + src: [`${BUILD_DIR}/ee_api_js_npm.js`], + dest: `${BUILD_DIR}/worker.js`, + options: { banner: WORKER_BANNER, footer: WORKER_FOOTER }, + }, nodejs: { src: [`${BUILD_DIR}/ee_api_js_npm.js`], dest: `${BUILD_DIR}/main.js`, @@ -70,4 +85,4 @@ grunt.initConfig({ /** * Default tasks, executed consecutively with `grunt` command. */ -grunt.registerTask('default', ['concat:nodejs', 'concat:browser']); +grunt.registerTask('default', ['concat:nodejs', 'concat:browser', 'concat:worker']); From 7b3db6450671294d125b129d3180ba7bd0a25017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Sandvik?= Date: Wed, 24 Nov 2021 12:22:29 +0100 Subject: [PATCH 2/2] fix: set goog.global.ee for web worker --- javascript/gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/gruntfile.js b/javascript/gruntfile.js index 8486dba07..190cbd34a 100644 --- a/javascript/gruntfile.js +++ b/javascript/gruntfile.js @@ -29,7 +29,7 @@ const BROWSER_FOOTER = [ const WORKER_BANNER = ""; const WORKER_FOOTER = [ 'goog.Timer.defaultTimerObject = self;', - 'module.exports = ee;' + 'module.exports = goog.global.ee = ee;' ].join('\n') + '\n'; /**