Skip to content

Conversation

@davidchase
Copy link
Contributor

@davidchase davidchase commented Aug 1, 2025

Node.js 22 Runtime Environment with ESM Support

Summary

This PR introduces a separate directory for Nodejs 22 runtime env (server.js) with some dependency updates such as Pino logging instead of Morgan.

Resolves #277

New Features

Node.js 22 Environment

  • Dedicated directory: nodejs22/ with complete environment setup
  • Latest Node.js: Version 22.17.1 on Alpine Linux 3.22
  • ESM support: "type": "module" configuration enables native import/export syntax
  • Modern dependencies: Express 5.1.0, Pino logging, WebSocket support

ESM-Ready Examples

All examples use modern ESM syntax and Node.js 22 features:

Example Description Node.js 22 Features
hello.js ESM hello world ESM module with query params
weather.js HTTP requests demo Native fetch API, error handling
multi-entry.js Multiple endpoints Named exports, routing
broadcast.js WebSocket broadcasting Multi-client messaging with ws 8.18
kubeEventsSlack.js Kubernetes integration Event processing, webhooks

Usage

Environment Creation

# Create Node.js 22 environment
fission env create --name node22 --image davidchase03/node-env-22:v2.0.1

# With builder support
fission env create --name node22 --image davidchase03/node-env-22:v2.0.1 --builder node-builder-22

Function Deployment (ESM)

# Deploy ESM function
fission fn create --name hello-esm --env node22 --code hello.js

# Test with query parameters
fission fn test --name hello-esm
curl "$FISSION_ROUTER/hello-esm?name=World"

Modern Function Syntax

// ESM function
export default async function(context) {
    const { query } = context.request;
    return {
        status: 200,
        body: JSON.stringify({
            message: `Hello ${query.name || 'World'} from Node.js 22! 🚀`,
            nodeVersion: process.version
        }),
        headers: { 'Content-Type': 'application/json' }
    }
}

Breaking Changes

None - this is purely additive. Existing nodejs/ environment remains unchanged for backward compatibility.

Testing

  • All existing Node.js tests continue to pass
  • New Node.js 22 specific test cases in nodejs22/test/
  • ESM examples tested with Node.js 22.17.1 runtime

Benefits

  • Modern JavaScript: Native ESM, top-level await, latest syntax
  • Better Performance: Node.js 22 optimizations and faster startup
  • Developer Experience: Modern tooling, better error messages
  • Backward Compatible: Existing Node.js environment unaffected

@cheomfa
Copy link

cheomfa commented Aug 3, 2025

Hi @sanketsudake and @soharab-ic ,
Could you please provide feedback and hopeful merge of this PR ?

@davidchase
Copy link
Contributor Author

Hi @sanketsudake any thoughts on this PR?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a Node.js 22 runtime environment for Fission with full ESM (ES Module) support, expanding the framework's capabilities while maintaining backward compatibility. The addition provides modern JavaScript features, improved performance, and enhanced developer experience.

Key changes:

  • Complete Node.js 22 environment with ESM-first architecture using "type": "module"
  • Updated dependencies including Pino logging (replacing Morgan), Express 5.1.0, and WebSocket 8.18
  • Comprehensive test suite adapted for ESM with modern export default syntax

Reviewed Changes

Copilot reviewed 30 out of 32 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
nodejs22/server.js Core ESM-enabled server with dynamic import loading and Pino logging
nodejs22/package.json Package configuration with "type": "module" and Node.js 22+ dependencies
nodejs22/examples/* ESM function examples showcasing modern JavaScript features
nodejs22/test/* Comprehensive test suite with ESM syntax and specialized test runners
nodejs22/builder/* Build configuration for Node.js 22 Alpine-based containers
Files not reviewed (2)
  • nodejs22/package-lock.json: Language not supported
  • nodejs22/test/test-case-4/package-lock.json: Language not supported

@sanketsudake
Copy link
Member

Please add nodejs22 in
https://github.com/fission/environments/blob/master/.github/workflows/filters/filters.yaml
Also will need copy of this for node22 in workflow

@davidchase
Copy link
Contributor Author

davidchase commented Aug 6, 2025

ok i have resolved the feedback provided

@davidchase
Copy link
Contributor Author

it seems like i needed to address the tests and gh actions but i dont see it running again since yesterday, how can i validate that the actions working properly again?

@davidchase
Copy link
Contributor Author

@sanketsudake can you help me make sense of whats failing? because it seems like nodejs (current runtime and nodejs22 are failing in the actions but i had not made changes to nodejs directory at all

@sanketsudake
Copy link
Member

I went through dump didnt find much as some of tools versions are outdated. Troubleshooting here #423 .
Will fix so that you can rebase.

@sanketsudake
Copy link
Member

sanketsudake commented Aug 8, 2025

Got most of things updated and also switched default version to nodejs 22 via PR #423

I am seeing if we can have multiple versions under same env.
Eg. There ESM version and we also got request for bun #418

We can have nodejs image name and different tags.

@davidchase
Copy link
Contributor Author

Got most of things updated and also switched default version to nodejs 22 via PR #423

ok i will wait for you to merge the PR so i can use those new actions

I am seeing if we can have multiple versions under same env.
Eg. There ESM version and we also got request for bun #418

It would be awesome to have support for Bun and Deno given there is some interest in both of those runtimes and with Bun/Deno we could utilize their native APIs for the server part to max out potential performance of the function handlers.

@davidchase davidchase closed this Aug 8, 2025
@davidchase
Copy link
Contributor Author

@sanketsudake something got messed up in my rebasing 😅 so i closed the PR here and re-opened it again #424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES module support for Node JS

3 participants