Skip to content

add node-module option for node.__file/dirname#17931

Merged
alexander-akait merged 14 commits intowebpack:mainfrom
iamyamakin:feature-14072
Jan 10, 2024
Merged

add node-module option for node.__file/dirname#17931
alexander-akait merged 14 commits intowebpack:mainfrom
iamyamakin:feature-14072

Conversation

@iamyamakin
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

feature

closes #14072

Did you add tests for your changes?

yes

Does this PR introduce a breaking change?

no

What needs to be documented once your changes are merged?

new options node.__filename=node-module / node.__dirname=node-module

generate __filename and __dirname for common js modules when output.module=true to
fileURLToPath(import.meta.url) and fileURLToPath(import.meta.url + "/..") respectively

p.s. That is copy of #14247 with merge commit.

vankop and others added 14 commits September 14, 2021 16:50
evaluate __filename and __dirname for common js modules when output.module to
fileURLToPath(import.meta.url) and fileURLToPath(import.meta.url + "/..") respectively
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
# Conflicts:
#	lib/dependencies/CachedConstDependency.js
#	schemas/WebpackOptions.check.js
# Conflicts:
#	schemas/WebpackOptions.check.js
# Conflicts:
#	lib/DependencyTemplate.js
#	lib/javascript/JavascriptGenerator.js
#	schemas/WebpackOptions.check.js
#	types.d.ts
@webpack-bot
Copy link
Copy Markdown
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Jan 9, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Copy Markdown
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Looks good for me, can you sign CLA?

@iamyamakin
Copy link
Copy Markdown
Contributor Author

@alexander-akait done, something else?

@alexander-akait alexander-akait merged commit f1b0bd5 into webpack:main Jan 10, 2024
@alexander-akait
Copy link
Copy Markdown
Member

Thank you, release will be soon

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

Projects

No open projects
Status: Shipped

Development

Successfully merging this pull request may close these issues.

ESM builds should substitute __filename and __dirname references in CommonJS

4 participants