-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(vite-node): provide import.meta.filename and dirname #5011
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
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
return await this.createModule(identifier) | ||
} | ||
|
||
public async resolve(specifier: string, parent: string) { | ||
public resolve(specifier: string, parent: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's behind this change? I'm now running into error where resolveModule
is passing Promise
to createModule
. Then this part:
if (identifier.startsWith('data:')) |
... crashes with error
TypeError: identifier.startsWith is not a function
❯ ExternalModulesExecutor.getModuleInformation ../../packages/vitest/dist/vendor/vm.UXtVveu9.js:575:20
❯ ExternalModulesExecutor.createModule ../../packages/vitest/dist/vendor/vm.UXtVveu9.js:597:38
❯ ExternalModulesExecutor.resolveModule ../../packages/vitest/dist/vendor/vm.UXtVveu9.js:505:23
❯ ../../packages/vitest/dist/vendor/vm.UXtVveu9.js:258:58
❯ ModuleWrap.<anonymous> node:internal/vm/module:306:30
❯ SourceTextModule.<computed> node:internal/vm/module:305:36
❯ SourceTextModule.link node:internal/vm/module:199:22
❯ EsmExecutor.evaluateModule ../../packages/vitest/dist/vendor/vm.UXtVveu9.js:258:11
❯ ExternalModulesExecutor.import ../../packages/vitest/dist/vendor/vm.UXtVveu9.js:621:20
❯ VitestExecutor.interopedImport ../../packages/vite-node/dist/client.mjs:383:28
And by debugging the identifier
there, it's Promise
and not string
.
This can be reproduced with test/run
tests. The exec-argv
one is crashing with vmThreads
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import.meta.resolve
is async
. This is on Node v18.17.1
:
> console.log(nativeResolve.toString())
async function resolve(specifier, parentUrl = defaultParentUrl) {
return PromisePrototypeThen(
asyncESM.esmLoader.resolve(specifier, parentUrl),
({ url }) => url,
(error) => (
error.code === 'ERR_UNSUPPORTED_DIR_IMPORT' ?
error.url : PromiseReject(error)),
);
}
Though it's not in sources: https://github.com/nodejs/node/blob/6ae20aa63de78294b18d5015481485b7cd8fbb60/lib/internal/modules/esm/initialize_import_meta.js#L22
Oh well
Description
Fixes #5010
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.