Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: correctly identify imports with resolution-mode (#582)#595

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
FoxxMD wants to merge1 commit intoYousefED:master
base:master
Choose a base branch
Loading
fromFoxxMD:importResolutionFix

Conversation

@FoxxMD
Copy link

Used fix provided by@jer-sen andcloses#582

Ibelieve this only occurs for ESM projects with"moduleResolution": "NodeNext" intsconfig.json and introduced inTS 4.7. This fix is backwards compatible.

constvm=require("vm");

constREGEX_FILE_NAME_OR_SPACE=/(\bimport\(".*?"\)|".*?")\.|/g;
constREGEX_FILE_NAME_OR_SPACE=/(\bimport\(".*?"(,\{assert:\{"resolution-mode":"(import|require)"\}\})?\)|".*?")\.|/g;
Copy link

@derdekaderdekaAug 26, 2025
edited
Loading

Choose a reason for hiding this comment

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

Hi@FoxxMD,
thank you for pointing in the right direction. I had to use a different regex when usingtypescript@22.14.0 andtypescript@5.8.3 withesm modules:

Suggested change
constREGEX_FILE_NAME_OR_SPACE=/(\bimport\(".*?"(,\{assert:\{"resolution-mode":"(import|require)"\}\})?\)|".*?")\.|/g;
constREGEX_FILE_NAME_OR_SPACE=/(\bimport\(.*?\)|".*?")\.|/g;

I'm patching this line with the help ofpatch-package intotypescript-json-schema to make it working again.

@YousefED Thank you for this great package! I would like to politely ask if this regular expression could be updated to work with ESM packages.

edit:
as just discovered@puckey suggests this change:

Suggested change
constREGEX_FILE_NAME_OR_SPACE=/(\bimport\(".*?"(,\{assert:\{"resolution-mode":"(import|require)"\}\})?\)|".*?")\.|/g;
constREGEX_FILE_NAME_OR_SPACE=/(\bimport\(".*?"(,[^)]+)?\)|".*?")\.|/g;

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@derdekaderdekaderdeka left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

imports with resolution-mode not replaced

2 participants

@FoxxMD@derdeka

[8]ページ先頭

©2009-2025 Movatter.jp