-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix(test runner): allow directory imports with path mapping #32491
Conversation
This comment has been minimized.
This comment has been minimized.
f2b9a33
to
f555d90
Compare
This comment has been minimized.
This comment has been minimized.
@@ -367,8 +367,8 @@ export const test = base | |||
const TSCONFIG = { | |||
'compilerOptions': { | |||
'target': 'ESNext', | |||
'moduleResolution': 'node', | |||
'module': 'commonjs', | |||
'moduleResolution': 'bundler', |
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.
why did this change?
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.
This updates our default tsc config in tests to align with what we aim to support, particularly "bundler". Let me land it separately.
packages/playwright/src/util.ts
Outdated
// - https://nodejs.org/dist/latest-v20.x/docs/api/modules.html#folders-as-modules | ||
|
||
const mainField = getMainFieldFromPackageJson(packageJsonPath); | ||
const mainFieldResolved = mainField ? resolveImportSpecifierExtension(path.resolve(resolved, mainField), isPathMapping) : undefined; |
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.
Why do we resolve package's main via path mapping? I don't think we should respect aliases in package.json, so should we just defer to Node from here?
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.
We do not apply path mappings here. resolveImportSpecifierExtension
handles extension substitution, similarly to typescript.
Deferring to Node does not work, that's exactly the issue we are fixing. TypeScript allows ESM directory imports, while pure Node does not.
f555d90
to
00b37ab
Compare
This comment has been minimized.
This comment has been minimized.
This regressed in microsoft#32078.
00b37ab
to
52589e8
Compare
Test results for "tests 1"1 failed 2 flaky29635 passed, 638 skipped Merge workflow run. |
…ts with path mapping We now hopefully align with `moduleResolution: bundler` tsconfig option, allowing directory imports in every scenario, and allowing proper module imports when not going through the type mapping. This regressed in microsoft#32078. Fixes microsoft#32480, fixes microsoft#31811.
We now hopefully align with
moduleResolution: bundler
tsconfig option, allowing directory imports in every scenario, and allowing proper module imports when not going through the type mapping.This regressed in #32078. Fixes #32480, fixes #31811.