Skip to content

fix: subpath patterns in exports #666

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix: subpath patterns in exports #666

wants to merge 3 commits into from

Conversation

ogonkov
Copy link
Contributor

@ogonkov ogonkov commented Mar 4, 2025

Current exports seems dosn't work at all, looks like TS just guess path with old moduleResolution, and fail to resolve anything with new moduleResolution: bundler

Trace of resolution with node10 resolution

======== Resolving module '@gravity-ui/markdown-editor/extensions/additional/Math' from '/Users/user/Projects/project/src/ui/components/common/YfmEditor/useYfmEditorOptions.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
'paths' option is specified, looking for a pattern to match module name '@gravity-ui/markdown-editor/extensions/additional/Math'.
Loading module '@gravity-ui/markdown-editor/extensions/additional/Math' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/user/Projects/project/src/ui/components/common/YfmEditor/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'gravity-ui__markdown-editor/extensions/additional/Math'
Directory '/Users/user/Projects/project/src/ui/components/common/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'gravity-ui__markdown-editor/extensions/additional/Math'
Directory '/Users/user/Projects/project/src/ui/components/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'gravity-ui__markdown-editor/extensions/additional/Math'
Directory /Users/user/Projects/project/src/ui/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'gravity-ui__markdown-editor/extensions/additional/Math'
Directory '/Users/user/Projects/project/src/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'gravity-ui__markdown-editor/extensions/additional/Math'
File '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/package.json' exists according to earlier cached lookups.
'package.json' has a 'typesVersions' entry '*' that matches compiler version '5.7.2', looking for a pattern to match module name 'extensions/additional/Math'.
Module name 'extensions/additional/Math', matched pattern 'extensions/*'.
Trying substitution './build/esm/extensions/*', candidate module location: './build/esm/extensions/additional/Math'.
File '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math.ts' does not exist.
File '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math.tsx' does not exist.
File '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'build/esm/index.d.ts' that references '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/build/esm/index.d.ts'.
'package.json' has a 'typesVersions' entry '*' that matches compiler version '5.7.2', looking for a pattern to match module name 'build/esm/index.d.ts'.
Loading module as file / folder, candidate module location '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/build/esm/index.d.ts', target file types: TypeScript, Declaration.
File name '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/build/esm/index.d.ts' has a '.d.ts' extension - stripping it.
File '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/index.ts' does not exist.
File '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/index.tsx' does not exist.
File '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/index.d.ts' exists - use it as a name resolution result.
Resolving real path for '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/index.d.ts', result '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/index.d.ts'.
======== Module name '@gravity-ui/markdown-editor/extensions/additional/Math' was successfully resolved to '/Users/user/Projects/project/node_modules/@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/index.d.ts' with Package ID '@gravity-ui/markdown-editor/build/esm/extensions/additional/Math/[email protected]+@diplodoc/c

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

},
"require": {
"types": "./build/cjs/extensions/*",
"default": "./build/cjs/extensions/*"
"types": "./build/cjs/extensions/*/index.d.ts",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! We’ve reviewed the pull request and have a couple of suggestions:

  1. We recommend using absolute paths to the index file in all extensions from additional.
  2. The same applies to the view folder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

"./extensions/Mermaid": {
  "default": "./build/cjs/extensions/additional/Mermaid/index.js",
},
"./view/mermaid": {
  "default": "./build/cjs/view/mermaid.js", // here exports all things related to diplodoc/mermaid-extension in src/view
},

@makhnatkin
Copy link
Collaborator

@ogonkov is it still actual?

@ogonkov
Copy link
Contributor Author

ogonkov commented Apr 29, 2025

I think yes, i will make changes that we discuss later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants