重新混合源映射支持 `TypeError: 列必须大于或等于 0,得到 -1`

问题描述 投票:0回答:1

使用bun和express运行remix,我遇到了

source-map-support
错误。

用类似express的代码

sourceMapSupport.install({
  retrieveSourceMap: function (source) {
    console.log(source, `${source}.map`)
    return {
      url: source,
      map: fs.readFileSync(`${source}.map`, "utf8"),
    }
  },
})

要恢复源映射,我收到错误:

/Users/dangoodman/code/sellmyai/build/index.js /Users/dangoodman/code/sellmyai/build/index.js.map
583 |     if (aNeedle[aLineName] <= 0) {
584 |       throw new TypeError('Line must be greater than or equal to 1, got '
585 |                           + aNeedle[aLineName]);
586 |     }
587 |     if (aNeedle[aColumnName] < 0) {
588 |       throw new TypeError('Column must be greater than or equal to 0, got '
                  ^
TypeError: Column must be greater than or equal to 0, got -1
      at SourceMapConsumer_findMapping (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:588:13)
      at SourceMapConsumer_originalPositionFor (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:653:17)
      at mapSourcePosition (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:244:28)
      at wrapCallSite (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:397:20)
      at prepareStackTrace (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:446:39)
      at new RowsNotFound (/Users/dangoodman/code/sellmyai/build/index.js:550:30)
      at /Users/dangoodman/code/sellmyai/build/index.js:2490:11
      at processTicksAndRejections (:61:77)

(省略

retrieveSourceMap
选项会导致相同的错误)

我可以确认该文件存在于该位置。我的

remix.config.js
看起来像:

/** @type {import('@remix-run/dev').AppConfig} */
export default {
  ignoredRouteFiles: ["**/.*"],
  serverModuleFormat: "esm",
  appDirectory: "src/remix",
};

我将混音放入面包中,例如:

import * as build from "../build/index.js"

app.all("*", createRequestHandler({ build: build as any }))

并拥有开发命令:

"remix dev --manual -c \"bun --watch run src/index.ts\""

如果我登录我得到的来源(基于下面的评论):

/Users/dangoodman/code/sellmyai/build/index.js
/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js
/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js

完整错误:

/Users/dangoodman/code/sellmyai/build/index.js
583 |     if (aNeedle[aLineName] <= 0) {
584 |       throw new TypeError('Line must be greater than or equal to 1, got '
585 |                           + aNeedle[aLineName]);
586 |     }
587 |     if (aNeedle[aColumnName] < 0) {
588 |       throw new TypeError('Column must be greater than or equal to 0, got '
                  ^
TypeError: Column must be greater than or equal to 0, got -1
      at SourceMapConsumer_findMapping (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:588:13)
      at SourceMapConsumer_originalPositionFor (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:653:17)
      at mapSourcePosition (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:244:28)
      at wrapCallSite (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:397:20)
      at prepareStackTrace (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:446:39)
      at new RowsNotFound (/Users/dangoodman/code/sellmyai/build/index.js:550:30)
      at /Users/dangoodman/code/sellmyai/build/index.js:2503:11
      at processTicksAndRejections (:61:77)

/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js
/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js
586 |     }
587 |     if (aNeedle[aColumnName] < 0) {
588 |       throw new TypeError('Column must be greater than or equal to 0, got '
589 |                           + aNeedle[aColumnName]);
590 |     }
591 |
                                                                          ^
TypeError: Column must be greater than or equal to 0, got -1
      at SourceMapConsumer_findMapping (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:591:69)
      at SourceMapConsumer_originalPositionFor (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:662:10)
      at mapSourcePosition (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:28:1)
      at wrapCallSite (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:398:7)
      at prepareStackTrace (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:449:55)
      at captureStackTrace (native:1:1)
      at new RowsNotFound (/Users/dangoodman/code/sellmyai/src/remix/routes/dashboard.settings.tsx:302:13)
remix.run bun
1个回答
0
投票

从最新的 Express 模板中尝试一下:

sourceMapSupport.install({
  retrieveSourceMap: function (source) {
    const match = source.startsWith("file://");
    if (match) {
      const filePath = url.fileURLToPath(source);
      const sourceMapPath = `${filePath}.map`;
      if (fs.existsSync(sourceMapPath)) {
        return {
          url: source,
          map: fs.readFileSync(sourceMapPath, "utf8"),
        };
      }
    }
    return null;
  },
});

https://github.com/remix-run/remix/blob/69ab6ace535e200d182968082568672bd2873ad5/templates/express/server.js#L12C1-L27C4

© www.soinside.com 2019 - 2024. All rights reserved.