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

feat(import.meta): add dirname and filename#19990

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

Draft
avivkeller wants to merge2 commits intowebpack:main
base:main
Choose a base branch
Loading
fromforked-by-avivkeller:import-meta-dirname-filename

Conversation

avivkeller
Copy link
Member

@avivkelleravivkeller commentedOct 7, 2025
edited
Loading

Summary

Fixes#18320 by adding the requestedimport.meta properties.

What kind of change does this PR introduce?

This PR adds support forimport.meta.{dirname,filename}, having them return the identical data that__dirname and__filename return.

Did you add tests for your changes?

Yes. I verified thatimport.meta.dirname + [filename] === import.meta.filename === an existing file.
Does this PR introduce a breaking change?

No, this is asemver-minor change.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Once merged, the additional properties must be documented accordingly.

Copy link
Member

@alexander-akaitalexander-akait left a comment
edited
Loading

Choose a reason for hiding this comment

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

It should not work like here, import.meta.dirname and import.meta.filename arenot supported by browsers (and maybe other envs), we should do the same as for__dirname and__filename, look atNdeStuffPlugin.js and we should do the same

Developer can usefs.readFileSync(import.meta.filename) and after bundling the path will be broken

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedOct 7, 2025
edited
Loading

CodSpeed Performance Report

Merging#19990 willnot alter performance

Comparingforked-by-avivkeller:import-meta-dirname-filename (5cc506d) withmain (c7ebdbd)

Summary

✅ 42 untouched

@avivkeller
Copy link
MemberAuthor

It should not work like here, import.meta.dirname and import.meta.filename arenot supported by browsers (and maybe other envs), we should do the same as for__dirname and__filename, look atNdeStuffPlugin.js and we should do the same

Developer can usefs.readFileSync(import.meta.filename) and after bundling the path will be broken

You mean like a variable response depending on the value ofnode?

@alexander-akait
Copy link
Member

@avivkeller Yeah, we should duplicate logic, but for such things, and improvenode-module output for commonjs whenimport.meta.dirname andimport.meta.filename are supported (look atlib/config/target.js), also make sense to introducenode-commonjs value when you want to bundle ES modules to commonjs.

Feel free to split these steps into multiple commits/PRs

avivkeller reacted with rocket emoji

@avivkelleravivkeller marked this pull request as draftOctober 7, 2025 16:43
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@alexander-akaitalexander-akaitalexander-akait requested changes

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

supportimport.meta.dirname andimport.meta.filename
2 participants
@avivkeller@alexander-akait

[8]ページ先頭

©2009-2025 Movatter.jp