screeps-typescript-starter
screeps-typescript-starter copied to clipboard
CJS modules with default exports do not work
I've tried a few of them, and so far, this class of modules seems to fail when it should be able to run in Screeps.
Consider this code added to main.ts
in starter:
// already in es6, of course
import { ErrorMapper } from "utils/ErrorMapper";
// this one works -- it's in es6 format
import * as _ from 'lodash-es';
// uploads, but exports empty object
import * as _ from 'lodash';
// no error and these will upload, but code will fail on server without executing
import * as Chance from 'chance';
import * as faker from 'faker';
Please note that I have also taken the step of installing @types
modules for these as well.
Using CommonJS modules w/ Rollup will have to require some workarounds.
See: https://screepers.gitbook.io/screeps-typescript-starter/in-depth/module-bundling#note-rollup-and-named-exports