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

static sourcemap base prefix of ../ leads to incorrect filepaths in source mapped stack traces, when output folder is more than one folder deep #1253

Open
iamstarkov opened this issue Feb 16, 2025 · 1 comment

Comments

@iamstarkov
Copy link

iamstarkov commented Feb 16, 2025

in my case I have a GitHub action which can consists of smaller sub actions which can be used by themselves. Think of actions/cache with its actions/cache/save and actions/cache/restore. cache action builds into single dist folder but have multiple sub folders for every sub action. I do the same.

Sourcemaps work, but location mapping is one off in terms of traversing up the filesystem hierarchy. I looked into the code and it seems despite ncc programmatically supporting sourceMapBasePrefix, it is not computed at all, let alone relatively to the --output. when I add on extra, sourcemap locations start to match to the original files and I can click on the stack trace and get to an error directly from my vs code

build of the pr sub action:

~/projects/nordnet/gitops (fix/multi-document-yaml) $ npm run build:pr

> [email protected] build:pr
> ncc build pr/action.js -o dist/pr/ --source-map

ncc: Version 0.38.3
ncc: Compiling file index.js into ESM
   0kB  dist/pr/package.json
  40kB  dist/pr/sourcemap-register.cjs
1467kB  dist/pr/index.js
1715kB  dist/pr/index.js.map
1715kB  dist/pr/index.js.map
3222kB  [1237ms] - ncc 0.38.3

before fix (notice how dist is still included into the filepath):


~/projects/nordnet/gitops (fix/multi-document-yaml) $ node --env-file=.env.test dist/pr/index.js

file:///Users/vlasta/projects/nordnet/gitops/dist/src/utils/enhanced-core.js:7
    .foo()
^
TypeError: str.foo is not a function
    at getListFromString (file:///Users/vlasta/projects/nordnet/gitops/dist/src/utils/enhanced-core.js:7:1)
    at Object.getListInput (file:///Users/vlasta/projects/nordnet/gitops/dist/src/utils/enhanced-core.js:26:1)
    at run (file:///Users/vlasta/projects/nordnet/gitops/dist/pr/action.js:35:1)

after fix:

~/projects/nordnet/gitops (fix/multi-document-yaml) $ node --env-file=.env.test dist/pr/index.js

file:///Users/vlasta/projects/nordnet/gitops/src/utils/enhanced-core.js:7
    .foo()
^
TypeError: str.foo is not a function
    at getListFromString (file:///Users/vlasta/projects/nordnet/gitops/src/utils/enhanced-core.js:7:1)
    at Object.getListInput (file:///Users/vlasta/projects/nordnet/gitops/src/utils/enhanced-core.js:26:1)
    at run (file:///Users/vlasta/projects/nordnet/gitops/pr/action.js:35:1)
iamstarkov added a commit to iamstarkov/ncc that referenced this issue Feb 16, 2025
@iamstarkov iamstarkov changed the title sourcemap filesystem mapping is broken when output is more than one folder deep static sourcemap base prefix of ../ leads to incorrect filepaths in source mapped stack traces, when output folder is more than one folder deep Feb 16, 2025
@iamstarkov
Copy link
Author

I believe if you if sourcemapbaseprefix to be relative from build file to output folder, it will solve the issue, so I raised #1254 to discuss that potential fix

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

1 participant