mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 19:04:23 +00:00
feat(publish): compile and package workers for npm and isolate workflow imports
This commit is contained in:
@@ -33,9 +33,32 @@ export function temporalWorkflow(options: TemporalWorkflowPluginOptions = {}): B
|
||||
build.onLoad({ filter: /.*/, namespace: 'temporal-workflow' }, async (args) => {
|
||||
const workflowsPath = args.path
|
||||
|
||||
// The bundleOptions contains raw parameters for Temporal bundleWorkflowCode which uses Webpack.
|
||||
// We cast options.bundleOptions to any to check for webpackConfigHook.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const originalHook = (options.bundleOptions as any)?.webpackConfigHook
|
||||
const bundleOptions = {
|
||||
...options.bundleOptions,
|
||||
// Webpack config is untyped inside Temporal's webpackConfigHook callback.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
webpackConfigHook: (config: any) => {
|
||||
config.resolve = config.resolve || {}
|
||||
config.resolve.alias = {
|
||||
...config.resolve.alias,
|
||||
'@shumai/workflow-core':
|
||||
require.resolve('@shumai/workflow-core/src/workflow-utils.ts'),
|
||||
}
|
||||
console.log('Webpack config aliases:', config.resolve.alias)
|
||||
if (originalHook) {
|
||||
return originalHook(config)
|
||||
}
|
||||
return config
|
||||
},
|
||||
}
|
||||
|
||||
const bundle = await bundleWorkflowCode({
|
||||
workflowsPath,
|
||||
...options.bundleOptions,
|
||||
...bundleOptions,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
@@ -110,6 +110,7 @@ export class WorkflowService {
|
||||
'@temporalio/workflow': path.dirname(
|
||||
require.resolve('@temporalio/workflow/package.json'),
|
||||
),
|
||||
'@shumai/workflow-core': require.resolve('./workflow-utils'),
|
||||
}
|
||||
return config
|
||||
},
|
||||
@@ -130,6 +131,7 @@ export class WorkflowService {
|
||||
'@temporalio/workflow': path.dirname(
|
||||
require.resolve('@temporalio/workflow/package.json'),
|
||||
),
|
||||
'@shumai/workflow-core': require.resolve('./workflow-utils'),
|
||||
}
|
||||
return config
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user