Open adalinesimonian opened 2 years ago
Were you able to figure out what was going on?
I've tried to create a minimal repro and so far haven't been successful
That's fine, as long as you can provide the steps required to get to the error I can look into it. (The less steps the better)
Any updates on a reproduction here?
I've got a real head-scratcher. When resolving packages in the parent process, everything works as expected and child dependencies are resolved correctly. However, everything changes when running inside of the VS Code child process.
I've tried to create a minimal repro and so far haven't been successful. However, I'm trying to drill into this and figure out what the issue may be, whether it's something to do with Yarn or something to do with VS Code or Jest.
Context
I'm implementing PnP support for jest-runner-vscode, which we use over at vscode-stylelint. Simplified, this is what the runner does:
To use PnP, the runner outputs an SDK that:
each entry point loads the PnP loader, then modifies Module._load to allow the virtual
vscode
module to be resolved (I hope there's a better way to do this):Details
Everything works just fine at the parent level. The child level is where things get complicated. This issue occurs both with Yarn 3.1.1 and 3.2.0-rc.7.
I have this scenario in which Jest uses ts-jest to run TypeScript tests. However, resolving fails as it seems to lack the correct context for resolving dependency packages, or something similar. I'm really not sure what's going wrong here, so I'm trying to collect all the information I can to figure this out. This is the error that occurs:
Resolution error
``` Error: Your application tried to access fast-json-stable-stringify, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound. Required package: fast-json-stable-stringify Required by: C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\e2e\ts-passing-tests\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\3\.yarn\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\dist\utils\ Require stack: - C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\e2e\ts-passing-tests\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\3\.yarn\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\dist\utils\json.js - C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\e2e\ts-passing-tests\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\3\.yarn\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\dist\utils\index.js - C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\e2e\ts-passing-tests\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\3\.yarn\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\dist\presets\create-jest-preset.js - C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\e2e\ts-passing-tests\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\3\.yarn\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\presets\index.js - C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\e2e\ts-passing-tests\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\3\.yarn\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\jest-preset.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\cache\jest-util-npm-27.4.2-2662ef0bf0-bcf16881af.zip\node_modules\jest-util\build\requireOrImportModule.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\cache\jest-util-npm-27.4.2-2662ef0bf0-bcf16881af.zip\node_modules\jest-util\build\index.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\unplugged\@jest-core-virtual-4ba2fd8653\node_modules\@jest\core\build\FailedTestsInteractiveMode.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\unplugged\@jest-core-virtual-4ba2fd8653\node_modules\@jest\core\build\plugins\FailedTestsInteractive.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\unplugged\@jest-core-virtual-4ba2fd8653\node_modules\@jest\core\build\watch.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\unplugged\@jest-core-virtual-4ba2fd8653\node_modules\@jest\core\build\cli\index.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\unplugged\@jest-core-virtual-4ba2fd8653\node_modules\@jest\core\build\jest.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\dist\child\entry-point.js - c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.pnp.cjs at Function.require$$0.Module._resolveFilename (c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.pnp.cjs:15482:13) at Function.require$$0.Module._load (c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.pnp.cjs:15336:42) at Function.pnpifiedModule._load (c:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.jest-vscode\pnp-tools.js:42:20) at Module.require (internal/modules/cjs/loader.js:1006:19) at require (internal/modules/cjs/helpers.js:88:18) at Object.fast-json-stable-stringify is a dependency of ts-jest, but it still fails to load as though it isn't.
So far, among other things, I've tried to log information I can get from the PnP API to see if that leads me to a solution. Currently, I've verified some basic PnP information from the child process:
What's interesting is what happens to the locator tree. At the parent level, the tree seems normal. Here's an output of the tree, only a few levels deep:
Locator tree from parent process:
``` Attempting to require "C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\0\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\dist\index.js" Locator: { "name": "ts-jest", "reference": "virtual:d6dfed325f672d64c6e1e75d503023534ed4d4770195a4dfddbb2e9ace1a5c72d4fd1428b9a5e1e4129e44699b159d31538e97299ee45dccb3c2c619ae29b2f7#npm:27.1.1" } jest-runner-vscode @jest/core @jest/console @types/node ansi-escapes chalk emittery exit graceful-fs jest-changed-files jest-config jest-message-util jest-regex-util jest-resolve-dependencies jest-runtime jest-snapshot jest-util jest-validate jest-watcher micromatch rimraf slash strip-ansi @jest/reporters @bcoe/v8-coverage @jest/console @types/node chalk collect-v8-coverage exit glob graceful-fs istanbul-lib-coverage istanbul-lib-instrument istanbul-lib-report istanbul-lib-source-maps istanbul-reports jest-util jest-worker slash source-map string-length terminal-link v8-to-istanbul @jest/test-result @jest/console collect-v8-coverage @jest/transform @babel/core babel-plugin-istanbul chalk convert-source-map fast-json-stable-stringify graceful-fs jest-regex-util jest-util micromatch pirates slash source-map write-file-atomic @jest/types @types/istanbul-reports @types/node @types/yargs chalk @types/babel__core @babel/parser @babel/types @types/babel__generator @types/babel__template @types/babel__traverse @types/fs-extra @types/node @types/istanbul-lib-coverage @types/jest jest-diff pretty-format @types/node @types/node-ipc @types/node @types/vscode @types/yargs @types/yargs-parser @typescript-eslint/eslint-plugin @typescript-eslint/experimental-utils @typescript-eslint/scope-manager debug functional-red-black-tree ignore regexpp semver tsutils @typescript-eslint/parser @typescript-eslint/scope-manager @typescript-eslint/types @typescript-eslint/typescript-estree debug @vscode/test-electron http-proxy-agent https-proxy-agent rimraf unzipper cosmiconfig @types/parse-json import-fresh parse-json path-type yaml esbuild esbuild-android-arm64 esbuild-darwin-64 esbuild-darwin-arm64 esbuild-freebsd-64 esbuild-freebsd-arm64 esbuild-linux-32 esbuild-linux-64 esbuild-linux-arm esbuild-linux-arm64 esbuild-linux-mips64le esbuild-linux-ppc64le esbuild-netbsd-64 esbuild-openbsd-64 esbuild-sunos-64 esbuild-windows-32 esbuild-windows-64 esbuild-windows-arm64 eslint @eslint/eslintrc @humanwhocodes/config-array ajv chalk cross-spawn debug doctrine enquirer escape-string-regexp eslint-scope eslint-utils eslint-visitor-keys espree esquery esutils fast-deep-equal file-entry-cache functional-red-black-tree glob-parent globals ignore import-fresh imurmurhash is-glob js-yaml json-stable-stringify-without-jsonify levn lodash.merge minimatch natural-compare optionator progress regexpp semver strip-ansi strip-json-comments text-table v8-compile-cache eslint-config-prettier execa cross-spawn get-stream human-signals is-stream merge-stream npm-run-path onetime signal-exit strip-final-newline fast-glob @nodelib/fs.stat @nodelib/fs.walk glob-parent merge2 micromatch fs-extra graceful-fs jsonfile universalify jest import-local jest-cli chalk exit graceful-fs import-local jest-config jest-util jest-validate prompts yargs jest-environment-node @jest/environment @jest/fake-timers @types/node jest-mock jest-util jest-haste-map @types/graceful-fs @types/node anymatch fb-watchman fsevents graceful-fs jest-regex-util jest-serializer jest-util jest-worker micromatch walker jest-resolve chalk graceful-fs jest-pnp-resolver jest-util jest-validate resolve resolve.exports slash jest-runner @jest/console @jest/environment @types/node chalk emittery exit graceful-fs jest-docblock jest-environment-jsdom jest-leak-detector jest-message-util jest-runtime jest-util jest-worker source-map-support throat js-message node-ipc event-pubsub js-queue npm-run-all ansi-styles chalk cross-spawn memorystream minimatch pidtree read-pkg shell-quote string.prototype.padend prettier ts-jest bs-logger fast-json-stable-stringify jest-util json5 lodash.memoize make-error semver yargs-parser typescript yargs cliui escalade get-caller-file require-directory string-width y18n yargs-parser ```However, from the child process, the tree is flattened:
Locator tree from child process:
``` Attempting to require "C:\Users\Adaline\GitHub\adalinesimonian\jest-runner-vscode\e2e\ts-passing-tests\.yarn\__virtual__\ts-jest-virtual-5a64f3962e\3\.yarn\cache\ts-jest-npm-27.1.1-e3e86ec65d-3aea680833.zip\node_modules\ts-jest\jest-preset.js" Locator: null jest-runner-vscode @jest/core @jest/console @types/node ansi-escapes chalk emittery exit graceful-fs jest-changed-files jest-config jest-message-util jest-regex-util jest-resolve-dependencies jest-runtime jest-snapshot jest-util jest-validate jest-watcher micromatch rimraf slash strip-ansi @jest/reporters @bcoe/v8-coverage @jest/console @types/node chalk collect-v8-coverage exit glob graceful-fs istanbul-lib-coverage istanbul-lib-instrument istanbul-lib-report istanbul-lib-source-maps istanbul-reports jest-util jest-worker slash source-map string-length terminal-link v8-to-istanbul @jest/test-result @jest/console collect-v8-coverage @jest/transform @babel/core babel-plugin-istanbul chalk convert-source-map fast-json-stable-stringify graceful-fs jest-regex-util jest-util micromatch pirates slash source-map write-file-atomic @jest/types @types/istanbul-reports @types/node @types/yargs chalk @types/babel__core @babel/parser @babel/types @types/babel__generator @types/babel__template @types/babel__traverse @types/fs-extra @types/node @types/istanbul-lib-coverage @types/jest jest-diff pretty-format @types/node @types/node-ipc @types/node @types/vscode @types/yargs @types/yargs-parser @typescript-eslint/eslint-plugin @typescript-eslint/experimental-utils @typescript-eslint/scope-manager debug functional-red-black-tree ignore regexpp semver tsutils @typescript-eslint/parser @typescript-eslint/scope-manager @typescript-eslint/types @typescript-eslint/typescript-estree debug @vscode/test-electron http-proxy-agent https-proxy-agent rimraf unzipper cosmiconfig @types/parse-json import-fresh parse-json path-type yaml esbuild esbuild-android-arm64 esbuild-darwin-64 esbuild-darwin-arm64 esbuild-freebsd-64 esbuild-freebsd-arm64 esbuild-linux-32 esbuild-linux-64 esbuild-linux-arm esbuild-linux-arm64 esbuild-linux-mips64le esbuild-linux-ppc64le esbuild-netbsd-64 esbuild-openbsd-64 esbuild-sunos-64 esbuild-windows-32 esbuild-windows-64 esbuild-windows-arm64 eslint @eslint/eslintrc @humanwhocodes/config-array ajv chalk cross-spawn debug doctrine enquirer escape-string-regexp eslint-scope eslint-utils eslint-visitor-keys espree esquery esutils fast-deep-equal file-entry-cache functional-red-black-tree glob-parent globals ignore import-fresh imurmurhash is-glob js-yaml json-stable-stringify-without-jsonify levn lodash.merge minimatch natural-compare optionator progress regexpp semver strip-ansi strip-json-comments text-table v8-compile-cache eslint-config-prettier execa cross-spawn get-stream human-signals is-stream merge-stream npm-run-path onetime signal-exit strip-final-newline fast-glob @nodelib/fs.stat @nodelib/fs.walk glob-parent merge2 micromatch fs-extra graceful-fs jsonfile universalify jest import-local jest-cli chalk exit graceful-fs import-local jest-config jest-util jest-validate prompts yargs jest-environment-node @jest/environment @jest/fake-timers @types/node jest-mock jest-util jest-haste-map @types/graceful-fs @types/node anymatch fb-watchman fsevents graceful-fs jest-regex-util jest-serializer jest-util jest-worker micromatch walker jest-resolve chalk graceful-fs jest-pnp-resolver jest-util jest-validate resolve resolve.exports slash jest-runner @jest/console @jest/environment @types/node chalk emittery exit graceful-fs jest-docblock jest-environment-jsdom jest-leak-detector jest-message-util jest-runtime jest-util jest-worker source-map-support throat js-message node-ipc event-pubsub js-queue npm-run-all ansi-styles chalk cross-spawn memorystream minimatch pidtree read-pkg shell-quote string.prototype.padend prettier ts-jest bs-logger fast-json-stable-stringify jest-util json5 lodash.memoize make-error semver yargs-parser typescript yargs cliui escalade get-caller-file require-directory string-width y18n yargs-parser ```What might this indicate? How should I go about figuring this out?