screepers / screeps-typescript-starter Goto Github PK
View Code? Open in Web Editor NEWStarter kit for TypeScript-based Screeps AI codes.
Home Page: https://screepers.gitbook.io/screeps-typescript-starter/
License: The Unlicense
Starter kit for TypeScript-based Screeps AI codes.
Home Page: https://screepers.gitbook.io/screeps-typescript-starter/
License: The Unlicense
I'm running this on Ubuntu WSL but I'm having trouble building it. I guess my package.lock got generated differently perhaps.
When I run build I get the following error
> [email protected] build /mnt/w/Projects/Games/Screeps
> rollup -c
No destination specified - code will be compiled but not uploaded
src/main.ts → dist/main.js...
[!] (rpt2 plugin) Error: /mnt/w/Projects/Games/Screeps/src/utils/ErrorMapper.ts(10,7): semantic error TS2322 Type 'Promise<BasicSourceMapConsumer>' is not assignable to type 'SourceMapConsumer'.
Property 'computeColumnSpans' is missing in type 'Promise<BasicSourceMapConsumer>'.
src/utils/ErrorMapper.ts
Error: /mnt/w/Projects/Games/Screeps/src/utils/ErrorMapper.ts(10,7): semantic error TS2322 Type 'Promise<BasicSourceMapConsumer>' is not assignable to type 'SourceMapConsumer'.
Property 'computeColumnSpans' is missing in type 'Promise<BasicSourceMapConsumer>'.
at error (/mnt/w/Projects/Games/Screeps/node_modules/rollup/dist/rollup.js:3438:30)
at Object.error (/mnt/w/Projects/Games/Screeps/node_modules/rollup/dist/rollup.js:21120:17)
at RollupContext.error (/mnt/w/Projects/Games/Screeps/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:17167:30)
at lodash_2 (/mnt/w/Projects/Games/Screeps/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:19879:23)
at arrayEach (/mnt/w/Projects/Games/Screeps/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:516:11)
at forEach (/mnt/w/Projects/Games/Screeps/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:9341:14)
at printDiagnostics (/mnt/w/Projects/Games/Screeps/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:19852:5)
at Object.transform (/mnt/w/Projects/Games/Screeps/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20125:17)
at /mnt/w/Projects/Games/Screeps/node_modules/rollup/dist/rollup.js:20831:25
at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `rollup -c`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2018-08-25T16_06_48_017Z-debug.log
Any idea how to fix this at all? I've yet to make any changes to this at all.
If the code had an error, it will still complete the build and try to upload
README says that noImplicitAny flag is false by default, but it's actually true.
See #44
Steps to reproduce:
npm install
rollup -c
Result:
src/main.ts → dist/main.js...
[!] (commonjs plugin) TypeError: parse is not a function in /Users/ben/Downloads/screeps-typescript-starter-master 2/node_modules/source-map/source-map.js
node_modules/source-map/source-map.js
TypeError: parse is not a function in /Users/ben/Downloads/screeps-typescript-starter-master 2/node_modules/source-map/source-map.js
at error (/usr/local/lib/node_modules/rollup/dist/rollup.js:169:15)
at /usr/local/lib/node_modules/rollup/dist/rollup.js:17413:17
at <anonymous>
TypeScript version: 2.8.3
Node version: 8.10.0
Remove all "this." from components
Hi,
Something is strange with the way screeps server run the first function in the main exported by webpack
Seems like several loop instances is alternating the run ,each one with its own globals
Example:
REPLACE THE FIRST FUNCTION IN THE MAIN FOR THIS MODIFIED ONE AND YOU WILL SEE WHAT I M TALKING ABOUT ...
// (function(modules) { // webpackBootstrap
// // The module cache
// var installedModules = {};
//
// // The require function
// function webpack_require(moduleId) {
//
// // Check if module is in cache
// if(installedModules[moduleId]) {
// return installedModules[moduleId].exports;
// }
// // Create a new module (and put it into the cache)
// var module = installedModules[moduleId] = {
// i: moduleId,
// l: false,
// exports: {}
// };
//
// // Execute the module function
// modules[moduleId].call(module.exports, module, module.exports, webpack_require);
//
// // Flag the module as loaded
// module.l = true;
//
// // Return the exports of the module
// return module.exports;
// }
//
//
// // expose the modules object (webpack_modules)
// webpack_require.m = modules;
//
// // expose the module cache
// webpack_require.c = installedModules;
//
// // identity function for calling harmony imports with the correct context
// webpack_require.i = function(value) { return value; };
//
// // define getter function for harmony exports
// webpack_require.d = function(exports, name, getter) {
// if(!webpack_require.o(exports, name)) {
// Object.defineProperty(exports, name, {
// configurable: false,
// enumerable: true,
// get: getter
// });
// }
// };
//
// // getDefaultExport function for compatibility with non-harmony modules
// webpack_require.n = function(module) {
// var getter = module && module.__esModule ?
// function getDefault() { return module['default']; } :
// function getModuleExports() { return module; };
// webpack_require.d(getter, 'a', getter);
// return getter;
// };
//
// // Object.prototype.hasOwnProperty.call
// webpack_require.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
//
// // webpack_public_path
// webpack_require.p = "";
//
// // Load entry module and return exports
// //return webpack_require(webpack_require.s = 21);
// CHANGE THE ENTRY POINT FOR THIS LOOP
global.var1=0;
modules.loop = function(){
global.var1++;
console.log("Global Var ->"+global.var1);
};
return modules;
/******/ })
Look at Console messages ..
seems like different loop functions alternating ...
Currently, npm run deploy errors out if you simply download the files, and run yarn, configure and attempt to upload to test. Nowhere is it indicated that you need to run git init, and commit files before npm run deploy will work.
Also, a command to run TSC without uploading (dry run) would be nice.
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.
Currently experimenting with the typescript starter (v3.0) and tried to push to the local server on my Mac. However, I am getting the following error:
(node:80116) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Cannot POST /api/auth/signin
I have been experimenting with the config file screeps.json
and I am using the username as I entered on the server and no password. Tried the IP adress, changed it to localhost etc etc:
"pserver": { "email": "username", "password": "", "protocol": "http", "hostname": "localhost", "port": 21025, "path": "/", "branch": "default" }
Any idea? What am I missing?
Prettier is an awesome tool which help you automatically format your code. It supports integration with popular linting tools like ESLint and TSLint, as well as really good integration with editors (like VS Code), with support for formatting after save.
Right now I could include it by either:
I'm more gravitated towards doing the latter, so to not complicate the default setup even further. I'll write down a quick guide on including Prettier which should be finished by the end of next week.
See #44.
Since the Webpack update broke the testing functionality on the starter pack, we might have to rewrite the entire testing framework. I'm looking into using magical-mock
. If it works well, we could use it.
Thanks a lot for this project. It's a been great time saver
Can you explain what you mean by this line:
https://github.com/screepers/screeps-typescript-starter/blob/master/config/config.local.ts#L11
I understand how to symlink and what that does, but which folders should I symlink?
And then what benefit does this get me? I thought with Screeps debugging all you get is logging anyway.
Thanks
Also tsc
reported the same error and failed. But rollup
succeeded.
Our current gulpfile/tasks pipeline has grown too much it might be overwhelming for new users to get started with the starter kit. Rewriting the entire tasks system should be our main priority before upgrading to TS 2.3.
yo
generator perhaps?)gulp
for other better alternatives (pure npm
tasks/brunch
) (might have to ditch the flattened directory option)brunch
(idea: @bryanbecker)npm
tasks + Webpack after all.Some people in the #typescript channel thought that the starter kit would be better without the existing bit inside. We should remove most of the pre-built codes to make sure that we have the most minimal skeleton possible.
So technically I have no idea what I'm doing here, this works in-game but rollup gives an error:
[!] (rpt2 plugin) Error: S:/Source/screeps-typescript-starter-master/src/main.ts(8,10): semantic error TS2339 Property 'sayHello' does not exist on type 'Creep'.
src\main.ts
Error: S:/Source/screeps-typescript-starter-master/src/main.ts(8,10): semantic error TS2339 Property 'sayHello' does not exist on type 'Creep'.
All I did was take the tutorial #1 code : https://github.com/screeps/tutorial-scripts/tree/8327df748685fe09354961e7f773b3d41a867d08/section1
Added a simple prototype: https://docs.screeps.com/contributed/modifying-prototypes.html
It works in-game (https://i.imgur.com/EQVjgAD.png) but rollup gives the above error.
In total:
role.harvester.ts
Creep.prototype.sayHello = function() {
// In prototype functions, 'this' usually has the value of the object calling
// the function. In this case that is whatever creep you are
// calling '.sayHello()' on.
this.say("Hello!");
};
var roleHarvester = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.carry.energy < creep.carryCapacity) {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}
else {
if(creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(Game.spawns['Spawn1']);
}
}
}
};
module.exports = roleHarvester;
main.ts
var roleHarvester = require('role.harvester');
module.exports.loop = function () {
for(var name in Game.creeps) {
var creep = Game.creeps[name];
roleHarvester.run(creep);
creep.sayHello();
}
}```
Link for doc contribution on gitbook just links back to this repo.
Screeps has recently introduced a token-based auth system, and the old authentication system will be deprecated by 01 February 2018. We should start look into implementing the new auth system and deprecate the old one.
This task will be on hold until Arcath/rollup-plugin-screeps#2 is resolved and the new auth system is implemented in rollup-plugin-screeps
.
@screepers/typescript
Since we're already well into TypeScript 2.0 and @types/
has already matured, so I think we could start to slowly deprecate typings
in favour of installing the typings directly out of npm
.
I have a proof-of-concept ready on my personal codebase, and are willing to move things over to the starter kit if most of the team agree.
Some caveats that are worth mentioning:
any
), since Webpack's typings are kinda broken.typings
.What do you guys think?
Hi, my gulpfile.js keeps getting deleted when I do the npm run deploy
(or gulp build
):
Console log of a full wipe and reclone:
https://files.slack.com/files-pri/T0HJCPP9T-F1W1334CR/full_wipe_and_reclone.txt
I would like to use a library from NPM in my code base. In my case I want to use ramda.js http://ramdajs.com/
I installed it with the usual npm install --save
, and its working fine locally in WebStorm. But the library isn't being bundled up and uploaded to screeps.
I realize I could manually place the library in the src/lib/
folder, but I'd prefer to use the normal npm workflow if possible.
edit: So adding the ramda.js
lib to src/lib/
didn't work either because the gulp file only builds the typescript files in src/
When I do this, nothing comes out, is this normal? I haven't change any configuration.
Game.profiler.profile(5)
I can probably figure this out myself, however I could not see any answers to this on the supplied wiki and guides.
(It's pretty late at night, so I'm not in the mood to fully debug)
I believe that tslint, webpack, etc are not command that the command line can run:
'tslint' is not recognised as an internal or external command, operable program or batch file.
Here is my npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'D:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'local' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prelocal', 'local', 'postlocal' ]
5 info lifecycle [email protected]~prelocal: [email protected]
6 silly lifecycle [email protected]~prelocal: no script for prelocal, continuing
7 info lifecycle [email protected]~local: [email protected]
8 verbose lifecycle [email protected]~local: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~local: PATH: D:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\GitHub\screeps-typescript-starter\node_modules\.bin;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\ProgramData\Razer\SwitchBlade\SDK;C:\Users\user\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Program Files\nodejs\;C:\Prog;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Git\cmd;D:\Program Files\PuTTY\;C:\Users\user\AppData\Roaming\npm;C:\Users\user\AppData\Local\Microsoft\WindowsApps;D:\Program Files\php;D:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\user\AppData\Local\GitHubDesktop\bin;D:\Users\user\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin
10 verbose lifecycle [email protected]~local: CWD: D:\GitHub\screeps-typescript-starter
11 silly lifecycle [email protected]~local: Args: [ '/d /s /c', 'webpack --colors --env.ENV=local' ]
12 silly lifecycle [email protected]~local: Returned: code: 1 signal: null
13 info lifecycle [email protected]~local: Failed to exec local script
14 verbose stack Error: [email protected] local: `webpack --colors --env.ENV=local`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (D:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:232:16)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at EventEmitter.emit (events.js:172:7)
14 verbose stack at ChildProcess.<anonymous> (D:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at ChildProcess.emit (events.js:172:7)
14 verbose stack at maybeClose (internal/child_process.js:821:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid [email protected]
16 verbose cwd D:\GitHub\screeps-typescript-starter
17 error Windows_NT 10.0.14393
18 error argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "local"
19 error node v5.4.0
20 error npm v3.3.12
21 error code ELIFECYCLE
22 error [email protected] local: `webpack --colors --env.ENV=local`
22 error Exit status 1
23 error Failed at the [email protected] local script 'webpack --colors --env.ENV=local'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the screeps-typescript-starter package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error webpack --colors --env.ENV=local
23 error You can get their info via:
23 error npm owner ls screeps-typescript-starter
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
When I try to push I get this error:
node:744) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): FetchError: request to https://screeps.com:443/api/user/branches? failed, reason: read ECONNRESET
I can only assume this is because I am behind a proxy, is there any way of adding proxy info to the config file to allow this to work?
When I try to build a project I get several of the following errors:
Build: Type 'T' cannot be used to index type 'FindTypes'.
from
type FilterFunction<T extends FindConstant> = (object: FindTypes[T]) => boolean;
It looks like it's trying to use the constant associated with the Type... but I'm not really sure. Any ideas?
I use stow for my dotfiles and it may be a good fit for this project.
I'll update this issue after I've played with it.
Hypothetically, this would allow to install the starter as a submodule thus being able to track it's code, and your own code simultaneously.
git init
git submodule add https://github.com/screepers/screeps-typescript-starter starter
cd starter
stow
the stow config inside the project will configure which files should be symlinked.
Benefits:
Potential issues:
some users may not want symlinks
counter: they don't have to use it
it may not make sense that src/
and test/
are symlinks
possible solution: 2 step stow
inovocation... one for symlinks, and one for not.
The lodash
version specified in package.json
is the newest version, it should be the one used by screeps.
https://github.com/screepers/screeps-typescript-starter/blob/master/package.json#L39
Do we want to stick with the old ones, or migrate to https://github.com/screepers/typed-screeps ?
Now that Webpack 2 has reached stable, we'll have to eventually convert the code over to Webpack 2. I'm putting this issue up here as a reminder to start working on it by the end of this week.
Since GitBook has made a lot of updates and severely limiting our free plan, we should consider moving to another documentation provider.
Docz seems like a good thing to migrate to, we can import our existing Markdown docs quite easily, and we can easily host it on Github Pages!
Are there any plans to update this package properly to the newest versions of the various dependencies? By doing so manually I noticed the following issues:
source-map
MUST stay at 0.6.1 for the ErrorMapper
to work since SourceMapConsumer
has been slightly reworked.rollup
to 1.0.0 will yield some deprecation warnings:(!) rpt2 plugin: The ongenerate hook used by plugin rpt2 is deprecated. The generateBundle hook should be used instead.
(!) rpt2 plugin: The onwrite hook used by plugin rpt2 is deprecated. The generateBundle hook should be used instead.
(!) screeps plugin: The ongenerate hook used by plugin screeps is deprecated. The generateBundle hook should be used instead.
(!) screeps plugin: The onwrite hook used by plugin screeps is deprecated. The generateBundle hook should be used instead.
It would be nice to be able to conditionally set variables based on build environment.
I can think of a couple hypothetical ways to accomplish this:
Config
not be typescript, but instead POJS (this may get around above)The entry script uploaded is main.js but screeps runs the main file. So nothing happens once uploaded since main is empty.
How can we upload the correct filenames and that will work with the sourcemap too?
The filenames uploaded would be main and main.map
I'm not sure if I'm the problem or if something is missing here. I'm a typescript noob.
I try to use classes... with inheritance and it's working fine if the base class is in the same file.. but when they are in seperate files it breakes with following error:
File A.ts:
abstract class Role {
...
}
export default Role;
File B.ts:
import Role from "./A"
export class Harvester extends Role {
...
}
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (main:3443:29)
at __webpack_require__ (main:21:30)
at Object.<anonymous> (main:3426:18)
at __webpack_require__ (main:21:30)
at Object.<anonymous> (main:3369:19)
at __webpack_require__ (main:21:30)
at Object.<anonymous> (main:3336:18)
at __webpack_require__ (main:21:30)
at Object.<anonymous> (main:55:24)
I think it's because the files are in the wrong order in the generated js file .. and I read that with grunt you can have a reference file to set the order. Or is this not possible at all?
Using Screeps endpoints is limited as described in documentation.
It would be nice to be informed if I am approaching the limit after executing API call.
I could work on the implementation if someone could give me some tip where to start.
@valerian is currently working on this at the moment, just putting this here for issue tracking purposes.
In the default setting of Powershell, gutils.log
entries that are colored in magenta using gutils.colors.magenta()
are practically invisible as the font color nearly matches the background color.
This is a known issue with the library chalk
that is used internally by gulp-utils
: chalk/chalk#2
To resolve this, I suggest to change the output color from magenta to cyan on all instances.
Any thoughts on this?
Expected behaviour:
On actual errors (such as putting in a bogus word, "wooo" in the middle of code), no upload to the screeps server should occur.
This is not what is happening currently. I tested by downloading the source, setting credentials running:
yarn
git init
git add *
git commit -m "test"
npm run deploy
No errors. Simulator runs fine. Add bogus word "woo" in the middle of main.ts and run:
npm run deploy
Now the simulator fails with error:
[5:18:33 PM]ReferenceError: wooooooo is not defined
at mloop:1377:5
at Object.wrap:1887:12
at Object.module.exports.Object.defineProperty.value:1392:56
at __webpack_require__:21:30
at __webpack_require__:21:30
at module.exports.exports.getArg:67:18
at main:70:10
at eval:3829:4
Full build output:
Staal@pc MINGW64 /f/screeps-typescript-starter-master (master)
$ npm run deploy
> [email protected] deploy F:\screeps-typescript-starter-master
> webpack --colors --env.ENV=dev
clean-webpack-plugin: F:\screeps-typescript-starter-master\dist\dev\* has been removed.
[at-loader] Using [email protected] from typescript and "tsconfig.json" from F:\screeps-typescript-starter-master\tsconfig.json.
[at-loader] Checking started in a separate process...
[at-loader] Checking finished with 1 errors
Hash: 5af8dd5b84150d22ffd1
Version: webpack 2.6.1
Time: 3253ms
Asset Size Chunks Chunk Names
main.js 121 kB 0 [emitted] main
main.js.map 158 kB 0 [emitted] main
[0] ./~/source-map/lib/util.js 10.5 kB {0} [built]
[1] ./src/config/config.ts 657 bytes {0} [built]
[2] ./src/lib/logger/log.ts 5.53 kB {0} [built]
[3] ./src/lib/logger/logLevels.ts 386 bytes {0} [built]
[4] ./~/source-map/lib/array-set.js 2.76 kB {0} [built]
[5] ./~/source-map/lib/base64-vlq.js 4.71 kB {0} [built]
[6] ./~/source-map/lib/source-map-generator.js 13.4 kB {0} [built]
[7] ./src/main.ts 1.04 kB {0} [built] [1 warning]
[11] ./~/screeps-profiler/screeps-profiler.js 8.72 kB {0} [built]
[13] ./~/source-map/lib/binary-search.js 4.25 kB {0} [built]
[14] ./~/source-map/lib/mapping-list.js 2.34 kB {0} [built]
[16] ./~/source-map/lib/source-map-consumer.js 38.4 kB {0} [built]
[17] ./~/source-map/lib/source-node.js 13.5 kB {0} [built]
[18] ./~/source-map/source-map.js 405 bytes {0} [optional] [built]
[20] multi ./src/main.ts 28 bytes {0} [built]
+ 6 hidden modules
WARNING in ./src/main.ts
F:/screeps-typescript-starter-master/src/main.ts
ERROR: 28:3 no-unused-expression unused expression, expected an assignment or function call
ERROR: 28:11 semicolon Missing semicolon
@ multi ./src/main.ts
ERROR in [at-loader] ./src/main.ts:28:3
TS2304: Cannot find name 'wooooooo'.
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] deploy: `webpack --colors --env.ENV=dev`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] deploy script 'webpack --colors --env.ENV=dev'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the screeps-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --colors --env.ENV=dev
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs screeps-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls screeps-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! F:\screeps-typescript-starter-master\npm-debug.log
I've been searching this for a day.
I disabled all the logging and profiling and the cpu is used already at 30 on the first line of mloop.
How are we supposed to use the repo?
And with log and profiling enabled it goes up to 60.
Right now you can only specify a single destination for the bundled code. We should support pushing to different branches and/or servers.
The way I'd like to implement this would be to use environment variables, set in the scripts
block in package.json
(e.g. SCREEPS_DESTINATION=... rollup -c
or similar) which can then be read in the rollup config using process.env
. If this gets merged it should be very easy to change it so that screeps.json
contains a map of names to destination configs, which then have their own script in package.json
to set the appropriate variable.
@screepers/typescript
Considering OCS is up in arms about copyright on their repo, I think we should add a license here and be done with it. (Actually, I think we should do that regardless of what OCS is doing)
https://choosealicense.com/ This site makes it easy.
My recommendation is either:
MIT license which basically lets people do whatever they want with the code as long as they attribute the original repo
Unlicense which relinquishes all rights
I don't think anyone here cares about retaining rights to this repo, which I why I vote for permissive.
If no one has objections to this, after a few days I'll submit a PR with the UNLICENSE
It's frustrating that straight out of the box the project is littered with errors (warnings, really).
Should we change the let
s to const
s per the linter's recommendation?
Should we change the default linting to not worry about it?
Something to think about: I've seen it mentioned on slack that const
is slower in CPU terms. No idea if this is true or just a slack old-wives tale, but something to consider
I've found an issue (and a possible solution) when loading screps-profiler
to a project. I add this issue in case it's useful for others.
We add screeps-profiler dependency as stated in screeps-typescript-starter/docs/in-depth/module-bundling.md:
npm install screeps-profiler
Then we modify src/main.js
to insert all required code:
function ploop() {
if (Config.USE_PROFILER) {
Profiler.wrap(mloop);
} else {
mloop();
}
}
export const loop = ErrorMapper.wrapLoop(ploop);
dist/main.js
contains a bundled screeps-profiler$ yarn push-develop
yarn run v1.3.2
$ rollup -c --dest develop
src/main.ts → dist/main.js...
(!) Missing exports
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
src/main.ts
enable is not exported by node_modules/screeps-profiler/screeps-profiler.js
5: // Screeps system reloads your script.
6: if (Config.USE_PROFILER) {
7: Profiler.enable();
^
8: }
9: /*
src/main.ts
wrap is not exported by node_modules/screeps-profiler/screeps-profiler.js
29: function ploop() {
30: if (Config.USE_PROFILER) {
31: Profiler.wrap(mloop);
^
32: }
33: else {
And dist/main.js
has some undefined
calls:
function ploop() {
if (USE_PROFILER) {
undefined(mloop);
}
else {
mloop();
}
}
In game console:
[10:07:40]TypeError: undefined is not a function
at main:2356:5
at eval:2398:4
at Object.<anonymous>:2:143116
at Object.r.runCode:2:143673
In rollup.config.js
, add a namedExprots section to commonjs
plugin to manually export enable
and wrap
functions.
commonjs({
namedExports: {
'node_modules/screeps-profiler/screeps-profiler.js': ['enable', 'wrap']
}
}),
Maybe screeps-typescript-starter/docs/in-depth/module-bundling.md could be modified to specify the rollup.config.js
modifications required.
Does anyone have a better solution than this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.