Appearance
Module System
DieselEngine scripts are ES modules (ECMAScript 2023+) executed by GraalVM. They support modern JavaScript syntax including import/export, async/await, destructuring, optional chaining, and more.
Imports
Use standard ES module import syntax with relative paths and the .js extension (required):
javascript
// Import a named export
import { UserService } from '../services/UserService.js';
// Import multiple named exports
import { validate, sanitize } from '../classes/Validators.js';
// Namespace import
import * as helpers from './helpers.js';
// Default import
import config from '../config.js';WARNING
The .js extension is required on all import paths. Extensionless imports like '../services/UserService' will fail.
Exports
Use standard export syntax:
javascript
// Named exports
export function handleRequest(context) { /* ... */ }
export class ItemService { /* ... */ }
export const API_VERSION = 2;
// Default export
export default class Config { /* ... */ }Path Resolution
All import paths are resolved relative to the importing script's location in the virtual filesystem. There are no node_modules, no package resolution, and no path aliases.
Given this file tree:
/services/
UserService.js
ItemService.js
/ingresses/api/
get-user.jsFrom /ingresses/api/get-user.js, you would import:
javascript
import { UserService } from '../../services/UserService.js';How It Works Under the Hood
DieselEngine implements a custom FileSystem for GraalVM that resolves module paths against the virtual tree stored in PostgreSQL — not the host filesystem. When you write import { X } from './foo.js', the engine:
- Resolves
./foo.jsrelative to the current script's parent folder - Looks up the resolved path in the virtual filesystem tree
- Loads the file content from PostgreSQL
- Evaluates it as an ES module
Supported JavaScript Features
Since DieselEngine runs on GraalVM's JS engine, you get full ECMAScript 2023+ support:
- Arrow functions, template literals, destructuring
async/awaitand Promisesclasssyntax with static methods- Optional chaining (
?.) and nullish coalescing (??) for...of,for...in, spread/rest operatorsMap,Set,WeakMap,WeakRefArray.prototype.at(),Object.groupBy(), etc.
INFO
There is no require(). Only ES module import/export is supported.
Top-Level Await
Top-level await is supported in scripts that run as top-level modules (on-demand, cron, startup). Ingress handlers export functions that are called synchronously by the engine.