Skip to content
Merged
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/early-pans-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aziontech/builder': patch
---

fix(builder): resolve azion polyfills package specifier to filesystem path in esbuild plugin
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { PluginBuild } from 'esbuild';
import fs from 'fs';
import { createRequire } from 'module';
import path from 'path';
import azionLibs from '../../../../helpers/azion-local-polyfills';

const requireCustom = createRequire(import.meta.url);

/**
* ESBuild Azion Module Plugin for polyfilling node modules.
* @param {boolean} isProduction Parameter to identify whether the build is dev or prod
Expand Down Expand Up @@ -89,8 +92,10 @@ const ESBuildAzionModulePlugin = (isProduction: boolean) => {
throw new Error(`Could not resolve module: ${args.path}`);
}

const contents = await fs.promises.readFile(resolved, 'utf8');
const resolveDir = path.dirname(resolved);
// Resolve package exports (e.g., @aziontech/builder/polyfills/...) to a filesystem path
const resolvedPath = requireCustom.resolve(resolved);
const contents = await fs.promises.readFile(resolvedPath, 'utf8');
const resolveDir = path.dirname(resolvedPath);

return {
loader: 'js',
Expand Down
Loading