Fork me on GitHub

Hello, I want to present my humble template It uses webpack with babel for bundling instead of the Closure's advanced optimizations. I have seen some of the Screeps projects on github, but all of them use optimizations. These optimizations are really nice when you are deploying your code to prod, so your script loads pretty fast, but this is not the case for deploying for Screeps, because it doesn't produce understandable error messages due to massive minifications. So I decided to create this project to resolve this issue. The template doesn't do a lot of stuff, it just compiles the code via and bundles it via with, thus compiled code can be executed in node 8 environment on screeps server.

😎 1

> it doesn't produce understandable error messages due to massive minifications Is there no way to make Screeps use source maps?


shadow-cljs doc says what this is possible I will check this out to see if this will work


I think i’ve been able to get good node stack traces with a combination of the compiler options and the npm package source-map-support


I think source-map support is a good feature to have, thus I created an issue for it. I think we may continue the discussion about this topic there @U02SD8PATK2 So how do you implement it? Can you show your config or leave a link to a project?


I don't any longer. it was in a now abandoned project. but if i recall correctly in the entry file i just required it like so.

(ns some.ns
  (:require ["source-map-support/register"]))
I was using deps.edn and. my build config set
:optimizations :simple
:target        :nodejs
:bundle-cmd {:default ["npx" "webpack" "./out/main.js" "-c" "./webpack.config.js"]}
and my webpack is
const path = require('path');

module.exports = {
  mode: 'production',
  entry: './out/main.js',
  target: 'node',
  // devtool: 'source-map',
  output: {
    path: path.resolve(__dirname, 'deploy'),
    filename: 'main.js',
I don't remember if there was anything else involved as this was quite a while ago. I was deploying things to a lambda.


Actually, I have ended up with the same solution as you, but with (.install (js/require source-map-support)). It works fine with nodejs, but in the screeps environment, it shows this error

Error: Unknown module 'path'
    at Object.requireFn (<isolated-vm>:20840:23)
    at Object.path (main:26726:18)
    at __webpack_require__ (main:26750:41)
    at Object../node_modules/source-map-support/source-map-support.js (main:22859:12)
It looks like the library uses the "path" module, which is probably constrained by devs. I tried your version, but the error is keeping the same, anyway thanks for the answer. I feel that the possible workaround may be the retrieveSourceMap callback:


@U2FRKM4TW After all, I think this is possible, You just need to consume it via and implement error mapping. Like here

👍 1