JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q62609F
  • License MIT

Smoother experience for Alterior on Node.js.

Package Exports

  • @alterior/platform-nodejs
  • @alterior/platform-nodejs/dist.esm/index.js
  • @alterior/platform-nodejs/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@alterior/platform-nodejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@alterior/platform-nodejs

Simplifies idiomatic setup of a Node.js environment for running Alterior applications.

Important note

You must still ensure you enable experimentalDecorators and emitDecoratorMetadata in your tsconfig.json to properly run Alterior applications.

Usage

Within your entry point (usually main.ts):

import '@alterior/platform-nodejs'; // must be first!
import { Application } from '@alterior/runtime';

// other imports here...

Application.bootstrap(MyModule);

Important: Make sure import '@alterior/platform-nodejs'; is the first line in your entrypoint (main.ts).

What does it do?

This does a number of things for you:

  • Loads zone.js as early as possible to ensure all code properly runs within the root Zone.
  • Loads reflect-metadata as early as possible to ensure all subsequently loaded code has Typescript reflection metadata emitted
  • Loads source-map-support/register as early as possible to ensure any stack traces are shown using the available source maps (this avoids seeing compiled JS files in stack traces, instead showing the original source file locations).
  • Loads dotenv/config as early as possible to ensure that any dotenv files are properly accounted for within process.env.
  • Makes fetch() available globally (when not already provided). Does this with globalThis.fetch = require('node-fetch')
  • Makes WebSocket available globally (when not already provided)