Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 4.6.0 #429

Merged
merged 5 commits into from
Feb 6, 2025
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [4.6.0-stage.1](https://github.com/aziontech/bundler/compare/v4.5.0...v4.6.0-stage.1) (2025-02-04)


### Features

* adding the unenv package and removing the polyfill manager ([#425](https://github.com/aziontech/bundler/issues/425)) ([529c267](https://github.com/aziontech/bundler/commit/529c267affba776467dd5127980078e8d98dbde6))

## [4.5.0](https://github.com/aziontech/bundler/compare/v4.4.2...v4.5.0) (2025-01-30)


Expand Down
4 changes: 3 additions & 1 deletion lib/build/bundlers/esbuild/esbuild.bundlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ describe('Esbuild Bundler', () => {

const result = fs.readFileSync(tmpOutput.name, 'utf-8');

expect(result).toContain('vulcan-node-modules-polyfills:crypto');
expect(result).toContain(
'node-built-in-modules:unenv/runtime/node/crypto/index',
);
},
TIMEOUT,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/build/bundlers/esbuild/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default {
target: 'es2022',
format: 'esm',
platform: 'browser',
mainFields: ['browser', 'main', 'module'],
mainFields: ['browser', 'module', 'main'],
loader: {
'.js': 'jsx',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable consistent-return */
import fs from 'fs';
import path from 'path';
import PolyfillsManager from '../../../polyfills/index.js';
import azionLibs from '../../../helpers/azion-libs.js';

/**
* ESBuild Azion Module Plugin for polyfilling node modules.
* @param {boolean} buildProd Parameter to identify whether the build is dev or prod
* @returns {object} - ESBuild plugin object.
*/
const ESBuildAzionModulePlugin = (buildProd) => {
const NAME = 'vulcan-azion-modules-polyfills';
const NAME = 'bundler-azion-modules-polyfills';
const NAMESPACE = NAME;
const filter = /^azion:/;
const prefix = 'azion:';
Expand All @@ -21,14 +21,12 @@ const ESBuildAzionModulePlugin = (buildProd) => {
*/
name: NAME,
setup: (build) => {
const polyfillManager = PolyfillsManager.buildPolyfills();

const options = build.initialOptions;

// external
if (buildProd) {
options.external = options.external || [];
[...polyfillManager.external].forEach(([key]) => {
[...azionLibs.external].forEach(([key]) => {
if (/^[^:]+:/.test(key) && !options.external.includes(key)) {
options.external.push(key);
}
Expand All @@ -38,8 +36,8 @@ const ESBuildAzionModulePlugin = (buildProd) => {
if (!buildProd) {
// build inject prefix (azion:) is not present and the polyfill is Azion
options.inject = options.inject || [];
if (polyfillManager.external) {
[...polyfillManager.external].forEach(([key, value]) => {
if (azionLibs.external) {
[...azionLibs.external].forEach(([key, value]) => {
const hasPrefix = /^[^:]+:/.test(key);
if (
!hasPrefix &&
Expand All @@ -57,13 +55,13 @@ const ESBuildAzionModulePlugin = (buildProd) => {
* @returns {object|undefined} - Object with path and namespace or undefined.
*/
build.onResolve({ filter }, async (args) => {
if (!buildProd && polyfillManager.external.has(args.path)) {
if (!buildProd && azionLibs.external.has(args.path)) {
return {
path: args.path,
namespace: NAMESPACE,
};
}
if (!polyfillManager.external.has(args.path)) {
if (!azionLibs.external.has(args.path)) {
return;
}

Expand All @@ -87,10 +85,10 @@ const ESBuildAzionModulePlugin = (buildProd) => {
* @returns {object} - Object with loader, contents, and resolve directory.
*/
build.onLoad({ filter, namespace: NAMESPACE }, async (args) => {
if (!polyfillManager.external.has(args.path)) {
if (!azionLibs.external.has(args.path)) {
return;
}
const resolved = polyfillManager.external.get(args.path);
const resolved = azionLibs.external.get(args.path);
const contents = await fs.promises.readFile(resolved, 'utf8');
const resolveDir = path.dirname(resolved);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Esbuild Azion Plugin', () => {
});

expect(results.outputFiles.at(0)?.text.trim()).toContain(
'vulcan-azion-modules-polyfills',
'bundler-azion-modules-polyfills',
);
});
});
Loading