Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/four-numbers-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/builders": patch
---

esbuild markdown loader
40 changes: 39 additions & 1 deletion packages/builders/src/base-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,21 @@ export abstract class BaseBuilder {
await esbuild.build({
treeShaking: true,
entryPoints: inputs,
plugins: [createDiscoverEntriesPlugin(state)],
plugins: [
{
name: 'markdown-loader',
setup(build) {
build.onLoad({ filter: /\.md$/ }, async (args) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markdown loader plugin in esbuild configurations lacks error handling, causing unhandled exceptions if readFile fails on markdown files with permission issues or inaccessibility

Fix on Vercel

const contents = await readFile(args.path, 'utf8');
return {
contents: `export default ${JSON.stringify(contents)}`,
loader: 'js',
};
});
},
},
createDiscoverEntriesPlugin(state),
],
platform: 'node',
write: false,
outdir,
Expand Down Expand Up @@ -345,6 +359,18 @@ export abstract class BaseBuilder {
// occur in deeply nested function calls across multiple files.
sourcemap: 'inline',
plugins: [
{
name: 'markdown-loader',
setup(build) {
build.onLoad({ filter: /\.md$/ }, async (args) => {
const contents = await readFile(args.path, 'utf8');
return {
contents: `export default ${JSON.stringify(contents)}`,
loader: 'js',
};
});
},
},
createSwcPlugin({
mode: 'step',
entriesToBundle: externalizeNonSteps
Expand Down Expand Up @@ -475,6 +501,18 @@ export abstract class BaseBuilder {
'.cjs',
],
plugins: [
{
name: 'markdown-loader',
setup(build) {
build.onLoad({ filter: /\.md$/ }, async (args) => {
const contents = await readFile(args.path, 'utf8');
return {
contents: `export default ${JSON.stringify(contents)}`,
loader: 'js',
};
});
},
},
createSwcPlugin({
mode: 'workflow',
workflowManifest,
Expand Down