diff --git a/.changeset/sweet-mangos-marry.md b/.changeset/sweet-mangos-marry.md new file mode 100644 index 0000000..9093e05 --- /dev/null +++ b/.changeset/sweet-mangos-marry.md @@ -0,0 +1,9 @@ +--- +"@arethetypeswrong/core": minor +--- + +New problem kind: **Missing `export =`** + +Previously, `FalseExportDefault` had many cases of false positives where the JavaScript assigned an object to `module.exports`, and that object had a `default` property pointing back to itself. This pattern is not a true `FalseExportDefault`, but it is still problematic if the types only declare an `export default`. These kinds of false positives of `FalseExportDefault` are now instead reported as `MissingExportEquals`. + +Additionally, `FalseExportDefault` was only ever reported as being visible in `node16-esm`, but this was incorrect. The consequences are most likely to be visible in `node16-esm`, but the problem is fundamentally independent of the module resolution mode, and inaccuracies can be observed in other modes as well, especially when `esModuleInterop` is not enabled. diff --git a/docs/problems/MissingExportEquals.md b/docs/problems/MissingExportEquals.md new file mode 100644 index 0000000..6deb103 --- /dev/null +++ b/docs/problems/MissingExportEquals.md @@ -0,0 +1,77 @@ +# ❓ Missing `export =` + +The JavaScript appears to set both `module.exports` and `module.exports.default` for improved compatibility, but the types only reflect the latter (by using `export default`). This will cause TypeScript under the `node16` module mode to think an extra `.default` property access is required, which will work at runtime but is not necessary. These types `export =` an object with a `default` property instead of using `export default`. + +## Explanation + +This problem occurs when a CommonJS JavaScript file appears to use a compatibility pattern like: + +```js +class Whatever { + /* ... */ +} +Whatever.default = Whatever; +module.exports = Whatever; +``` + +but the corresponding type definitions only reflect the existence of the `module.exports.default` property: + +```ts +declare class Whatever { + /* ... */ +} +export default Whatever; +``` + +The types should declare the existence of the `Whatever` class on both `module.exports` and `module.exports.default`. The method of doing this can vary depending on the kinds of things already being exported from the types. When the `export default` exports a class, and that class is the only export in the file, the `default` can be declared as a static property on the class, and the `export default` swapped for `export =`: + +```ts +declare class Whatever { + static default: typeof Whatever; + /* ... */ +} +export = Whatever; +``` + +When the file exports additional types, it will be necessary to declare a `namespace` that merges with the class and contains the exported types: + +```ts +declare class Whatever { + static default: typeof Whatever; + /* ... */ +} +declare namespace Whatever { + export interface WhateverProps { + /* ... */ + } +} +export = Whatever; +``` + +This merging namespace can also be used to declare the `default` property when the main export is a function: + +```ts +declare function Whatever(props: Whatever.WhateverProps): void; +declare namespace Whatever { + declare const _default: typeof Whatever; + export { _default as default }; + + export interface WhateverProps { + /* ... */ + } +} +export = Whatever; +``` + +## Consequences + +This problem is similar to the [“Incorrect default export”](./FalseExportDefault.md) problem, but in this case, the types are _incomplete_ rather than wholly incorrect. This incompleteness may lead TypeScript users importing from Node.js ESM code, or CommonJS code without `esModuleInterop` enabled, to add an extra `.default` property onto default imports to access the module’s `module.exports.default` property, even though accessing the `module.exports` would have been sufficient. + +```ts +import Whatever from "pkg"; +Whatever.default(); // Ok, but `Whatever()` would have worked! +``` + +## Common causes + +This problem is usually caused by library authors incorrectly hand-authoring declaration files to match existing JavaScript rather than generating JavaScript and type declarations from TypeScript with `tsc`, or by using a third-party TypeScript emitter that adds an extra compatibility layer to TypeScript written with `export default`. Libraries compiling to CommonJS should generally avoid writing `export default` as input syntax. diff --git a/packages/cli/src/problemUtils.ts b/packages/cli/src/problemUtils.ts index a8b7624..69277b5 100644 --- a/packages/cli/src/problemUtils.ts +++ b/packages/cli/src/problemUtils.ts @@ -11,6 +11,7 @@ export const problemFlags: Record = { FallbackCondition: "fallback-condition", CJSOnlyExportsDefault: "cjs-only-exports-default", FalseExportDefault: "false-export-default", + MissingExportEquals: "missing-export-equals", UnexpectedModuleSyntax: "unexpected-module-syntax", InternalResolutionError: "internal-resolution-error", }; diff --git a/packages/cli/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.md b/packages/cli/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.md index 839db41..24d30c3 100644 --- a/packages/cli/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.md +++ b/packages/cli/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.md @@ -6,14 +6,16 @@ $ attw @vitejs__plugin-react@3.1.0.tgz -f table-flipped @vitejs/plugin-react v3.1.0 +❓ The JavaScript appears to set both module.exports and module.exports.default for improved compatibility, but the types only reflect the latter (by using export default). This will cause TypeScript under the node16 module mode to think an extra .default property access is required, which will work at runtime but is not necessary. These types export = an object with a default property instead of using export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/MissingExportEquals.md + 🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md -┌────────────────────────┬────────┬───────────────────┬────────────────────────┬─────────┐ -│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ -├────────────────────────┼────────┼───────────────────┼────────────────────────┼─────────┤ -│ "@vitejs/plugin-react" │ 🟢 │ 🟢 (CJS) │ 🎭 Masquerading as CJS │ 🟢 │ -└────────────────────────┴────────┴───────────────────┴────────────────────────┴─────────┘ +┌────────────────────────┬───────────────────────┬───────────────────────┬────────────────────────┬─────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────┼─────────┤ +│ "@vitejs/plugin-react" │ ❓ Missing `export =` │ ❓ Missing `export =` │ 🎭 Masquerading as CJS │ 🟢 │ +└────────────────────────┴───────────────────────┴───────────────────────┴────────────────────────┴─────────┘ ``` diff --git a/packages/cli/test/snapshots/ajv@8.12.0.tgz.md b/packages/cli/test/snapshots/ajv@8.12.0.tgz.md index 1129684..fb2e0bd 100644 --- a/packages/cli/test/snapshots/ajv@8.12.0.tgz.md +++ b/packages/cli/test/snapshots/ajv@8.12.0.tgz.md @@ -11,16 +11,16 @@ Build tools: - rollup@^2.44.0 - @rollup/plugin-typescript@^10.0.1 - No problems found 🌟 +❓ The JavaScript appears to set both module.exports and module.exports.default for improved compatibility, but the types only reflect the latter (by using export default). This will cause TypeScript under the node16 module mode to think an extra .default property access is required, which will work at runtime but is not necessary. These types export = an object with a default property instead of using export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/MissingExportEquals.md -┌───────┬────────┬───────────────────┬───────────────────┬─────────┐ -│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ -├───────┼────────┼───────────────────┼───────────────────┼─────────┤ -│ "ajv" │ 🟢 │ 🟢 (CJS) │ 🟢 (CJS) │ 🟢 │ -└───────┴────────┴───────────────────┴───────────────────┴─────────┘ +┌───────┬───────────────────────┬───────────────────────┬───────────────────────┬───────────────────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├───────┼───────────────────────┼───────────────────────┼───────────────────────┼───────────────────────┤ +│ "ajv" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +└───────┴───────────────────────┴───────────────────────┴───────────────────────┴───────────────────────┘ ``` -Exit code: 0 \ No newline at end of file +Exit code: 1 \ No newline at end of file diff --git a/packages/cli/test/snapshots/axios@1.4.0.tgz.md b/packages/cli/test/snapshots/axios@1.4.0.tgz.md index 8813aaa..c962678 100644 --- a/packages/cli/test/snapshots/axios@1.4.0.tgz.md +++ b/packages/cli/test/snapshots/axios@1.4.0.tgz.md @@ -10,7 +10,7 @@ Build tools: - typescript@^4.8.4 - rollup@^2.67.0 -❓ Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 +🃏 Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md @@ -24,7 +24,7 @@ Build tools: ├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼────────────────────┼────────────────────┤ │ "axios" │ 🟢 │ 🟢 (CJS) │ 🟢 (ESM) │ 🟢 │ ├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼────────────────────┼────────────────────┤ -│ "axios/unsafe/*" │ ❓ Unable to check │ ❓ Unable to check │ ❓ Unable to check │ ❓ Unable to check │ +│ "axios/unsafe/*" │ 🃏 Unable to check │ 🃏 Unable to check │ 🃏 Unable to check │ 🃏 Unable to check │ ├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼────────────────────┼────────────────────┤ │ "axios/unsafe/core/settle.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ │ │ │ ⚠️ ESM (dynamic import only) │ │ │ diff --git a/packages/cli/test/snapshots/hexoid@1.0.0.tgz.md b/packages/cli/test/snapshots/hexoid@1.0.0.tgz.md index 0a9545f..1c17f73 100644 --- a/packages/cli/test/snapshots/hexoid@1.0.0.tgz.md +++ b/packages/cli/test/snapshots/hexoid@1.0.0.tgz.md @@ -9,11 +9,11 @@ hexoid v1.0.0 ❗️ The resolved types use export default where the JavaScript file appears to use module.exports =. This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime. These types should use export = instead of export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md -┌──────────┬────────┬───────────────────┬──────────────────────────────┬─────────┐ -│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ -├──────────┼────────┼───────────────────┼──────────────────────────────┼─────────┤ -│ "hexoid" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -└──────────┴────────┴───────────────────┴──────────────────────────────┴─────────┘ +┌──────────┬──────────────────────────────┬──────────────────────────────┬──────────────────────────────┬──────────────────────────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├──────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ +│ "hexoid" │ ❗️ Incorrect default export │ ❗️ Incorrect default export │ ❗️ Incorrect default export │ ❗️ Incorrect default export │ +└──────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘ ``` diff --git a/packages/cli/test/snapshots/postcss@8.4.21.tgz.md b/packages/cli/test/snapshots/postcss@8.4.21.tgz.md index de320ed..62ba6b3 100644 --- a/packages/cli/test/snapshots/postcss@8.4.21.tgz.md +++ b/packages/cli/test/snapshots/postcss@8.4.21.tgz.md @@ -6,77 +6,77 @@ $ attw postcss@8.4.21.tgz -f table-flipped postcss v8.4.21 +❓ The JavaScript appears to set both module.exports and module.exports.default for improved compatibility, but the types only reflect the latter (by using export default). This will cause TypeScript under the node16 module mode to think an extra .default property access is required, which will work at runtime but is not necessary. These types export = an object with a default property instead of using export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/MissingExportEquals.md + 🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md 🐛 Import resolved to types through a conditional package.json export, but only after failing to resolve through an earlier condition. This behavior is a TypeScript bug (https://github.com/microsoft/TypeScript/issues/50762). It may misrepresent the runtime behavior of this import and should not be relied upon. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FallbackCondition.md -❗️ The resolved types use export default where the JavaScript file appears to use module.exports =. This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime. These types should use export = instead of export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md - ❌ Import resolved to JavaScript files, but no type declarations were found. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/UntypedResolution.md -┌──────────────────────────────────┬─────────────┬───────────────────┬──────────────────────────────┬────────────────────────────┐ -│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss" │ 🟢 │ 🟢 (CJS) │ 🎭 Masquerading as CJS │ 🐛 Used fallback condition │ -│ │ │ │ 🐛 Used fallback condition │ │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/at-rule" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/comment" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/container" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/css-syntax-error" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/declaration" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/fromJSON" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/input" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/lazy-result" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/no-work-result" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/list" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/map-generator" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/node" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/parse" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/parser" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/postcss" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/previous-map" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/processor" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/result" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/root" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/rule" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/stringifier" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/stringify" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/symbols" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/terminal-highlight" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/tokenize" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/warn-once" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/lib/warning" │ 🟢 │ 🟢 (CJS) │ ❗️ Incorrect default export │ 🟢 │ -├──────────────────────────────────┼─────────────┼───────────────────┼──────────────────────────────┼────────────────────────────┤ -│ "postcss/package.json" │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ -└──────────────────────────────────┴─────────────┴───────────────────┴──────────────────────────────┴────────────────────────────┘ +┌──────────────────────────────────┬───────────────────────┬───────────────────────┬────────────────────────────┬────────────────────────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss" │ ❓ Missing `export =` │ ❓ Missing `export =` │ 🎭 Masquerading as CJS │ 🐛 Used fallback condition │ +│ │ │ │ 🐛 Used fallback condition │ │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/at-rule" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/comment" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/container" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/css-syntax-error" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/declaration" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/fromJSON" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/input" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/lazy-result" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/no-work-result" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/list" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/map-generator" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/node" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/parse" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/parser" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/postcss" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/previous-map" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/processor" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/result" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/root" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/rule" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/stringifier" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/stringify" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/symbols" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/terminal-highlight" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/tokenize" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/warn-once" │ ❌ No types │ ❌ No types │ ❌ No types │ ❌ No types │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/lib/warning" │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ ❓ Missing `export =` │ +├──────────────────────────────────┼───────────────────────┼───────────────────────┼────────────────────────────┼────────────────────────────┤ +│ "postcss/package.json" │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ +└──────────────────────────────────┴───────────────────────┴───────────────────────┴────────────────────────────┴────────────────────────────┘ ``` diff --git a/packages/cli/test/snapshots/vue@3.3.4.tgz --exclude-entrypoints macros -f ascii.md b/packages/cli/test/snapshots/vue@3.3.4.tgz --exclude-entrypoints macros -f ascii.md index 65f8b6e..8f50f42 100644 --- a/packages/cli/test/snapshots/vue@3.3.4.tgz --exclude-entrypoints macros -f ascii.md +++ b/packages/cli/test/snapshots/vue@3.3.4.tgz --exclude-entrypoints macros -f ascii.md @@ -10,7 +10,7 @@ vue v3.3.4 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md -❓ Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 +🃏 Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md @@ -71,10 +71,10 @@ bundler: 🟢 "vue/dist/*" -node10: ❓ Unable to check -node16 (from CJS): ❓ Unable to check -node16 (from ESM): ❓ Unable to check -bundler: ❓ Unable to check +node10: 🃏 Unable to check +node16 (from CJS): 🃏 Unable to check +node16 (from ESM): 🃏 Unable to check +bundler: 🃏 Unable to check *********************************** diff --git a/packages/cli/test/snapshots/vue@3.3.4.tgz --include-entrypoints .foo -f ascii.md b/packages/cli/test/snapshots/vue@3.3.4.tgz --include-entrypoints .foo -f ascii.md index 926827b..2a1f90d 100644 --- a/packages/cli/test/snapshots/vue@3.3.4.tgz --include-entrypoints .foo -f ascii.md +++ b/packages/cli/test/snapshots/vue@3.3.4.tgz --include-entrypoints .foo -f ascii.md @@ -10,7 +10,7 @@ vue v3.3.4 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md -❓ Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 +🃏 Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md @@ -71,10 +71,10 @@ bundler: 🟢 "vue/dist/*" -node10: ❓ Unable to check -node16 (from CJS): ❓ Unable to check -node16 (from ESM): ❓ Unable to check -bundler: ❓ Unable to check +node10: 🃏 Unable to check +node16 (from CJS): 🃏 Unable to check +node16 (from ESM): 🃏 Unable to check +bundler: 🃏 Unable to check *********************************** diff --git a/packages/cli/test/snapshots/vue@3.3.4.tgz.md b/packages/cli/test/snapshots/vue@3.3.4.tgz.md index 9974d36..71e1729 100644 --- a/packages/cli/test/snapshots/vue@3.3.4.tgz.md +++ b/packages/cli/test/snapshots/vue@3.3.4.tgz.md @@ -10,7 +10,7 @@ vue v3.3.4 💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md -❓ Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 +🃏 Wildcard subpaths cannot yet be analyzed by this tool. https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/40 🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md @@ -30,7 +30,7 @@ vue v3.3.4 ├───────────────────────┼──────────────────────┼────────────────────┼──────────────────────────────┼────────────────────┤ │ "vue/jsx" │ 🟢 │ 🟢 (CJS) │ 🟢 (CJS) │ 🟢 │ ├───────────────────────┼──────────────────────┼────────────────────┼──────────────────────────────┼────────────────────┤ -│ "vue/dist/*" │ ❓ Unable to check │ ❓ Unable to check │ ❓ Unable to check │ ❓ Unable to check │ +│ "vue/dist/*" │ 🃏 Unable to check │ 🃏 Unable to check │ 🃏 Unable to check │ 🃏 Unable to check │ ├───────────────────────┼──────────────────────┼────────────────────┼──────────────────────────────┼────────────────────┤ │ "vue/package.json" │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ ├───────────────────────┼──────────────────────┼────────────────────┼──────────────────────────────┼────────────────────┤ diff --git a/packages/core/src/checks/entrypointResolutionProblems.ts b/packages/core/src/checks/entrypointResolutionProblems.ts index 7e2a25c..374ec58 100644 --- a/packages/core/src/checks/entrypointResolutionProblems.ts +++ b/packages/core/src/checks/entrypointResolutionProblems.ts @@ -1,7 +1,7 @@ import ts from "typescript"; import type { EntrypointInfo, EntrypointResolutionProblem } from "../types.js"; import type { CompilerHosts } from "../multiCompilerHost.js"; -import { resolvedThroughFallback, visitResolutions } from "../utils.js"; +import { getResolutionOption, resolvedThroughFallback, visitResolutions } from "../utils.js"; export function getEntrypointResolutionProblems( entrypointResolutions: Record, @@ -11,6 +11,7 @@ export function getEntrypointResolutionProblems( visitResolutions(entrypointResolutions, (result, entrypoint) => { const { subpath } = entrypoint; const { resolutionKind } = result; + const resolutionOption = getResolutionOption(resolutionKind); if (result.isWildcard) { problems.push({ kind: "Wildcard", @@ -70,13 +71,14 @@ export function getEntrypointResolutionProblems( }); } - if (resolutionKind === "node16-esm" && resolution && implementationResolution) { - const typesSourceFile = hosts.node16.getSourceFile(resolution.fileName); + if (resolution && implementationResolution) { + const host = hosts[resolutionOption]; + const typesSourceFile = host.getSourceFile(resolution.fileName); if (typesSourceFile) { ts.bindSourceFile(typesSourceFile, { target: ts.ScriptTarget.Latest, allowJs: true, checkJs: true }); } const typesExports = typesSourceFile?.symbol?.exports; - const jsSourceFile = typesExports && hosts.node16.getSourceFile(implementationResolution.fileName); + const jsSourceFile = typesExports && host.getSourceFile(implementationResolution.fileName); if (jsSourceFile) { ts.bindSourceFile(jsSourceFile, { target: ts.ScriptTarget.Latest, allowJs: true, checkJs: true }); } @@ -85,12 +87,32 @@ export function getEntrypointResolutionProblems( if ( typesExports.has(ts.InternalSymbolName.Default) && !typesExports.has(ts.InternalSymbolName.ExportEquals) && - jsExports.has(ts.InternalSymbolName.ExportEquals) && - !jsExports.has(ts.InternalSymbolName.Default) + jsExports.has(ts.InternalSymbolName.ExportEquals) ) { - // Also need to check for `default` property on `jsModule["export="]`? + if (!jsExports.has(ts.InternalSymbolName.Default)) { + const jsChecker = host + .createProgram([implementationResolution.fileName], { + allowJs: true, + checkJs: true, + }) + .getTypeChecker(); + // Check for `default` property on `jsModule["export="]` + if ( + !jsChecker + .getExportsAndPropertiesOfModule(jsChecker.resolveExternalModuleSymbol(jsSourceFile.symbol)) + .some((s) => s.name === "default") + ) { + problems.push({ + kind: "FalseExportDefault", + entrypoint: subpath, + resolutionKind, + }); + return; + } + } + // types have a default, JS has a default and a module.exports = problems.push({ - kind: "FalseExportDefault", + kind: "MissingExportEquals", entrypoint: subpath, resolutionKind, }); diff --git a/packages/core/src/multiCompilerHost.ts b/packages/core/src/multiCompilerHost.ts index 6e1a0b2..8947b32 100644 --- a/packages/core/src/multiCompilerHost.ts +++ b/packages/core/src/multiCompilerHost.ts @@ -30,7 +30,10 @@ export class CompilerHostWrapper { private normalModuleResolutionCache: ts.ModuleResolutionCache; private noDtsResolutionModuleResolutionCache: ts.ModuleResolutionCache; - private traceCache: Record> = {}; + private moduleResolutionCache: Record< + /*FromFileName*/ string, + Record + > = {}; private traceCollector: TraceCollector = new TraceCollector(); private languageVersion = ts.ScriptTarget.Latest; @@ -86,22 +89,30 @@ export class CompilerHostWrapper { moduleName: string, containingFile: string, resolutionMode?: ts.ModuleKind.ESNext | ts.ModuleKind.CommonJS, - noDtsResolution?: boolean + noDtsResolution?: boolean, + allowJs?: boolean ): ResolveModuleNameResult { + const moduleKey = this.getModuleKey(moduleName, resolutionMode, noDtsResolution, allowJs); + if (this.moduleResolutionCache[containingFile]?.[moduleKey]) { + const { resolution, trace } = this.moduleResolutionCache[containingFile][moduleKey]; + return { + resolution, + trace, + }; + } this.traceCollector.clear(); const resolution = ts.resolveModuleName( moduleName, containingFile, - noDtsResolution ? { ...this.compilerOptions, noDtsResolution } : this.compilerOptions, + noDtsResolution ? { ...this.compilerOptions, noDtsResolution, allowJs } : this.compilerOptions, this.compilerHost, noDtsResolution ? this.noDtsResolutionModuleResolutionCache : this.normalModuleResolutionCache, /*redirectedReference*/ undefined, resolutionMode ); const trace = this.traceCollector.read(); - const moduleKey = `${resolutionMode ?? 1}:${moduleName}`; - if (!this.traceCache[containingFile]?.[moduleKey]) { - (this.traceCache[containingFile] ??= {})[moduleKey] = trace; + if (!this.moduleResolutionCache[containingFile]?.[moduleKey]) { + (this.moduleResolutionCache[containingFile] ??= {})[moduleKey] = { resolution, trace }; } return { resolution, @@ -114,13 +125,40 @@ export class CompilerHostWrapper { moduleSpecifier: string, resolutionMode: ts.ModuleKind.ESNext | ts.ModuleKind.CommonJS | undefined ): string[] | undefined { - return this.traceCache[fromFileName]?.[`${resolutionMode ?? 1}:${moduleSpecifier}`]; + return this.moduleResolutionCache[fromFileName]?.[ + this.getModuleKey(moduleSpecifier, resolutionMode, /*noDtsResolution*/ undefined, /*allowJs*/ undefined) + ]?.trace; + } + + private getModuleKey( + moduleSpecifier: string, + resolutionMode: ts.ModuleKind.ESNext | ts.ModuleKind.CommonJS | undefined, + noDtsResolution: boolean | undefined, + allowJs: boolean | undefined + ) { + return `${resolutionMode ?? 1}:${+!!noDtsResolution}:${+!!allowJs}:${moduleSpecifier}`; } - createProgram(rootNames: string[]): ts.Program { + createProgram(rootNames: string[], extraOptions?: ts.CompilerOptions): ts.Program { + if ( + extraOptions && + ts.changesAffectModuleResolution( + // allowJs and noDtsResolution are part of the cache key, but any other resolution-affecting options + // are assumed to be constant for the host. + { + ...this.compilerOptions, + allowJs: extraOptions.allowJs, + checkJs: extraOptions.checkJs, + noDtsResolution: extraOptions.noDtsResolution, + }, + { ...this.compilerOptions, ...extraOptions } + ) + ) { + throw new Error("Cannot override resolution-affecting options for host due to potential cache polution"); + } return ts.createProgram({ rootNames, - options: this.compilerOptions, + options: extraOptions ? { ...this.compilerOptions, ...extraOptions } : this.compilerOptions, host: this.compilerHost, }); } diff --git a/packages/core/src/problems.ts b/packages/core/src/problems.ts index e096273..6082051 100644 --- a/packages/core/src/problems.ts +++ b/packages/core/src/problems.ts @@ -18,7 +18,7 @@ export interface ProblemKindInfo { export const problemKindInfo: Record = { Wildcard: { - emoji: "❓", + emoji: "🃏", title: "Wildcards", shortDescription: "Unable to check", description: "Wildcard subpaths cannot yet be analyzed by this tool.", @@ -89,6 +89,15 @@ export const problemKindInfo: Record = { docsUrl: "https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md", }, + MissingExportEquals: { + emoji: "❓", + title: "Types are missing an `export =`", + shortDescription: "Missing `export =`", + description: + "The JavaScript appears to set both `module.exports` and `module.exports.default` for improved compatibility, but the types only reflect the latter (by using `export default`). This will cause TypeScript under the `node16` module mode to think an extra `.default` property access is required, which will work at runtime but is not necessary. These types `export =` an object with a `default` property instead of using `export default`.", + docsUrl: + "https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/MissingExportEquals.md", + }, UnexpectedModuleSyntax: { emoji: "🚭", title: "Syntax is incompatible with detected module kind", diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 8b21ee1..9191b0b 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -84,7 +84,8 @@ export type EntrypointResolutionProblemKind = | "CJSResolvesToESM" | "Wildcard" | "FallbackCondition" - | "FalseExportDefault"; + | "FalseExportDefault" + | "MissingExportEquals"; export interface EntrypointResolutionProblem { kind: EntrypointResolutionProblemKind; diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index 36a446b..1b5fe57 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -102,6 +102,7 @@ export function isEntrypointResolutionProblemKind(kind: ProblemKind): kind is En case "Wildcard": case "FallbackCondition": case "FalseExportDefault": + case "MissingExportEquals": return true; default: return false as AssertNever; diff --git a/packages/core/test/fixtures/anymatch@3.1.3.tgz b/packages/core/test/fixtures/anymatch@3.1.3.tgz new file mode 100644 index 0000000..05145cd Binary files /dev/null and b/packages/core/test/fixtures/anymatch@3.1.3.tgz differ diff --git a/packages/core/test/fixtures/ignore@5.2.4.tgz b/packages/core/test/fixtures/ignore@5.2.4.tgz new file mode 100644 index 0000000..6e5818d Binary files /dev/null and b/packages/core/test/fixtures/ignore@5.2.4.tgz differ diff --git a/packages/core/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.json b/packages/core/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.json index bc9ff54..eafd176 100644 --- a/packages/core/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.json +++ b/packages/core/test/snapshots/@vitejs__plugin-react@3.1.0.tgz.json @@ -321,6 +321,16 @@ } }, "problems": [ + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-cjs" + }, { "kind": "FalseCJS", "entrypoint": ".", diff --git a/packages/core/test/snapshots/ajv@8.12.0.tgz.json b/packages/core/test/snapshots/ajv@8.12.0.tgz.json index 009179a..5b447e4 100644 --- a/packages/core/test/snapshots/ajv@8.12.0.tgz.json +++ b/packages/core/test/snapshots/ajv@8.12.0.tgz.json @@ -500,5 +500,26 @@ "isWildcard": false } }, - "problems": [] + "problems": [ + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-esm" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "bundler" + } + ] } diff --git a/packages/core/test/snapshots/anymatch@3.1.3.tgz.json b/packages/core/test/snapshots/anymatch@3.1.3.tgz.json new file mode 100644 index 0000000..dd5a6b9 --- /dev/null +++ b/packages/core/test/snapshots/anymatch@3.1.3.tgz.json @@ -0,0 +1,309 @@ +{ + "packageName": "anymatch", + "packageVersion": "3.1.3", + "types": { + "kind": "included" + }, + "buildTools": {}, + "entrypoints": { + ".": { + "subpath": ".", + "resolutions": { + "node10": { + "name": ".", + "resolutionKind": "node10", + "resolution": { + "fileName": "/node_modules/anymatch/index.d.ts", + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'anymatch' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/anymatch/package.json'.", + "File '/node_modules/anymatch.ts' does not exist.", + "File '/node_modules/anymatch.tsx' does not exist.", + "File '/node_modules/anymatch.d.ts' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "File '/node_modules/anymatch/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.d.ts' with Package ID 'anymatch/index.d.ts@3.1.3'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/anymatch/index.js", + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'anymatch' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "Found 'package.json' at '/node_modules/anymatch/package.json'.", + "File '/node_modules/anymatch.ts' does not exist.", + "File '/node_modules/anymatch.tsx' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: JavaScript, JSON.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "File '/node_modules/anymatch.js' does not exist.", + "File '/node_modules/anymatch.jsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.js' exists - use it as a name resolution result.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.js' with Package ID 'anymatch/index.js@3.1.3'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/anymatch/index.d.ts" + ] + }, + "node16-cjs": { + "name": ".", + "resolutionKind": "node16-cjs", + "resolution": { + "fileName": "/node_modules/anymatch/index.d.ts", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/anymatch/package.json" + }, + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'anymatch' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", + "File '/package.json' does not exist.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/anymatch/package.json'.", + "File '/node_modules/anymatch.ts' does not exist.", + "File '/node_modules/anymatch.tsx' does not exist.", + "File '/node_modules/anymatch.d.ts' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "File '/node_modules/anymatch/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.d.ts' with Package ID 'anymatch/index.d.ts@3.1.3'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/anymatch/index.js", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/anymatch/package.json" + }, + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'anymatch' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in CJS mode with conditions 'require', 'node'.", + "File '/package.json' does not exist.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "Found 'package.json' at '/node_modules/anymatch/package.json'.", + "File '/node_modules/anymatch.ts' does not exist.", + "File '/node_modules/anymatch.tsx' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "File '/node_modules/anymatch.js' does not exist.", + "File '/node_modules/anymatch.jsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.js' exists - use it as a name resolution result.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.js' with Package ID 'anymatch/index.js@3.1.3'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/anymatch/index.d.ts" + ] + }, + "node16-esm": { + "name": ".", + "resolutionKind": "node16-esm", + "resolution": { + "fileName": "/node_modules/anymatch/index.d.ts", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/anymatch/package.json" + }, + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'anymatch' from '/index.mts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/anymatch/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "File '/node_modules/anymatch/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.d.ts' with Package ID 'anymatch/index.d.ts@3.1.3'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/anymatch/index.js", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/anymatch/package.json" + }, + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'anymatch' from '/index.mts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in ESM mode with conditions 'import', 'node'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/anymatch/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/anymatch/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/anymatch/index.js' exists - use it as a name resolution result.", + "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/anymatch/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.js' with Package ID 'anymatch/index.js@3.1.3'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/anymatch/index.d.ts" + ] + }, + "bundler": { + "name": ".", + "resolutionKind": "bundler", + "resolution": { + "fileName": "/node_modules/anymatch/index.d.ts", + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'anymatch' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/anymatch/package.json'.", + "File '/node_modules/anymatch.ts' does not exist.", + "File '/node_modules/anymatch.tsx' does not exist.", + "File '/node_modules/anymatch.d.ts' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "File '/node_modules/anymatch/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.d.ts' with Package ID 'anymatch/index.d.ts@3.1.3'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/anymatch/index.js", + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'anymatch' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import'.", + "File '/package.json' does not exist.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "Found 'package.json' at '/node_modules/anymatch/package.json'.", + "File '/node_modules/anymatch.ts' does not exist.", + "File '/node_modules/anymatch.tsx' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "File '/node_modules/anymatch.js' does not exist.", + "File '/node_modules/anymatch.jsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.js' exists - use it as a name resolution result.", + "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'anymatch' from 'node_modules' folder, target file types: TypeScript.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "File '/node_modules/anymatch/package.json' exists according to earlier cached lookups.", + "File '/node_modules/anymatch.ts' does not exist.", + "File '/node_modules/anymatch.tsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/anymatch/index.ts' does not exist.", + "File '/node_modules/anymatch/index.tsx' does not exist.", + "======== Module name 'anymatch' was successfully resolved to '/node_modules/anymatch/index.js' with Package ID 'anymatch/index.js@3.1.3'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/anymatch/index.d.ts" + ] + } + }, + "hasTypes": true, + "isWildcard": false + } + }, + "problems": [ + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-esm" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "bundler" + } + ] +} diff --git a/packages/core/test/snapshots/hexoid@1.0.0.tgz.json b/packages/core/test/snapshots/hexoid@1.0.0.tgz.json index 83c05fc..3d29bb9 100644 --- a/packages/core/test/snapshots/hexoid@1.0.0.tgz.json +++ b/packages/core/test/snapshots/hexoid@1.0.0.tgz.json @@ -325,10 +325,25 @@ } }, "problems": [ + { + "kind": "FalseExportDefault", + "entrypoint": ".", + "resolutionKind": "node10" + }, + { + "kind": "FalseExportDefault", + "entrypoint": ".", + "resolutionKind": "node16-cjs" + }, { "kind": "FalseExportDefault", "entrypoint": ".", "resolutionKind": "node16-esm" + }, + { + "kind": "FalseExportDefault", + "entrypoint": ".", + "resolutionKind": "bundler" } ] } diff --git a/packages/core/test/snapshots/ignore@5.2.4.tgz.json b/packages/core/test/snapshots/ignore@5.2.4.tgz.json new file mode 100644 index 0000000..d5cf6b0 --- /dev/null +++ b/packages/core/test/snapshots/ignore@5.2.4.tgz.json @@ -0,0 +1,311 @@ +{ + "packageName": "ignore", + "packageVersion": "5.2.4", + "types": { + "kind": "included" + }, + "buildTools": { + "typescript": "^4.9.4" + }, + "entrypoints": { + ".": { + "subpath": ".", + "resolutions": { + "node10": { + "name": ".", + "resolutionKind": "node10", + "resolution": { + "fileName": "/node_modules/ignore/index.d.ts", + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'ignore' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/ignore/package.json'.", + "File '/node_modules/ignore.ts' does not exist.", + "File '/node_modules/ignore.tsx' does not exist.", + "File '/node_modules/ignore.d.ts' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "File '/node_modules/ignore/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.d.ts' with Package ID 'ignore/index.d.ts@5.2.4'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/ignore/index.js", + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'ignore' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "Found 'package.json' at '/node_modules/ignore/package.json'.", + "File '/node_modules/ignore.ts' does not exist.", + "File '/node_modules/ignore.tsx' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "Loading module 'ignore' from 'node_modules' folder, target file types: JavaScript, JSON.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "File '/node_modules/ignore.js' does not exist.", + "File '/node_modules/ignore.jsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.js' exists - use it as a name resolution result.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.js' with Package ID 'ignore/index.js@5.2.4'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/ignore/index.d.ts" + ] + }, + "node16-cjs": { + "name": ".", + "resolutionKind": "node16-cjs", + "resolution": { + "fileName": "/node_modules/ignore/index.d.ts", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/ignore/package.json" + }, + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'ignore' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in CJS mode with conditions 'require', 'types', 'node'.", + "File '/package.json' does not exist.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/ignore/package.json'.", + "File '/node_modules/ignore.ts' does not exist.", + "File '/node_modules/ignore.tsx' does not exist.", + "File '/node_modules/ignore.d.ts' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "File '/node_modules/ignore/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.d.ts' with Package ID 'ignore/index.d.ts@5.2.4'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/ignore/index.js", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/ignore/package.json" + }, + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'ignore' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in CJS mode with conditions 'require', 'node'.", + "File '/package.json' does not exist.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "Found 'package.json' at '/node_modules/ignore/package.json'.", + "File '/node_modules/ignore.ts' does not exist.", + "File '/node_modules/ignore.tsx' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "File '/node_modules/ignore.js' does not exist.", + "File '/node_modules/ignore.jsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.js' exists - use it as a name resolution result.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.js' with Package ID 'ignore/index.js@5.2.4'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/ignore/index.d.ts" + ] + }, + "node16-esm": { + "name": ".", + "resolutionKind": "node16-esm", + "resolution": { + "fileName": "/node_modules/ignore/index.d.ts", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/ignore/package.json" + }, + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'ignore' from '/index.mts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/ignore/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "File '/node_modules/ignore/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.d.ts' with Package ID 'ignore/index.d.ts@5.2.4'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/ignore/index.js", + "moduleKind": { + "detectedKind": 1, + "detectedReason": "no:type", + "reasonFileName": "/node_modules/ignore/package.json" + }, + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'ignore' from '/index.mts'. ========", + "Explicitly specified module resolution kind: 'Node16'.", + "Resolving in ESM mode with conditions 'import', 'node'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/ignore/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/ignore/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/ignore/index.js' exists - use it as a name resolution result.", + "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "'package.json' does not have a 'main' field.", + "File name '/node_modules/ignore/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.js' with Package ID 'ignore/index.js@5.2.4'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/ignore/index.d.ts" + ] + }, + "bundler": { + "name": ".", + "resolutionKind": "bundler", + "resolution": { + "fileName": "/node_modules/ignore/index.d.ts", + "isJson": false, + "isTypeScript": true, + "trace": [ + "======== Resolving module 'ignore' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/ignore/package.json'.", + "File '/node_modules/ignore.ts' does not exist.", + "File '/node_modules/ignore.tsx' does not exist.", + "File '/node_modules/ignore.d.ts' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "File '/node_modules/ignore/index.d.ts' exists - use it as a name resolution result.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.d.ts' with Package ID 'ignore/index.d.ts@5.2.4'. ========" + ] + }, + "implementationResolution": { + "fileName": "/node_modules/ignore/index.js", + "isJson": false, + "isTypeScript": false, + "trace": [ + "======== Resolving module 'ignore' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import'.", + "File '/package.json' does not exist.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript, JavaScript, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "Found 'package.json' at '/node_modules/ignore/package.json'.", + "File '/node_modules/ignore.ts' does not exist.", + "File '/node_modules/ignore.tsx' does not exist.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "File '/node_modules/ignore.js' does not exist.", + "File '/node_modules/ignore.jsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.js' exists - use it as a name resolution result.", + "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'ignore' from 'node_modules' folder, target file types: TypeScript.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript.", + "File '/node_modules/ignore/package.json' exists according to earlier cached lookups.", + "File '/node_modules/ignore.ts' does not exist.", + "File '/node_modules/ignore.tsx' does not exist.", + "'package.json' does not have a 'main' field.", + "File '/node_modules/ignore/index.ts' does not exist.", + "File '/node_modules/ignore/index.tsx' does not exist.", + "======== Module name 'ignore' was successfully resolved to '/node_modules/ignore/index.js' with Package ID 'ignore/index.js@5.2.4'. ========" + ] + }, + "files": [ + "/node_modules/typescript/lib/lib.d.ts", + "/node_modules/ignore/index.d.ts" + ] + } + }, + "hasTypes": true, + "isWildcard": false + } + }, + "problems": [ + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-esm" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "bundler" + } + ] +} diff --git a/packages/core/test/snapshots/postcss@8.4.21.tgz.json b/packages/core/test/snapshots/postcss@8.4.21.tgz.json index b21843b..deb8127 100644 --- a/packages/core/test/snapshots/postcss@8.4.21.tgz.json +++ b/packages/core/test/snapshots/postcss@8.4.21.tgz.json @@ -8255,6 +8255,16 @@ } }, "problems": [ + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": ".", + "resolutionKind": "node16-cjs" + }, { "kind": "FalseCJS", "entrypoint": ".", @@ -8271,55 +8281,205 @@ "resolutionKind": "bundler" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/at-rule", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/at-rule", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/at-rule", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/at-rule", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/comment", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/comment", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/comment", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/comment", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/container", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/container", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/container", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/container", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/css-syntax-error", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/css-syntax-error", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/css-syntax-error", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/css-syntax-error", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/declaration", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/declaration", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/declaration", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/declaration", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/fromJSON", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/fromJSON", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/fromJSON", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/fromJSON", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/input", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/input", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/input", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/input", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/lazy-result", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/lazy-result", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/lazy-result", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/lazy-result", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/no-work-result", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/no-work-result", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/no-work-result", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/no-work-result", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/list", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/list", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/list", "resolutionKind": "node16-esm" }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/list", + "resolutionKind": "bundler" + }, { "kind": "UntypedResolution", "entrypoint": "./lib/map-generator", @@ -8341,15 +8501,45 @@ "resolutionKind": "bundler" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/node", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/node", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/node", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/node", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/parse", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/parse", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/parse", "resolutionKind": "node16-esm" }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/parse", + "resolutionKind": "bundler" + }, { "kind": "UntypedResolution", "entrypoint": "./lib/parser", @@ -8371,45 +8561,165 @@ "resolutionKind": "bundler" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/postcss", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/postcss", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/postcss", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/postcss", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/previous-map", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/previous-map", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/previous-map", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/previous-map", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/processor", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/processor", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/processor", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/processor", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/result", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/result", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/result", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/result", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/root", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/root", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/root", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/root", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/rule", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/rule", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/rule", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/rule", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/stringifier", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/stringifier", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/stringifier", "resolutionKind": "node16-esm" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/stringifier", + "resolutionKind": "bundler" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/stringify", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/stringify", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/stringify", "resolutionKind": "node16-esm" }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/stringify", + "resolutionKind": "bundler" + }, { "kind": "UntypedResolution", "entrypoint": "./lib/symbols", @@ -8491,9 +8801,24 @@ "resolutionKind": "bundler" }, { - "kind": "FalseExportDefault", + "kind": "MissingExportEquals", + "entrypoint": "./lib/warning", + "resolutionKind": "node10" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/warning", + "resolutionKind": "node16-cjs" + }, + { + "kind": "MissingExportEquals", "entrypoint": "./lib/warning", "resolutionKind": "node16-esm" + }, + { + "kind": "MissingExportEquals", + "entrypoint": "./lib/warning", + "resolutionKind": "bundler" } ] }