Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rollup not working #169

Open
M0lion opened this issue Nov 20, 2022 · 8 comments
Open

rollup not working #169

M0lion opened this issue Nov 20, 2022 · 8 comments

Comments

@M0lion
Copy link

M0lion commented Nov 20, 2022

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.

@bastianh
Copy link

bastianh commented Dec 30, 2022

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'); }

@bastianh
Copy link

bastianh commented Dec 30, 2022

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]

@ErikEvenson
Copy link

@M0lion can you share net diff of what you did to get things working? I had the same issue you had.

@Lawlzer
Copy link

Lawlzer commented Feb 8, 2023

(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.

@Lawlzer
Copy link

Lawlzer commented Feb 8, 2023

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)

@pyrodogg
Copy link
Member

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.

@an-stu
Copy link

an-stu commented Dec 2, 2023

Have anyone solved this problem?
[11:25:10]SyntaxError: Unexpected token ':' [main.js.map:1:47]

@tbontb-iaq
Copy link

For people whose sourcemap doesn't work properly, this might be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants