add node-module option for node.__file/dirname#14247
Conversation
evaluate __filename and __dirname for common js modules when output.module to fileURLToPath(import.meta.url) and fileURLToPath(import.meta.url + "/..") respectively
|
For maintainers only:
|
Co-authored-by: Tobias Koppers <[email protected]>
4e83305 to
bf01661
Compare
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
# Conflicts: # lib/dependencies/CachedConstDependency.js # schemas/WebpackOptions.check.js
sokra
left a comment
There was a problem hiding this comment.
Found these old review comments... not sure if they are still relevant
| @@ -199,7 +199,8 @@ class JavascriptGenerator extends Generator { | |||
| runtime: generateContext.runtime, | |||
There was a problem hiding this comment.
Unrelated: For performance reasons we should only create templateContext once per module.
# Conflicts: # schemas/WebpackOptions.check.js
# Conflicts: # lib/DependencyTemplate.js # lib/javascript/JavascriptGenerator.js # schemas/WebpackOptions.check.js # types.d.ts
alexander-akait
left a comment
There was a problem hiding this comment.
@vankop can you rebase, I think we can merge it and I am fine with it, thank you
|
@sokra do you mind if i create PR with a merge commit? I see a few conflicts between this branch and main:
|
|
I'll rebase this PR, no worries. |
|
Yeah, feel free to send again, I am fine with the such improve |
|
I've created an issue to document this in webpack/webpack.js.org. |
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
__filenameand__dirnamefor common js modules when output.module=true tofileURLToPath(import.meta.url)andfileURLToPath(import.meta.url + "/..")respectively