screeps-typescript-starter
screeps-typescript-starter copied to clipboard
rollup not working
I just created a new repo with this as a template and the rollup wasn't working.
I'm using node v18.12.1 and had to remove the thing in package.json requiring node v10 or v12, so I don't know if this happens on those versions, but they're quite old, so maybe update it. I don't know why it's there so I don't know what the right move here is.
At first I got this error
Error loading `tslib` helper library. [!] Error: Package subpath './package.json' is not defined by "exports" in /home/molion/Documents/screeps/node_modules/tslib/package.json
I fixed it by updating all the rollup stuff to the latest version.
Then I got some errors complaining about rollup.config.js probably being an esm file, the message suggested renaming it to .mjs. I tried that, but got some error complaining about use if require().
I changed back to .js and rewrote it to using require instead of import.
I then made a small change because of @rollup/plugin-node-resolve exports not being what was expected.
Now it's working.
I could submit a PR with these changes, but I'm not sure what to do about the node version thing.
instead of renaming it to .mjs you can add "type": "module",
to package json and you can replace the require with import cfgi from "./screeps.json" assert { type: 'json' };
and then later else if ((cfg = cfgi[dest]) == null) { throw new Error('Invalid upload destination'); }
One problem after updating everything is that errormapper will stop working .. not sure which update it was
e.g.:
[11:25:10]SyntaxError: Unexpected token ':' [main.js.map:1:47]
@M0lion can you share net diff of what you did to get things working? I had the same issue you had.
(revised message lower) ~I've gotten this same error. It seems related to the version of Node/NPM.~ ~I was using the latest, node v18, npm v9, and that had the errors~
~If you use VSCode, you should use the .devcontainer
file, as that sets the Node version to v12 (Npm v6)~
~(I believe the reasoning behind this, is because Screeps uses v12 of Node? I could be wrong)~
~If you do not use VSCode/do not want to use a devcontainer, try downgrading to Node v12 and Npm v6.~
I've done a bit more testing:
It might not be caused by the Node/NPM version?
I do not get that issue in the Devcontainer.
However, I get a different error when using nvm
to change my Node version to v12. (I get a node:process
error. V13+ have different errors)
One problem after updating everything is that errormapper will stop working .. not sure which update it was
e.g.:
[11:25:10]SyntaxError: Unexpected token ':' [main.js.map:1:47]
Yea. One thing to note is that this game is stuck in the past in many ways. While much of the "build process" should be able to be updated to keep track modern Node versions, anything that is compiled to actually run in the game needs to be compatible with the game's Node version and general restrictions of running in the game environment (ex. no reliable async).
The source-map
package is probably frozen on the version pinned in package.json unless someone does a bunch of research to find a replacement that is 'up to date' and works with screeps.
Have anyone solved this problem?
[11:25:10]SyntaxError: Unexpected token ':' [main.js.map:1:47]
For people whose sourcemap doesn't work properly, this might be useful.