-
-
Notifications
You must be signed in to change notification settings - Fork 550
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
[Bug]: node.__dirname: true causes broken output on Windows #8170
Labels
Comments
lauriharpf
added
bug
Something isn't working
pending triage
The issue/PR is currently untouched.
labels
Oct 18, 2024
I will try to fix it. |
Thank you! 🙏 As an additional observation, noticed that this only seems to affect |
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
System Info
System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 5.78 GB / 15.82 GB
Binaries:
Node: 20.18.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.12.2 - ~\AppData\Roaming\npm\pnpm.CMD
Browsers:
Chrome: 129.0.6668.101
Edge: Spartan (44.19041.1266.0), Chromium (129.0.2792.89)
Internet Explorer: 11.0.19041.1566
Details
Note: This issue only reproduces when building on Windows, as Windows uses the
\
path separator.If
node: { __dirname: true }
(webpack documentation) is used in the RsPack config and__dirname
cmd
command promptthen RsPack output contains unescaped
\
characters (e.g.__dirname: ${'src\foo\bar\baz'}
), resulting in an unexpected string and not matching the webpack output (e.g.var __dirname = "src\\foo\\bar\\baz"; ... `__dirname: ${__dirname}
).(Thank you for your awesome work on this project 🙏❤ . Hope this report proves to be useful!)
Reproduce link
https://github.com/lauriharpf/rspack-node-dirname/tree/main
Reproduce Steps
node: { __dirname: true }
in the RsPack configuration.__dirname
in a subdirectory file in the code being built (for example, like in the reproduce repo).cmd
command promptWhat happens
RsPack does not escape the
\
-separator, output is e.g.src\foo\bar\baz
. See https://github.com/lauriharpf/rspack-node-dirname/blob/main/rspack-dist/src_foo_bar_baz_render_js.js#L15webpack escapes the
\
-separator, output is e.g.src\\foo\\bar\\baz
. See https://github.com/lauriharpf/rspack-node-dirname/blob/main/webpack-dist/src_foo_bar_baz_render_js.js#L10Desired result
RsPack and webpack build results match in terms of
__dirname
: both produce escaped output, e.g.src\\foo\\bar\\baz
The text was updated successfully, but these errors were encountered: