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

2.1.4: Failed to load source map for typescript.js #6806

Open
6 tasks done
RobinTail opened this issue Oct 29, 2024 · 8 comments · May be fixed by #6816
Open
6 tasks done

2.1.4: Failed to load source map for typescript.js #6806

RobinTail opened this issue Oct 29, 2024 · 8 comments · May be fixed by #6816
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@RobinTail
Copy link
Contributor

RobinTail commented Oct 29, 2024

Describe the bug

While upgrading vitest from 2.1.3 to 2.1.4 this error appeared in the beginning of the tests.
It's not causing tests to fail though.

 RUN  v2.1.4 ...
      Coverage enabled with istanbul

4:01:17 AM [vite] Failed to load source map for .../node_modules/typescript/lib/typescript.js.
Error: An error occurred while trying to read the map file at typescript.js.map
Error: ENOENT: no such file or directory, open '.../node_modules/typescript/lib/typescript.js.map'

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-lgenvr?file=src%2Fbasic.ts

Seems to be related to importing typescript:

import { factory } from 'typescript';

System Info

System:
    OS: macOS 14.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 623.28 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 9.11.0 - ~/.nvm/versions/node/v20.11.1/bin/pnpm
    bun: 1.1.32 - /usr/local/bin/bun
  Browsers:
    Chrome: 130.0.6723.70
    Safari: 18.0.1
  npmPackages:
    @vitest/coverage-istanbul: ^2.0.3 => 2.1.4
    vitest: ^2.0.3 => 2.1.4

Used Package Manager

yarn

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Oct 29, 2024

With this change #6724, we started to surface warning from plugins, so this is a part of it.

Technically this might be typescript package's issue since they have sourceMappingURL which points to a non-existing file.

$ tail node_modules/typescript/lib/typescript.js
//# sourceMappingURL=typescript.js.map

$ ls node_modules/typescript/lib/typescript*
node_modules/typescript/lib/typescript.d.ts
node_modules/typescript/lib/typescript.js    

@RobinTail
Copy link
Contributor Author

RobinTail commented Oct 29, 2024

we started to surface warning from plugins

Well... #6724 aimed to address #6598 that was about custom plugins.
But there is no plugin here, right? It happens in a bare vitest example, @hi-ogawa

Technically this might be typescript package's issue

That's fair.

@RobinTail
Copy link
Contributor Author

RobinTail commented Oct 29, 2024

Related issue in Typescript microsoft/TypeScript#32207
From 2019 🤦🏽‍♀️

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Oct 29, 2024

Well... #6724 aimed to address #6598 that was about custom plugins.
But there is no plugin here, right? It happens in a bare vitest example,

I meant plugins including Vite's internal ones and warning is coming from there.

Btw, another odd thing is that Vitest is transforming a giant typescript.js, which shouldn't be necessary. This could be an issue on Vitest side's heuristics, but for now you can enforce it from test.server.deps.external like this (and this workarounds warnings since Vite won't process the source anymore) https://stackblitz.com/edit/vitest-dev-vitest-81tnhv?file=vite.config.ts

@RobinTail
Copy link
Contributor Author

RobinTail commented Oct 29, 2024

test.server.deps.external

This resolves my problem. Thank you so much!

But you're right, that should have not been necessary taking into account that the default value for test.server.deps.external should be [/node_modules/]

Which btw does work when setting explicitly

server: { deps: { external: [/\/node_modules\//] } },

So that the issue is that the default value mentioned in the documentation is not really applied

@RobinTail
Copy link
Contributor Author

test.server.deps.external is not present in the default config

const config = {
allowOnly: !isCI,
isolate: true,
watch: !isCI,
globals: false,
environment: 'node' as const,
pool: 'forks' as const,
clearMocks: false,
restoreMocks: false,
mockReset: false,
unstubGlobals: false,
unstubEnvs: false,
include: defaultInclude,
exclude: defaultExclude,
teardownTimeout: 10000,
forceRerunTriggers: ['**/package.json/**', '**/{vitest,vite}.config.*/**'],
update: false,
reporters: [],
silent: false,
hideSkippedTests: false,
api: false,
ui: false,
uiBase: '/__vitest__/',
open: !isCI,
css: {
include: [],
},
coverage: coverageConfigDefaults as CoverageV8Options,
fakeTimers: fakeTimersDefaults,
maxConcurrency: 5,
dangerouslyIgnoreUnhandledErrors: false,
typecheck: {
checker: 'tsc' as const,
include: ['**/*.{test,spec}-d.?(c|m)[jt]s?(x)'],
exclude: defaultExclude,
},
slowTestThreshold: 300,
disableConsoleIntercept: false,
} satisfies UserConfig

@RobinTail
Copy link
Contributor Author

odd thing

Made a fix for that in #6807 , @hi-ogawa

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Oct 29, 2024

I haven't looked into this deeper, but It's likely that the issue about external is more complicated than that. Currently, we rely on quite a few checks here and changing the default entirely isn't intended.

async function _shouldExternalize(

And I'm aware that the documentation https://vitest.dev/config/#server-deps-external isn't telling the truth right now.

@hi-ogawa hi-ogawa linked a pull request Oct 30, 2024 that will close this issue
6 tasks
@hi-ogawa hi-ogawa added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
2 participants