Skip to content

odoe/jsapi-node-ts

Repository files navigation

ArcGIS API for JavaScript in Node with TypeScript

Integrating Node with @arcgis/core can be done by building the app with native ESM in a supported Node version or by transpiling to CommonJS.

// rollup.config.js
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";

export default {
  input: ["src/request.ts", "src/projection.ts", "src/webmap.ts"],
  output: {
    chunkFileNames: "chunks/[name].js",
    dir: "dist",
    format: "cjs"
  },
  external: ["whatwg-fetch"],
  plugins: [typescript(), resolve(), commonjs()],
  preserveEntrySignatures: false
};

Because Node does not have a native fetch, you will need to load a polyfill.

require("cross-fetch/polyfill");

IdentityManager

You will also want to disable the IdentityManager so it doesn't attempt to load DOM related JavaScript.

import esriConfig from "@arcgis/core/config";

esriConfig.request.useIdentity = false;

About

Using TypeScript to write JSAPI apps in node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published