@meetploy/emulator 1.26.1 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundler/bundler.d.ts +1 -1
- package/dist/bundler/bundler.js +15 -317
- package/dist/bundler/bundler.js.map +1 -1
- package/dist/dashboard-dist/assets/main-Bxo6zxtr.js +364 -0
- package/dist/dashboard-dist/assets/main-BzmV5bYj.css +1 -0
- package/dist/dashboard-dist/index.html +2 -2
- package/dist/dev-dashboard.js +9 -1
- package/dist/dev-dashboard.js.map +1 -1
- package/dist/runtime/ai-runtime.d.ts +1 -1
- package/dist/runtime/ai-runtime.js +1 -157
- package/dist/runtime/ai-runtime.js.map +1 -1
- package/dist/runtime/cache-runtime.d.ts +1 -0
- package/dist/runtime/cache-runtime.js +2 -0
- package/dist/runtime/cache-runtime.js.map +1 -0
- package/dist/runtime/fs-runtime.d.ts +1 -1
- package/dist/runtime/fs-runtime.js +1 -111
- package/dist/runtime/fs-runtime.js.map +1 -1
- package/dist/runtime/queue-runtime.d.ts +1 -1
- package/dist/runtime/queue-runtime.js +1 -59
- package/dist/runtime/queue-runtime.js.map +1 -1
- package/dist/runtime/state-runtime.d.ts +1 -1
- package/dist/runtime/state-runtime.js +1 -283
- package/dist/runtime/state-runtime.js.map +1 -1
- package/dist/runtime/timer-runtime.d.ts +1 -1
- package/dist/runtime/timer-runtime.js +1 -59
- package/dist/runtime/timer-runtime.js.map +1 -1
- package/dist/runtime/workflow-runtime.d.ts +1 -1
- package/dist/runtime/workflow-runtime.js +1 -266
- package/dist/runtime/workflow-runtime.js.map +1 -1
- package/dist/services/cache-service.d.ts +14 -0
- package/dist/services/cache-service.js +39 -0
- package/dist/services/cache-service.js.map +1 -0
- package/dist/services/dashboard-routes.js +48 -0
- package/dist/services/dashboard-routes.js.map +1 -1
- package/dist/services/dashboard-routes.spec.js +69 -0
- package/dist/services/dashboard-routes.spec.js.map +1 -1
- package/dist/services/mock-server.js +8 -0
- package/dist/services/mock-server.js.map +1 -1
- package/dist/utils/sqlite.js +2 -86
- package/dist/utils/sqlite.js.map +1 -1
- package/package.json +1 -1
- package/dist/dashboard-dist/assets/main-C8ubpaTn.css +0 -1
- package/dist/dashboard-dist/assets/main-DZM02c9l.js +0 -359
package/dist/bundler/bundler.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { build } from "esbuild";
|
|
4
|
-
import {
|
|
5
|
-
import { AI_RUNTIME_CODE } from "../runtime/ai-runtime.js";
|
|
6
|
-
import { DB_RUNTIME_CODE } from "../runtime/db-runtime.js";
|
|
7
|
-
import { FS_RUNTIME_CODE } from "../runtime/fs-runtime.js";
|
|
8
|
-
import { QUEUE_RUNTIME_CODE } from "../runtime/queue-runtime.js";
|
|
9
|
-
import { STATE_RUNTIME_CODE } from "../runtime/state-runtime.js";
|
|
10
|
-
import { TIMER_RUNTIME_CODE } from "../runtime/timer-runtime.js";
|
|
11
|
-
import { WORKFLOW_RUNTIME_CODE } from "../runtime/workflow-runtime.js";
|
|
4
|
+
import { generateEnvInjectCode, generateWorkerWrapperCode, PLOY_ENV_INJECT_SPECIFIER, PLOY_RUNTIME_MODULES, PLOY_USER_WORKER_SPECIFIER, } from "@meetploy/tools/cli";
|
|
12
5
|
const NODE_BUILTINS = [
|
|
13
6
|
"assert",
|
|
14
7
|
"async_hooks",
|
|
@@ -52,325 +45,30 @@ const NODE_BUILTINS = [
|
|
|
52
45
|
"worker_threads",
|
|
53
46
|
"zlib",
|
|
54
47
|
];
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
imports.push('import { initializeDB } from "__ploy_db_runtime__";');
|
|
60
|
-
for (const [bindingName, dbName] of Object.entries(config.db)) {
|
|
61
|
-
bindings.push(` ${bindingName}: initializeDB("${dbName}", "${mockServiceUrl}/db"),`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (config.queue) {
|
|
65
|
-
imports.push('import { initializeQueue } from "__ploy_queue_runtime__";');
|
|
66
|
-
for (const [bindingName, queueName] of Object.entries(config.queue)) {
|
|
67
|
-
bindings.push(` ${bindingName}: initializeQueue("${queueName}", "${mockServiceUrl}"),`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (config.state) {
|
|
71
|
-
imports.push('import { initializeState } from "__ploy_state_runtime__";');
|
|
72
|
-
for (const [bindingName, stateName] of Object.entries(config.state)) {
|
|
73
|
-
bindings.push(` ${bindingName}: initializeState("${stateName}", "${mockServiceUrl}"),`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (config.fs) {
|
|
77
|
-
imports.push('import { initializeFileStorage } from "__ploy_fs_runtime__";');
|
|
78
|
-
for (const [bindingName, fsName] of Object.entries(config.fs)) {
|
|
79
|
-
bindings.push(` ${bindingName}: initializeFileStorage("${fsName}", "${mockServiceUrl}"),`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (config.workflow) {
|
|
83
|
-
imports.push('import { initializeWorkflow, createStepContext, executeWorkflow } from "__ploy_workflow_runtime__";');
|
|
84
|
-
for (const [bindingName, value] of Object.entries(config.workflow)) {
|
|
85
|
-
const workflowName = getWorkflowName(value);
|
|
86
|
-
bindings.push(` ${bindingName}: initializeWorkflow("${workflowName}", "${mockServiceUrl}"),`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (config.timer) {
|
|
90
|
-
imports.push('import { initializeTimer } from "__ploy_timer_runtime__";');
|
|
91
|
-
for (const [bindingName, timerName] of Object.entries(config.timer)) {
|
|
92
|
-
bindings.push(` ${bindingName}: initializeTimer("${timerName}", "${mockServiceUrl}"),`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (config.ai && envVars?.PLOY_AI_URL && envVars?.PLOY_AI_TOKEN) {
|
|
96
|
-
imports.push('import { initializeAI } from "__ploy_ai_runtime__";');
|
|
97
|
-
bindings.push(` AI: initializeAI(${JSON.stringify(envVars.PLOY_AI_URL)}, ${JSON.stringify(envVars.PLOY_AI_TOKEN)}),`);
|
|
98
|
-
bindings.push(` PLOY_AI_URL: ${JSON.stringify(envVars.PLOY_AI_URL)},`);
|
|
99
|
-
bindings.push(` PLOY_AI_TOKEN: ${JSON.stringify(envVars.PLOY_AI_TOKEN)},`);
|
|
100
|
-
}
|
|
101
|
-
imports.push('import userWorker from "__ploy_user_worker__";');
|
|
102
|
-
let workflowRetriesMap = "{}";
|
|
103
|
-
if (config.workflow) {
|
|
104
|
-
const retriesEntries = [];
|
|
105
|
-
for (const [, value] of Object.entries(config.workflow)) {
|
|
106
|
-
const workflowName = getWorkflowName(value);
|
|
107
|
-
const retries = getWorkflowRetries(value);
|
|
108
|
-
if (retries !== undefined) {
|
|
109
|
-
retriesEntries.push(`"${workflowName}": ${retries}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
workflowRetriesMap = `{${retriesEntries.join(", ")}}`;
|
|
113
|
-
}
|
|
114
|
-
const workflowHandlerCode = config.workflow
|
|
115
|
-
? `
|
|
116
|
-
// Handle workflow execution requests
|
|
117
|
-
if (request.headers.get("X-Ploy-Workflow-Execution") === "true") {
|
|
118
|
-
const workflowName = request.headers.get("X-Ploy-Workflow-Name");
|
|
119
|
-
const executionId = request.headers.get("X-Ploy-Execution-Id");
|
|
120
|
-
|
|
121
|
-
if (workflowName && executionId && userWorker.workflows && userWorker.workflows[workflowName]) {
|
|
122
|
-
const input = await request.json();
|
|
123
|
-
const __workflowRetries = ${workflowRetriesMap};
|
|
124
|
-
const defaultRetries = __workflowRetries[workflowName] ?? ${DEFAULT_RETRIES};
|
|
125
|
-
const workflowEntry = userWorker.workflows[workflowName];
|
|
126
|
-
const workflowFn = workflowEntry?.handler;
|
|
127
|
-
const onErrorFn = typeof workflowEntry?.onError === "function"
|
|
128
|
-
? workflowEntry.onError
|
|
129
|
-
: undefined;
|
|
130
|
-
if (typeof workflowFn !== "function") {
|
|
131
|
-
return new Response(JSON.stringify({ success: false, error: "Invalid workflow definition for: " + workflowName + ". Expected { handler: Function, onError?: Function }." }), {
|
|
132
|
-
status: 400,
|
|
133
|
-
headers: { "Content-Type": "application/json" }
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
try {
|
|
137
|
-
await executeWorkflow(
|
|
138
|
-
executionId,
|
|
139
|
-
workflowFn,
|
|
140
|
-
input,
|
|
141
|
-
injectedEnv,
|
|
142
|
-
"${mockServiceUrl}",
|
|
143
|
-
defaultRetries,
|
|
144
|
-
onErrorFn
|
|
145
|
-
);
|
|
146
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
147
|
-
headers: { "Content-Type": "application/json" }
|
|
148
|
-
});
|
|
149
|
-
} catch (error) {
|
|
150
|
-
return new Response(JSON.stringify({ success: false, error: String(error) }), {
|
|
151
|
-
status: 500,
|
|
152
|
-
headers: { "Content-Type": "application/json" }
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}`
|
|
157
|
-
: "";
|
|
158
|
-
const cronHandlerCode = config.cron
|
|
159
|
-
? `
|
|
160
|
-
// Handle cron trigger delivery
|
|
161
|
-
if (request.headers.get("X-Ploy-Cron-Trigger") === "true") {
|
|
162
|
-
const cronExpression = request.headers.get("X-Ploy-Cron-Expression");
|
|
163
|
-
const scheduledTime = parseInt(request.headers.get("X-Ploy-Cron-Scheduled-Time") || String(Date.now()), 10);
|
|
164
|
-
|
|
165
|
-
if (cronExpression && userWorker.scheduled) {
|
|
166
|
-
let noRetryFlag = false;
|
|
167
|
-
const event = {
|
|
168
|
-
cron: cronExpression,
|
|
169
|
-
scheduledTime,
|
|
170
|
-
noRetry() { noRetryFlag = true; }
|
|
171
|
-
};
|
|
172
|
-
try {
|
|
173
|
-
await userWorker.scheduled(event, injectedEnv, ctx);
|
|
174
|
-
return new Response(JSON.stringify({ success: true, noRetry: noRetryFlag }), {
|
|
175
|
-
headers: { "Content-Type": "application/json" }
|
|
176
|
-
});
|
|
177
|
-
} catch (error) {
|
|
178
|
-
return new Response(JSON.stringify({ success: false, error: String(error) }), {
|
|
179
|
-
status: 500,
|
|
180
|
-
headers: { "Content-Type": "application/json" }
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return new Response(JSON.stringify({ success: false, error: "No scheduled handler defined" }), {
|
|
186
|
-
status: 404,
|
|
187
|
-
headers: { "Content-Type": "application/json" }
|
|
188
|
-
});
|
|
189
|
-
}`
|
|
190
|
-
: "";
|
|
191
|
-
const timerHandlerCode = config.timer
|
|
192
|
-
? `
|
|
193
|
-
// Handle timer fire delivery
|
|
194
|
-
if (request.headers.get("X-Ploy-Timer-Fire") === "true") {
|
|
195
|
-
const timerId = request.headers.get("X-Ploy-Timer-Id");
|
|
196
|
-
const timerName = request.headers.get("X-Ploy-Timer-Name");
|
|
197
|
-
const timerTime = request.headers.get("X-Ploy-Timer-Time");
|
|
198
|
-
if (timerId && userWorker.timer) {
|
|
199
|
-
const body = await request.json().catch(() => ({}));
|
|
200
|
-
try {
|
|
201
|
-
await userWorker.timer({
|
|
202
|
-
id: timerId,
|
|
203
|
-
scheduledTime: parseInt(timerTime || "0", 10),
|
|
204
|
-
payload: body.payload,
|
|
205
|
-
intervalMs: body.intervalMs
|
|
206
|
-
}, injectedEnv, ctx);
|
|
207
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
208
|
-
headers: { "Content-Type": "application/json" }
|
|
209
|
-
});
|
|
210
|
-
} catch (error) {
|
|
211
|
-
return new Response(JSON.stringify({ success: false, error: String(error) }), {
|
|
212
|
-
status: 500,
|
|
213
|
-
headers: { "Content-Type": "application/json" }
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}`
|
|
218
|
-
: "";
|
|
219
|
-
const queueHandlerCode = config.queue
|
|
220
|
-
? `
|
|
221
|
-
// Handle queue message delivery
|
|
222
|
-
if (request.headers.get("X-Ploy-Queue-Delivery") === "true") {
|
|
223
|
-
const queueName = request.headers.get("X-Ploy-Queue-Name");
|
|
224
|
-
const messageId = request.headers.get("X-Ploy-Message-Id");
|
|
225
|
-
const deliveryId = request.headers.get("X-Ploy-Delivery-Id");
|
|
226
|
-
const attempt = parseInt(request.headers.get("X-Ploy-Message-Attempt") || "1", 10);
|
|
227
|
-
|
|
228
|
-
if (queueName && messageId && userWorker.message) {
|
|
229
|
-
const payload = await request.json();
|
|
230
|
-
try {
|
|
231
|
-
await userWorker.message({
|
|
232
|
-
id: messageId,
|
|
233
|
-
queueName,
|
|
234
|
-
payload,
|
|
235
|
-
attempt,
|
|
236
|
-
timestamp: Date.now()
|
|
237
|
-
}, injectedEnv, ctx);
|
|
238
|
-
return new Response(JSON.stringify({ success: true }), {
|
|
239
|
-
headers: { "Content-Type": "application/json" }
|
|
240
|
-
});
|
|
241
|
-
} catch (error) {
|
|
242
|
-
return new Response(JSON.stringify({ success: false, error: String(error) }), {
|
|
243
|
-
status: 500,
|
|
244
|
-
headers: { "Content-Type": "application/json" }
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}`
|
|
249
|
-
: "";
|
|
250
|
-
const envVarsEntries = envVars && Object.keys(envVars).length > 0
|
|
251
|
-
? Object.entries(envVars)
|
|
252
|
-
.map(([key, value]) => ` ${JSON.stringify(key)}: ${JSON.stringify(value)}`)
|
|
253
|
-
.join(",\n")
|
|
254
|
-
: "";
|
|
255
|
-
const envVarsCode = envVarsEntries
|
|
256
|
-
? `\n injectedEnv.vars = {\n${envVarsEntries}\n };`
|
|
257
|
-
: "";
|
|
258
|
-
const envInjectImport = envVarsEntries ? 'import "__ploy_env_inject__";' : "";
|
|
259
|
-
const runtimeImports = imports.filter((i) => !i.includes("__ploy_user_worker__"));
|
|
260
|
-
const userImport = 'import userWorker from "__ploy_user_worker__";';
|
|
261
|
-
return `${runtimeImports.join("\n")}
|
|
262
|
-
${envInjectImport}
|
|
263
|
-
${userImport}
|
|
264
|
-
|
|
265
|
-
const ployBindings = {
|
|
266
|
-
${bindings.join("\n")}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
export default {
|
|
270
|
-
async fetch(request, env, ctx) {
|
|
271
|
-
const injectedEnv = { ...env, ...ployBindings };${envVarsCode}
|
|
272
|
-
${cronHandlerCode}
|
|
273
|
-
${timerHandlerCode}
|
|
274
|
-
${workflowHandlerCode}
|
|
275
|
-
${queueHandlerCode}
|
|
276
|
-
|
|
277
|
-
if (userWorker.fetch) {
|
|
278
|
-
return userWorker.fetch(request, injectedEnv, ctx);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return new Response("Worker has no fetch handler", { status: 500 });
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
async scheduled(event, env, ctx) {
|
|
285
|
-
if (userWorker.scheduled) {
|
|
286
|
-
const injectedEnv = { ...env, ...ployBindings };${envVarsCode}
|
|
287
|
-
return userWorker.scheduled(event, injectedEnv, ctx);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
`;
|
|
292
|
-
}
|
|
293
|
-
function createRuntimePlugin(_config, envVars) {
|
|
48
|
+
function createRuntimePlugin(envVars) {
|
|
49
|
+
const runtimeSpecifiers = Object.keys(PLOY_RUNTIME_MODULES);
|
|
50
|
+
const allSpecifiers = [...runtimeSpecifiers, PLOY_ENV_INJECT_SPECIFIER];
|
|
51
|
+
const filter = new RegExp(`^(${allSpecifiers.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
294
52
|
return {
|
|
295
53
|
name: "ploy-runtime",
|
|
296
54
|
setup(build) {
|
|
297
|
-
build.onResolve({ filter
|
|
298
|
-
path:
|
|
299
|
-
namespace: "ploy-runtime",
|
|
300
|
-
sideEffects: true,
|
|
301
|
-
}));
|
|
302
|
-
build.onResolve({ filter: /^__ploy_db_runtime__$/ }, () => ({
|
|
303
|
-
path: "__ploy_db_runtime__",
|
|
304
|
-
namespace: "ploy-runtime",
|
|
305
|
-
}));
|
|
306
|
-
build.onResolve({ filter: /^__ploy_queue_runtime__$/ }, () => ({
|
|
307
|
-
path: "__ploy_queue_runtime__",
|
|
308
|
-
namespace: "ploy-runtime",
|
|
309
|
-
}));
|
|
310
|
-
build.onResolve({ filter: /^__ploy_state_runtime__$/ }, () => ({
|
|
311
|
-
path: "__ploy_state_runtime__",
|
|
312
|
-
namespace: "ploy-runtime",
|
|
313
|
-
}));
|
|
314
|
-
build.onResolve({ filter: /^__ploy_fs_runtime__$/ }, () => ({
|
|
315
|
-
path: "__ploy_fs_runtime__",
|
|
316
|
-
namespace: "ploy-runtime",
|
|
317
|
-
}));
|
|
318
|
-
build.onResolve({ filter: /^__ploy_workflow_runtime__$/ }, () => ({
|
|
319
|
-
path: "__ploy_workflow_runtime__",
|
|
55
|
+
build.onResolve({ filter }, (args) => ({
|
|
56
|
+
path: args.path,
|
|
320
57
|
namespace: "ploy-runtime",
|
|
58
|
+
sideEffects: args.path === PLOY_ENV_INJECT_SPECIFIER,
|
|
321
59
|
}));
|
|
322
|
-
build.
|
|
323
|
-
path
|
|
324
|
-
|
|
325
|
-
}));
|
|
326
|
-
build.onResolve({ filter: /^__ploy_ai_runtime__$/ }, () => ({
|
|
327
|
-
path: "__ploy_ai_runtime__",
|
|
328
|
-
namespace: "ploy-runtime",
|
|
329
|
-
}));
|
|
330
|
-
build.onLoad({ filter: /^__ploy_db_runtime__$/, namespace: "ploy-runtime" }, () => ({
|
|
331
|
-
contents: DB_RUNTIME_CODE,
|
|
332
|
-
loader: "ts",
|
|
333
|
-
}));
|
|
334
|
-
build.onLoad({ filter: /^__ploy_queue_runtime__$/, namespace: "ploy-runtime" }, () => ({
|
|
335
|
-
contents: QUEUE_RUNTIME_CODE,
|
|
336
|
-
loader: "ts",
|
|
337
|
-
}));
|
|
338
|
-
build.onLoad({ filter: /^__ploy_state_runtime__$/, namespace: "ploy-runtime" }, () => ({
|
|
339
|
-
contents: STATE_RUNTIME_CODE,
|
|
340
|
-
loader: "ts",
|
|
341
|
-
}));
|
|
342
|
-
build.onLoad({ filter: /^__ploy_fs_runtime__$/, namespace: "ploy-runtime" }, () => ({
|
|
343
|
-
contents: FS_RUNTIME_CODE,
|
|
344
|
-
loader: "ts",
|
|
345
|
-
}));
|
|
346
|
-
build.onLoad({ filter: /^__ploy_workflow_runtime__$/, namespace: "ploy-runtime" }, () => ({
|
|
347
|
-
contents: WORKFLOW_RUNTIME_CODE,
|
|
348
|
-
loader: "ts",
|
|
349
|
-
}));
|
|
350
|
-
build.onLoad({ filter: /^__ploy_timer_runtime__$/, namespace: "ploy-runtime" }, () => ({
|
|
351
|
-
contents: TIMER_RUNTIME_CODE,
|
|
352
|
-
loader: "ts",
|
|
353
|
-
}));
|
|
354
|
-
build.onLoad({ filter: /^__ploy_ai_runtime__$/, namespace: "ploy-runtime" }, () => ({
|
|
355
|
-
contents: AI_RUNTIME_CODE,
|
|
356
|
-
loader: "ts",
|
|
357
|
-
}));
|
|
358
|
-
build.onLoad({ filter: /^__ploy_env_inject__$/, namespace: "ploy-runtime" }, () => {
|
|
359
|
-
const entries = Object.entries(envVars ?? {});
|
|
360
|
-
if (entries.length === 0) {
|
|
361
|
-
return { contents: "", loader: "js" };
|
|
60
|
+
build.onLoad({ filter, namespace: "ploy-runtime" }, (args) => {
|
|
61
|
+
if (args.path === PLOY_ENV_INJECT_SPECIFIER) {
|
|
62
|
+
return { contents: generateEnvInjectCode(envVars), loader: "js" };
|
|
362
63
|
}
|
|
363
|
-
|
|
364
|
-
.map(([key, value]) => ` process.env[${JSON.stringify(key)}] = ${JSON.stringify(value)};`)
|
|
365
|
-
.join("\n")}\n}`;
|
|
366
|
-
return { contents: code, loader: "js" };
|
|
64
|
+
return { contents: PLOY_RUNTIME_MODULES[args.path], loader: "ts" };
|
|
367
65
|
});
|
|
368
66
|
},
|
|
369
67
|
};
|
|
370
68
|
}
|
|
371
69
|
export async function bundleWorker(options) {
|
|
372
70
|
const { projectDir, tempDir, entryPoint, config, mockServiceUrl, envVars } = options;
|
|
373
|
-
const wrapperCode =
|
|
71
|
+
const wrapperCode = generateWorkerWrapperCode(config, mockServiceUrl, envVars);
|
|
374
72
|
const wrapperPath = join(tempDir, "wrapper.ts");
|
|
375
73
|
writeFileSync(wrapperPath, wrapperCode);
|
|
376
74
|
const bundlePath = join(tempDir, "worker.bundle.js");
|
|
@@ -389,9 +87,9 @@ export async function bundleWorker(options) {
|
|
|
389
87
|
...NODE_BUILTINS,
|
|
390
88
|
],
|
|
391
89
|
alias: {
|
|
392
|
-
|
|
90
|
+
[PLOY_USER_WORKER_SPECIFIER]: entryPoint,
|
|
393
91
|
},
|
|
394
|
-
plugins: [createRuntimePlugin(
|
|
92
|
+
plugins: [createRuntimePlugin(envVars)],
|
|
395
93
|
absWorkingDir: projectDir,
|
|
396
94
|
logLevel: "warning",
|
|
397
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../src/bundler/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAkC,MAAM,SAAS,CAAC;AAEhE,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../src/bundler/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAkC,MAAM,SAAS,CAAC;AAEhE,OAAO,EACN,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,GAC1B,MAAM,qBAAqB,CAAC;AAQ7B,MAAM,aAAa,GAAG;IACrB,QAAQ;IACR,aAAa;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