Open
Description
Hi
I would like to strip webpack from my bundle for container efficiency reasons but can't because webpack is loaded eagerly. By lazily loading workflow/bundler
in index and in worker you can get away with deleting webpack and friends from the bundle (in my case the docker container)
I have achieved it by applying this patch (on the build outputs) but I am sure doing a similar thing would be fairly easy on the typescript side. Note I have just removed the default interceptor warning altogether.
diff --git a/lib/index.js b/lib/index.js
index ac5a7f9594321f75f52ac0641621d91c02c9ba8c..3aaa482c51d04627d9d7a2b96755f721ec2b5949 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -52,8 +52,7 @@ Object.defineProperty(exports, "defaultPayloadConverter", { enumerable: true, ge
Object.defineProperty(exports, "Worker", { enumerable: true, get: function () { return worker_1.Worker; } });
var replay_1 = require("./replay");
Object.defineProperty(exports, "ReplayError", { enumerable: true, get: function () { return replay_1.ReplayError; } });
-var bundler_1 = require("./workflow/bundler");
-Object.defineProperty(exports, "bundleWorkflowCode", { enumerable: true, get: function () { return bundler_1.bundleWorkflowCode; } });
+Object.defineProperty(exports, "bundleWorkflowCode", { enumerable: true, get: function () { return require("./workflow/bundler").bundleWorkflowCode; } });
/* eslint-disable deprecation/deprecation */
// Anything below this line is deprecated
var activity_log_interceptor_1 = require("./activity-log-interceptor");
diff --git a/lib/worker.js b/lib/worker.js
index e8cf98a86e9e1045af378319f6242f1ba66a3194..d4fc8999e3ef50d64c3d87338d930f3a0e0c28e8 100644
--- a/lib/worker.js
+++ b/lib/worker.js
@@ -57,7 +57,6 @@ const rxutils_1 = require("./rxutils");
const utils_1 = require("./utils");
const worker_options_1 = require("./worker-options");
const workflow_codec_runner_1 = require("./workflow-codec-runner");
-const bundler_1 = require("./workflow/bundler");
const reusable_vm_1 = require("./workflow/reusable-vm");
const threaded_vm_1 = require("./workflow/threaded-vm");
const vm_1 = require("./workflow/vm");
@@ -317,12 +316,6 @@ class Worker {
logger.warn('Ignoring WorkerOptions.bundlerOptions because WorkerOptions.workflowBundle is set');
}
const modules = new Set(compiledOptions.interceptors.workflowModules);
- // Warn if user tries to customize the default set of workflow interceptor modules
- if (modules &&
- new Set([...modules, ...bundler_1.defaultWorkflowInterceptorModules]).size !== bundler_1.defaultWorkflowInterceptorModules.length) {
- logger.warn('Ignoring WorkerOptions.interceptors.workflowModules because WorkerOptions.workflowBundle is set.\n' +
- 'To use workflow interceptors with a workflowBundle, pass them in the call to bundleWorkflowCode.');
- }
if ((0, worker_options_1.isCodeBundleOption)(compiledOptions.workflowBundle)) {
return parseWorkflowCode(compiledOptions.workflowBundle.code);
}
@@ -335,6 +328,7 @@ class Worker {
}
}
else if (compiledOptions.workflowsPath) {
+ const bundler_1 = require("./workflow/bundler");
const bundler = new bundler_1.WorkflowCodeBundler({
logger,
workflowsPath: compiledOptions.workflowsPath,